-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Button): add Button to @carbon/styles (#8834)
* feat(Button): add button styles to @carbon/styles * fix(Button): don't allow visibility of tooltip by default * test(Button): update snapshots * test(Button): add button style tests * fix(Button): change convert import, add visually hidden classes * fix(Tooltip): add space after minus sign"
- Loading branch information
Showing
13 changed files
with
892 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/carbon-react/src/components/Button/Button.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { Add16 } from '@carbon/icons-react'; | ||
import { Button, ButtonSet, ButtonSkeleton } from 'carbon-components-react'; | ||
|
||
export default { | ||
title: 'Components/Button', | ||
parameters: { | ||
component: Button, | ||
subcomponents: { | ||
ButtonSet, | ||
ButtonSkeleton, | ||
}, | ||
}, | ||
}; | ||
|
||
export const _Default = () => { | ||
return <Button>Button</Button>; | ||
}; | ||
|
||
export const Secondary = () => { | ||
return <Button kind="secondary">Button</Button>; | ||
}; | ||
|
||
export const Tertiary = () => { | ||
return <Button kind="tertiary">Button</Button>; | ||
}; | ||
|
||
export const Danger = () => { | ||
return ( | ||
<> | ||
<Button kind="danger">Button</Button> | ||
| ||
<Button kind="danger--tertiary">Tertiary Danger Button</Button> | ||
| ||
<Button kind="danger--ghost">Ghost Danger Button</Button> | ||
</> | ||
); | ||
}; | ||
|
||
export const Ghost = () => { | ||
return <Button kind="ghost">Button</Button>; | ||
}; | ||
|
||
export const IconButton = () => ( | ||
<Button | ||
renderIcon={Add16} | ||
iconDescription="Icon Description" | ||
hasIconOnly | ||
onClick={action('onClick')} | ||
/> | ||
); | ||
|
||
export const SetOfButtons = () => { | ||
return ( | ||
<ButtonSet> | ||
<Button kind="secondary">Secondary button</Button> | ||
<Button kind="primary">Primary button</Button> | ||
</ButtonSet> | ||
); | ||
}; | ||
|
||
export const Skeleton = () => ( | ||
<div> | ||
<ButtonSkeleton /> | ||
| ||
<ButtonSkeleton small /> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
export { Button } from 'carbon-components-react'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright IBM Corp. 2018, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @jest-environment node | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { SassRenderer } = require('@carbon/test-utils/scss'); | ||
|
||
const { render } = SassRenderer.create(__dirname); | ||
|
||
describe('scss/components/button', () => { | ||
test('Public API', async () => { | ||
const { unwrap } = await render(` | ||
@use 'sass:map'; | ||
@use 'sass:meta'; | ||
@use '../button'; | ||
$_: get('mixin', meta.mixin-exists('button', 'button')); | ||
$_: get('variables', map.keys(meta.module-variables('button'))); | ||
`); | ||
expect(unwrap('mixin')).toBe(true); | ||
expect(unwrap('variables')).toMatchInlineSnapshot(` | ||
Array [ | ||
"button-font-weight", | ||
"button-font-size", | ||
"button-border-radius", | ||
"button-height", | ||
"button-padding", | ||
"button-padding-field", | ||
"button-padding-sm", | ||
"button-padding-lg", | ||
"button-padding-ghost", | ||
"button-padding-ghost-field", | ||
"button-padding-ghost-sm", | ||
"button-border-width", | ||
"button-outline-width", | ||
] | ||
`); | ||
}); | ||
|
||
test('configuration', async () => { | ||
const { unwrap } = await render(` | ||
@use '../button' with ( | ||
$button-height: 2rem, | ||
); | ||
$_: get('height', button.$button-height); | ||
`); | ||
expect(unwrap('height')).toBe('2rem'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
@use 'accordion'; | ||
@use 'breadcrumb'; | ||
@use 'button'; | ||
@use 'link'; | ||
@use 'list'; | ||
@use 'loading'; |
Oops, something went wrong.