Skip to content

Commit

Permalink
Merge branch 'main' into deprecate-controlled-password-input
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed May 12, 2021
2 parents 41ec341 + c334c5d commit 1ff244a
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 89 deletions.
24 changes: 22 additions & 2 deletions packages/components/src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,23 @@
padding: $button-padding-field;
}

//expressive styles
.#{$prefix}--btn--expressive {
@include carbon--type-style('body-short-02');

min-height: 3rem;
}

.#{$prefix}--btn--icon-only.#{$prefix}--btn--expressive {
padding: 12px 13px;
//default size 48px
}

.#{$prefix}--btn.#{$prefix}--btn--expressive .#{$prefix}--btn__icon {
width: rem(20px);
height: rem(20px);
}

// Skeleton State
.#{$prefix}--btn.#{$prefix}--skeleton {
@include skeleton;
Expand All @@ -458,8 +475,6 @@

.#{$prefix}--btn-set .#{$prefix}--btn {
width: 100%;
// 196px from design kit
max-width: rem(196px);

&:not(:focus) {
box-shadow: rem(-1px) 0 0 0 $button-separator;
Expand All @@ -470,6 +485,11 @@
}
}

.#{$prefix}--btn-set .#{$prefix}--btn:not(.#{$prefix}--btn--expressive) {
// 196px from design kit
max-width: rem(196px);
}

.#{$prefix}--btn-set .#{$prefix}--btn:focus + .#{$prefix}--btn {
box-shadow: inherit;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/components/list/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
list-style: none;
}

.#{$prefix}--list--expressive,
.#{$prefix}--list--expressive .#{$prefix}--list--nested {
@include type-style('body-long-02');
}

.#{$prefix}--list--ordered--native {
list-style: decimal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,18 @@
background-color: $field-02;
}

.#{$prefix}--number--light .#{$prefix}--number__control-btn:focus::before,
.#{$prefix}--number--light .#{$prefix}--number__control-btn:focus::after {
background-color: transparent;
}

// V11: Possibly deprecate
.#{$prefix}--number--light .#{$prefix}--number__control-btn:hover,
.#{$prefix}--number--light .#{$prefix}--number__control-btn:hover::before,
.#{$prefix}--number--light .#{$prefix}--number__control-btn:hover::after {
background-color: $hover-light-ui;
}

.#{$prefix}--number--light .#{$prefix}--number__control-btn:focus::before,
.#{$prefix}--number--light .#{$prefix}--number__control-btn:focus::after {
background-color: transparent;
}

