Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Refactored Button styles to use createStyles utility #2285

Merged
merged 105 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
a56f895
feat: Add static css function
NicholasBoll Jun 28, 2023
3407964
Fix import
NicholasBoll Jun 28, 2023
6716d61
add labs button
NicholasBoll Jun 29, 2023
98b372c
feat: Button refactor
josh-bagwell Jul 13, 2023
703dced
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Jul 13, 2023
6de7eed
chore: Button refactor
josh-bagwell Jul 14, 2023
eb5bed1
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Jul 14, 2023
7b60877
chore: Button Refactor
josh-bagwell Jul 19, 2023
8a94d93
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Jul 19, 2023
0992bb3
feat: Adjusted for Tertiary Buttons
josh-bagwell Jul 25, 2023
45e403b
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Jul 25, 2023
353632a
feat: Button Re-factor for Tertiary
josh-bagwell Jul 28, 2023
1f6b9f9
fix: Removed imports
josh-bagwell Jul 28, 2023
0dec176
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Jul 28, 2023
43cf967
feat: Button Refactor fixing theme
josh-bagwell Jul 31, 2023
2c3c927
feat: Fixing issues
josh-bagwell Jul 31, 2023
d5f1949
feat: Fixing issues
josh-bagwell Jul 31, 2023
148b6f5
fix: Fixed items
josh-bagwell Jul 31, 2023
e4bc666
fix: Fixing issues
josh-bagwell Jul 31, 2023
35c74a8
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Jul 31, 2023
d041fcd
feat: Adjusted hover state
josh-bagwell Aug 1, 2023
42e973c
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Aug 11, 2023
3ac399c
feat: Button refactor adjustments
josh-bagwell Aug 14, 2023
f1aa2da
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Aug 14, 2023
3109f7c
feat: Button Styles Refactor
josh-bagwell Aug 16, 2023
0950f08
feat: Button Styles Refactor edits
josh-bagwell Aug 21, 2023
c32085d
feat: Button Styles Refactor primary edits
josh-bagwell Aug 21, 2023
6618c1f
feat: Button Styles Refactor added testing
josh-bagwell Aug 21, 2023
87b5fe9
feat: Button Styles Refactor
josh-bagwell Aug 22, 2023
d135a6a
feat: Button Styles Refactor
josh-bagwell Aug 22, 2023
3e610c0
feat: Button Styles Update
josh-bagwell Aug 22, 2023
cf18679
feat: Button Styles Refactor made edits to provider
josh-bagwell Aug 25, 2023
b4d8619
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Aug 25, 2023
f6aa1a2
feat: Added ignore for TS error for now
josh-bagwell Aug 25, 2023
8470c26
feat: Button Styles Updates
josh-bagwell Aug 29, 2023
2d471d4
feat: Button Styles Refactor visual testing primary
josh-bagwell Aug 30, 2023
e2cdc29
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Aug 30, 2023
70edc9e
feat: Button Styles Refactor updated
josh-bagwell Aug 30, 2023
649d879
feat: Button Styles Refactor Updated Visual Test
josh-bagwell Aug 30, 2023
b4ff41b
feat: Button Styles added tokens
josh-bagwell Sep 6, 2023
edd568d
feat: Button Styles added tokens from brand
josh-bagwell Sep 8, 2023
43ee646
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Sep 8, 2023
d413074
feat: Added tokens
josh-bagwell Sep 11, 2023
e405d8e
feat: Updated labs package
josh-bagwell Sep 12, 2023
11e4378
feat: Fixed package
josh-bagwell Sep 12, 2023
c45842f
feat: Visual Tests using labs buttons
josh-bagwell Sep 12, 2023
9a1fd88
feat: Added new focus outline
josh-bagwell Sep 13, 2023
d979ca8
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Sep 13, 2023
c0a077a
feat: Fixed yarn lock file
josh-bagwell Sep 13, 2023
c22371d
feat: Fixed button widths
josh-bagwell Sep 19, 2023
eb9b608
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Sep 19, 2023
5de52e7
feat: Adjusted button examples
josh-bagwell Sep 20, 2023
2b53f41
feat: Adjusted buttons to shorten code length
josh-bagwell Sep 20, 2023
db472eb
feat: Updated modifiers
josh-bagwell Sep 20, 2023
76b9369
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Sep 20, 2023
78ce9fd
feat: Adjusted Delete Button
josh-bagwell Sep 21, 2023
1c06746
feat: Started button migration
josh-bagwell Sep 22, 2023
b2d6bda
feat: Fixed exports of functions for basebutton
josh-bagwell Sep 26, 2023
703dad4
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Sep 26, 2023
a48b40f
feat: Fixed issues with exports on buttons
josh-bagwell Sep 26, 2023
3a40da3
feat: Fixed deletebutton
josh-bagwell Sep 26, 2023
fc3ae0e
feat: Fixed base button
josh-bagwell Sep 26, 2023
93cf47b
feat: Adjusted buttons for segmented control
josh-bagwell Sep 26, 2023
8fe549a
feat: Fixed focusring and removed labs button folder
josh-bagwell Sep 27, 2023
dae63e7
feat: Fixed package file
josh-bagwell Sep 28, 2023
0a73f80
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Sep 28, 2023
514eb35
feat: Fixed cs spec file
josh-bagwell Sep 28, 2023
e2f6f9c
feat: Fixed export for focusRing
josh-bagwell Sep 28, 2023
7bdfc8d
feat: Fixed replaceWithTokens function
josh-bagwell Sep 28, 2023
cfb8e70
feat: Addressed focus ring on segmented control and pills
josh-bagwell Sep 28, 2023
2217576
fix: Fixed Roboto font issue
josh-bagwell Sep 29, 2023
2a73937
fix: Fixed type issue
josh-bagwell Sep 29, 2023
56fc591
feat: Fixed Pill and Segmented control
josh-bagwell Sep 29, 2023
d0316b5
fix: Adjusted colors on Pill and SegmentedControl
josh-bagwell Sep 29, 2023
46f87ea
fix: Fixed pill and segmented control
josh-bagwell Oct 2, 2023
b775c57
fix: Fixed pill
josh-bagwell Oct 3, 2023
8e96863
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Oct 3, 2023
7f809b2
fix: Fixed Pill or SegmentedControl
josh-bagwell Oct 5, 2023
ee5f16f
fix: Fixed adjustments for tests
josh-bagwell Oct 5, 2023
5898039
fix: Fixed UI tests
josh-bagwell Oct 9, 2023
b13427b
fix: Fixed buttons
josh-bagwell Oct 9, 2023
61380a8
fix: Fixed tertiaryButton
josh-bagwell Oct 9, 2023
87f8c7e
fix: Fixed Button styles setup
josh-bagwell Oct 10, 2023
f280100
fix: Fixed style structure
josh-bagwell Oct 10, 2023
16504db
feat: Added function for mapping size modifiers
josh-bagwell Oct 10, 2023
e1b7b32
feat: Fixed other components with focusRing
josh-bagwell Oct 10, 2023
4e62704
fix: Fixed deps
josh-bagwell Oct 10, 2023
c0ec032
feat: Fixed button styles
josh-bagwell Oct 12, 2023
32de1a4
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Oct 12, 2023
dff3382
fix: Fixed deps
josh-bagwell Oct 12, 2023
7b26bfa
fix: Fixed toolbar buttons
josh-bagwell Oct 12, 2023
c26c18b
fix: Fixed actionbar and updates cs function
josh-bagwell Oct 12, 2023
9c2a369
fix: Made small tweaks to buttons and started upgrade guide
josh-bagwell Oct 12, 2023
8cc948e
fix: Fixed tertiary Button
josh-bagwell Oct 12, 2023
c75909a
fix: Adjusted line height and tertiary focus ring
josh-bagwell Oct 13, 2023
78033f2
feat: Added docs
josh-bagwell Oct 17, 2023
e3c322f
Merge branch 'prerelease/major' of https://github.com/Workday/canvas-…
josh-bagwell Oct 17, 2023
7ecc3b8
fix: Pulled in Nicholas styles merge
josh-bagwell Oct 17, 2023
19fb902
fix: Fixed basebutton moving
josh-bagwell Oct 17, 2023
a7fb08d
fix: Fixed package json
josh-bagwell Oct 17, 2023
72f2b17
fix: Fixed Upgrade guide and storybook org
josh-bagwell Oct 17, 2023
7468e3c
fix: Added suggestions
josh-bagwell Oct 18, 2023
ef5662f
fix: Fixed Button iconPosition conditional
josh-bagwell Oct 18, 2023
6980d51
fix: Added suggestions from PR
josh-bagwell Oct 18, 2023
540957b
fix: Removed unnecessary selectors
josh-bagwell Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import routes from './routes';
import {CanvasProviderDecorator} from '../utils/storybook';
import theme from './theme';
import {defaultCanvasTheme} from '@workday/canvas-kit-react/common';
import "@workday/canvas-tokens-web/dist/css/base/_variables.css";
import "@workday/canvas-tokens-web/dist/css/brand/_variables.css";
import "@workday/canvas-tokens-web/dist/css/system/_variables.css";
josh-bagwell marked this conversation as resolved.
Show resolved Hide resolved

// set routes on window for testing the validity of the routes
window.__routes = routes;
Expand Down Expand Up @@ -34,7 +37,9 @@ function storySort(a, b) {
prefix('basic', 'aa'),
prefix('default', 'ab'),
prefix('testing', 'zzz'),
prefix('examples', 'zz')
prefix('examples', 'zz'),
// Make sure upgrade guides follow chronological order by replacing `v9.0` with `v09.0`
value => value.replace(/v([1-9]\-0)/, '0$1')
josh-bagwell marked this conversation as resolved.
Show resolved Hide resolved
);

const left = prefixFn(a[0]);
Expand Down
21 changes: 3 additions & 18 deletions cypress/integration/ExpandableContainer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ describe('ExpandableContainer', () => {
});

it('should have aria-expanded set to false', () => {
cy.findByRole('button')
.should(
'have.attr',
'aria-expanded',
'false'
);
cy.findByRole('button').should('have.attr', 'aria-expanded', 'false');
});

it('should not show expanded content', () => {
Expand All @@ -33,12 +28,7 @@ describe('ExpandableContainer', () => {
});

it('should set aria-expanded to true', () => {
cy.findByRole('button')
.should(
'have.attr',
'aria-expanded',
'true'
);
cy.findByRole('button').should('have.attr', 'aria-expanded', 'true');
});

it('should show expanded content', () => {
Expand All @@ -62,12 +52,7 @@ describe('ExpandableContainer', () => {
});

it('should have aria-expanded set to false', () => {
cy.findByRole('button')
.should(
'have.attr',
'aria-expanded',
'false'
);
cy.findByRole('button').should('have.attr', 'aria-expanded', 'false');
});
});
});
Expand Down
68 changes: 62 additions & 6 deletions modules/docs/mdx/10.0-UPGRADE_GUIDE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ any questions.