// Size Variant styles
// TODO V11: Remove xl selector
.#{$prefix}--number--xl input[type='number'],
Expand Down
12 changes: 12 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Map {
"defaultProps": Object {
"dangerDescription": "danger",
"disabled": false,
"isExpressive": false,
"kind": "primary",
"size": "default",
"tabIndex": 0,
Expand Down Expand Up @@ -194,6 +195,9 @@ Map {
"type": "string",
},
"iconDescription": [Function],
"isExpressive": Object {
"type": "bool",
},
"isSelected": Object {
"type": "bool",
},
Expand Down Expand Up @@ -4250,6 +4254,7 @@ Map {
},
"OrderedList" => Object {
"defaultProps": Object {
"isExpressive": false,
"native": false,
"nested": false,
},
Expand All @@ -4260,6 +4265,9 @@ Map {
"className": Object {
"type": "string",
},
"isExpressive": Object {
"type": "bool",
},
"native": Object {
"type": "bool",
},
Expand Down Expand Up @@ -6488,6 +6496,7 @@ Map {
},
"UnorderedList" => Object {
"defaultProps": Object {
"isExpressive": false,
"nested": false,
},
"propTypes": Object {
Expand All @@ -6497,6 +6506,9 @@ Map {
"className": Object {
"type": "string",
},
"isExpressive": Object {
"type": "bool",
},
"nested": Object {
"type": "bool",
},
Expand Down
74 changes: 72 additions & 2 deletions packages/react/src/components/Button/Button-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const props = {
const iconToUse = iconMap[select('Icon (icon)', icons, 'none')];
return {
className: 'some-class',
isExpressive: boolean('Expressive', false),
kind: select('Button kind (kind)', kinds, 'primary'),
disabled: boolean('Disabled (disabled)', false),
size: select('Button size (size)', sizes, 'default'),
Expand All @@ -96,6 +97,7 @@ const props = {
}
return {
className: 'some-class',
isExpressive: boolean('Expressive', false),
kind: select('Button kind (kind)', kinds, 'primary'),
disabled: boolean('Disabled (disabled)', false),
isSelected: boolean('Selected (isSelected)', false),
Expand Down Expand Up @@ -123,6 +125,7 @@ const props = {
const iconToUse = iconMap[select('Icon (icon)', icons, 'none')];
return {
className: 'some-class',
isExpressive: boolean('Expressive', false),
disabled: boolean('Disabled (disabled)', false),
size: select('Button size (size)', sizes, 'default'),
renderIcon: !iconToUse || iconToUse.svgData ? undefined : iconToUse,
Expand Down Expand Up @@ -196,10 +199,14 @@ export const Playground = () => {
alignItems: 'center',
flexWrap: 'wrap',
}}>
<Button {...regularProps}>Button</Button>
<Button {...regularProps}>Buttons</Button>
&nbsp;
{!regularProps.kind.includes('danger') && (
<Button hasIconOnly {...iconOnly}></Button>
<>
<Button hasIconOnly {...iconOnly}></Button>
&nbsp;
<Button hasIconOnly {...iconOnly} kind="ghost"></Button>
</>
)}
</div>
<div
Expand Down Expand Up @@ -241,6 +248,69 @@ export const SetOfButtons = () => {
);
};

export const ExpressiveButtons = () => {
return (
<>
<div
style={{
margin: '1rem',
}}>
<Button isExpressive size="default">
Button
</Button>
</div>
<div
style={{
margin: '1rem',
}}>
<Button isExpressive size="lg">
Button
</Button>
</div>
<div
style={{
margin: '1rem',
}}>
<Button isExpressive size="xl">
Button
</Button>
</div>
<div
style={{
margin: '1rem',
}}>
<Button isExpressive size="default" renderIcon={Add16}>
Button
</Button>
</div>
<div
style={{
margin: '1rem',
}}>
<Button
isExpressive
renderIcon={Add16}
hasIconOnly
iconDescription="Icon description"
/>
</div>
<div
style={{
marginTop: '1rem',
}}>
<ButtonSet>
<Button kind="secondary" isExpressive>
Secondary button
</Button>
<Button kind="primary" isExpressive>
Primary button
</Button>
</ButtonSet>
</div>
</>
);
};

export const Skeleton = () => (
<div>
<ButtonSkeleton />
Expand Down
16 changes: 14 additions & 2 deletions packages/react/src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Button = React.forwardRef(function Button(
size,
kind,
href,
isExpressive,
isSelected,
tabIndex,
type,
Expand Down Expand Up @@ -122,14 +123,19 @@ const Button = React.forwardRef(function Button(

const buttonClasses = classNames(className, {
[`${prefix}--btn`]: true,
[`${prefix}--btn--sm`]: size === 'small' || size === 'sm' || small,
[`${prefix}--btn--md`]: size === 'field' || size === 'md',
[`${prefix}--btn--sm`]:
(size === 'small' && !isExpressive) ||
(size === 'sm' && !isExpressive) ||
(small && !isExpressive),
[`${prefix}--btn--md`]:
(size === 'field' && !isExpressive) || (size === 'md' && !isExpressive),
// V11: change lg to xl
[`${prefix}--btn--lg`]: enabled ? size === 'xl' : size === 'lg',
// V11: change xl to 2xl
[`${prefix}--btn--xl`]: enabled ? size === '2xl' : size === 'xl',
[`${prefix}--btn--${kind}`]: kind,
[`${prefix}--btn--disabled`]: disabled,
[`${prefix}--btn--expressive`]: isExpressive,
[`${prefix}--tooltip--hidden`]: hasIconOnly && !allowTooltipVisibility,
[`${prefix}--tooltip--visible`]: isHovered,
[`${prefix}--btn--icon-only`]: hasIconOnly,
Expand Down Expand Up @@ -275,6 +281,11 @@ Button.propTypes = {
return undefined;
},

/**
* Specify whether the Button is expressive, or not
*/
isExpressive: PropTypes.bool,

/**
* Specify whether the Button is currently selected
*/
Expand Down Expand Up @@ -383,6 +394,7 @@ Button.defaultProps = {
dangerDescription: 'danger',
tooltipAlignment: 'center',
tooltipPosition: 'top',
isExpressive: false,
};

export default Button;
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,7 @@ exports[`DataTable should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
size="small"
Expand Down Expand Up @@ -2047,6 +2048,7 @@ exports[`DataTable should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand Down Expand Up @@ -2126,6 +2128,7 @@ exports[`DataTable should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand Down Expand Up @@ -2205,6 +2208,7 @@ exports[`DataTable should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand Down Expand Up @@ -2276,6 +2280,7 @@ exports[`DataTable should render 1`] = `
className="bx--batch-summary__cancel"
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[Function]}
size="default"
Expand Down Expand Up @@ -2536,6 +2541,7 @@ exports[`DataTable should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
size="small"
Expand Down Expand Up @@ -2926,6 +2932,7 @@ exports[`DataTable sticky header should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
size="small"
Expand Down Expand Up @@ -3089,6 +3096,7 @@ exports[`DataTable sticky header should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand Down Expand Up @@ -3168,6 +3176,7 @@ exports[`DataTable sticky header should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand Down Expand Up @@ -3247,6 +3256,7 @@ exports[`DataTable sticky header should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
renderIcon={
Expand Down Expand Up @@ -3318,6 +3328,7 @@ exports[`DataTable sticky header should render 1`] = `
className="bx--batch-summary__cancel"
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[Function]}
size="default"
Expand Down Expand Up @@ -3578,6 +3589,7 @@ exports[`DataTable sticky header should render 1`] = `
<Button
dangerDescription="danger"
disabled={false}
isExpressive={false}
kind="primary"
onClick={[MockFunction]}
size="small"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports[`DataTable.TableBatchAction should render 1`] = `
dangerDescription="danger"
disabled={false}
iconDescription="test"
isExpressive={false}
kind="primary"
renderIcon={
Object {
Expand Down
Loading

0 comments on commit 1ff244a

Please sign in to comment.