- [Codemod](#codemod)
- [Removals](#removals)
- [useBanner](#useBanner)
- [useBanner](#useBanner)
- [Deprecations](#deprecations)
- [InputIconContainer](#input-icon-container)
- [Table](#table)
- [Token Updates](#token-updates)
- [Space and Depth](#space-and-depth)
- [Component Updates](#component-updates)
- [Buttons](#buttons)
- [Glossary](#glossary)
- [Main](#main)
- [Preview](#preview)
Expand Down Expand Up @@ -61,19 +62,23 @@ promoted or replaced a component or utility.
## useBanner

We have removed the `useBanner` hook, the only function of which was to add `aria-labelledby` and
`aria-describedby` references to the text inside of the Banner. This was not required for accessibility,
and browsers can compute the name of the Banner from the text given inside.
`aria-describedby` references to the text inside of the Banner. This was not required for
accessibility, and browsers can compute the name of the Banner from the text given inside.

## Deprecations

### Input Icon Container

We've deprecated `InputIconContainer` from [Main](#main) because it doesn't handle
bidirectionality or icons at the start of an input. Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/story/components-inputs-text-input--icons) instead.
We've deprecated `InputIconContainer` from [Main](#main) because it doesn't handle bidirectionality
or icons at the start of an input. Please consider using
[`InputGroup`](https://workday.github.io/canvas-kit/?path=/story/components-inputs-text-input--icons)
instead.

### Table

We've deprecated `Table` and `TableRow` as well as all of their exported members. Please consider using [`Table in Preview`](https://workday.github.io/canvas-kit/?path=/docs/preview-table--basic) instead.
We've deprecated `Table` and `TableRow` as well as all of their exported members. Please consider
using [`Table in Preview`](https://workday.github.io/canvas-kit/?path=/docs/preview-table--basic)
instead.

## Token Updates

Expand Down Expand Up @@ -123,6 +128,57 @@ these sizes should change along with it. Since `px` are a fixed unit and do not

## Component Updates

### Buttons

We re-factored how we styled Buttons to use our `createStyles` utility function. We don't anticipate
this as a breaking change but, there may be slight changes to visual test.

**PR:** [#2285](https://github.com/Workday/canvas-kit/pull/2285)

#### Button Icon Fill

Icons will no longer be "filled" on toggle. This decision was made to not have the exisitng icon
look so different in the toggled state.

#### Button Focus Ring Update

We found that focus ring was not consistent across all Buttons. We have made some changes to create
a consistent focus ring across all Buttons and variants. These will need to be taken note of due to
some small changes visually with Buttons.

- `PrimaryButton`: `inverse` variant now has the same focus ring as default variant and as
`SecondaryButton`.

josh-bagwell marked this conversation as resolved.
Show resolved Hide resolved
Also, `colors` will no longer support the `focusRing` option.

```tsx
import {focusRing} from '@workday/canvas-kit-react/common';

// before
<PrimaryButton
colors={{
// other colors
focus: {
// other colors
focusRing: focusRing(/* options */)
}
}}
/>

// after
<PrimaryButton
colors={{
// other colors
focus: {
// other colors
}
}}
css={{
':focus-visible': focusRing(/* options */)
}}
/>;
```

## Glossary

### Main
Expand Down
43 changes: 24 additions & 19 deletions modules/preview-react/pill/lib/Pill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,23 @@ const getButtonPillColors = () => {
label: colors.blackPepper400,
border: colors.licorice200,
},
focus: {
icon: colors.licorice500,
background: colors.soap300,
border: colors.blueberry400,
label: colors.blackPepper400,
},
hover: {
icon: colors.licorice500,
background: colors.soap400,
border: colors.licorice400,
label: colors.blackPepper400,
},
active: {
icon: colors.licorice500,
background: colors.soap500,
border: colors.licorice500,
},
focus: {
icon: colors.licorice500,
background: colors.soap300,
border: colors.blueberry400,
focusRing: focusRing({
width: 0,
inset: 'inner',
innerColor: colors.blueberry400,
outerColor: colors.blueberry400,
separation: 1,
}),
label: colors.blackPepper400,
},
disabled: {
icon: colors.licorice100,
Expand Down Expand Up @@ -92,12 +88,7 @@ const getRemovablePillColors = (disabled?: boolean) => {
icon: colors.licorice200,
background: colors.soap300,
label: colors.blackPepper400,

focusRing: focusRing({
width: 0,
innerColor: 'transparent',
outerColor: 'transparent',
}),
border: colors.licorice200,
},
disabled: {},
};
Expand Down Expand Up @@ -147,8 +138,15 @@ const StyledBasePill = styled(BaseButton.as('button'))<StyledType & PillProps>(
}),
},
({variant}) => ({
'&:focus': {
'&:focus, &:focus-visible': {
josh-bagwell marked this conversation as resolved.
Show resolved Hide resolved
borderColor: variant === 'removable' ? undefined : colors.blueberry400,
...focusRing({
width: 0,
inset: 'inner',
innerColor: colors.blueberry400,
outerColor: colors.blueberry400,
separation: 1,
}),
},
}),
boxStyleFn
Expand All @@ -158,6 +156,13 @@ const StyledNonInteractivePill = styled(StyledBasePill)<StyledType>({
cursor: 'default',
overflow: 'revert', // override BaseButton overflow styles so the click target exists outside the pill for removable
position: 'relative',
'&:focus-visibile, &.focus': {
...focusRing({
width: 0,
innerColor: 'transparent',
outerColor: 'transparent',
}),
},
});

/**
Expand Down
14 changes: 9 additions & 5 deletions modules/preview-react/pill/lib/PillIconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,19 @@ const getIconColors = () => {
return {
default: {
icon: colors.licorice200,
border: 'initial',
},

hover: {
icon: colors.licorice500,
border: 'initial',
},
active: {
icon: colors.licorice500,
border: 'initial',
},
focus: {
icon: colors.licorice500,

focusRing: focusRing({
innerColor: 'transparent',
}),
border: 'transparent',
},
disabled: {
icon: colors.licorice100,
Expand All @@ -63,6 +62,11 @@ const StyledIconButton = styled(BaseButton)<StyledType & PillIconButtonProps>({
pointerEvents: 'all',
cursor: 'pointer',
},
'&.focus, &:focus-visible': {
...focusRing({
innerColor: 'transparent',
}),
},
});

export const PillIconButton = createSubcomponent('button')({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ButtonContainerProps,
ButtonColors,
ButtonSizes,
getMinWidthStyles,
} from '@workday/canvas-kit-react/button';
import {CanvasSystemIcon} from '@workday/design-assets-types';
import {useSegmentedControlModel} from './hooks/useSegmentedControlModel';
Expand Down Expand Up @@ -53,6 +52,21 @@ export interface ItemProps extends ButtonContainerProps {
tooltipProps?: Omit<TooltipProps, 'children'>;
}

const getMinWidthStyles = (children: React.ReactNode, size: ButtonSizes) => {
switch (size) {
case 'large':
return children ? '112px' : '48px';
case 'medium':
return children ? '96px' : space.xl;
case 'small':
return children ? space.xxxl : space.l;
case 'extraSmall':
return children ? 'auto' : space.m;
default:
return children ? '96px' : space.xl;
}
};

const getButtonSize = (size: ButtonContainerProps['size']) => {
switch (size) {
case 'large':
Expand All @@ -76,18 +90,28 @@ const getIconButtonColors = (toggled?: boolean): ButtonColors => {
},
hover: {
background: toggled ? colors.frenchVanilla100 : colors.soap400,
border: toggled ? colors.licorice200 : 'transparent',
icon: colors.licorice400,
label: colors.licorice400,
},
active: {
background: toggled ? colors.frenchVanilla100 : colors.soap400,
border: toggled ? colors.licorice200 : 'transparent',
icon: colors.licorice400,
label: colors.licorice400,
},
focus: {},
focus: {
background: toggled ? colors.frenchVanilla100 : colors.soap200,
border: toggled ? colors.licorice200 : 'transparent',
icon: toggled ? colors.blackPepper400 : colors.licorice400,
label: toggled ? colors.blackPepper400 : colors.licorice400,
},
disabled: {
background: colors.soap200,
opacity: '1',
icon: colors.licorice400,
border: toggled ? colors.licorice200 : 'transparent',
label: colors.blackPepper400,
},
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const ActionBarWithOverflowMenuStates = () => {
},
{
label: 'Maximum Visible Items (as 5 buttons)',
props: {maximumVisible: items.length},
props: {maximumVisible: items.length, containerWidth: 830},
},
{
label: 'Maximum Visible Items (400px width)',
Expand Down
19 changes: 8 additions & 11 deletions modules/react/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
export {PrimaryButton, PrimaryButtonProps} from './lib/PrimaryButton';
export {SecondaryButton, SecondaryButtonProps} from './lib/SecondaryButton';
export {TertiaryButton, TertiaryButtonProps} from './lib/TertiaryButton';
export {DeleteButton, DeleteButtonProps} from './lib/DeleteButton';
export {
DeprecatedButton as deprecated_Button,
DeprecatedButtonProps,
} from './lib/deprecated_Button';
export {ToolbarIconButton, ToolbarIconButtonProps} from './lib/ToolbarIconButton';
export {ToolbarDropdownButton, ToolbarDropdownButtonProps} from './lib/ToolbarDropdownButton';
export {Hyperlink, HyperlinkProps} from './lib/Hyperlink';
export {
BaseButton,
ButtonContainerProps,
BaseButtonProps,
getMinWidthStyles,
getPaddingStyles,
} from './lib/BaseButton';
export {ExternalHyperlink, ExternalHyperlinkProps} from './lib/ExternalHyperlink';
export * from './lib/types';
export * from './lib/PrimaryButton';
export * from './lib/SecondaryButton';
export * from './lib/TertiaryButton';
export * from './lib/DeleteButton';
export * from './lib/BaseButton';
export * from './lib/ToolbarDropdownButton';
export * from './lib/ToolbarIconButton';
export * from './lib/types';
Loading
Loading