-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve S2 chromatic story coverage #6999
base: combine_chromatic
Are you sure you want to change the base?
Changes from all commits
005c40a
431a5bf
f30143a
9efd241
d531726
7e1acb5
ad7465f
f3229e3
9363c65
d3d97b0
c5c3c4f
3ef9e2b
da1e308
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import {ActionButton, Text} from '../src'; | ||
import {Fonts, UnsafeClassName} from '../stories/ActionButton.stories'; | ||
import {generatePowerset} from '@react-spectrum/story-utils'; | ||
import type {Meta} from '@storybook/react'; | ||
import NewIcon from '../s2wf-icons/S2_Icon_New_20_N.svg'; | ||
import {shortName} from './utils'; | ||
import {StaticColorProvider} from '../stories/utils'; | ||
import {style} from '../style/spectrum-theme' with { type: 'macro' }; | ||
|
||
const meta: Meta<typeof ActionButton> = { | ||
component: ActionButton, | ||
parameters: { | ||
chromaticProvider: {disableAnimations: true} | ||
}, | ||
title: 'S2 Chromatic/ActionButton' | ||
}; | ||
|
||
export default meta; | ||
|
||
let states = [ | ||
{isQuiet: true}, | ||
{isReadOnly: true}, | ||
{isDisabled: true}, | ||
{size: ['XS', 'S', 'M', 'L', 'XL']}, | ||
{staticColor: ['black', 'white']} | ||
]; | ||
|
||
let combinations = generatePowerset(states); | ||
|
||
const Template = (args) => { | ||
let {children, ...otherArgs} = args; | ||
return ( | ||
<div className={style({display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 250px))', gridAutoFlow: 'row', justifyItems: 'start', gap: 24, width: '[100vw]'})}> | ||
{combinations.map(c => { | ||
let key = Object.keys(c).map(k => shortName(k, c[k])).join(' '); | ||
if (!key) { | ||
key = 'default'; | ||
} | ||
|
||
let button = <ActionButton key={key} {...otherArgs} {...c}>{children ? children : key}</ActionButton>; | ||
if (c.staticColor != null) { | ||
return ( | ||
<StaticColorProvider staticColor={c.staticColor}> | ||
{button} | ||
</StaticColorProvider> | ||
); | ||
} | ||
|
||
return button; | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export const Default = { | ||
render: Template | ||
}; | ||
|
||
export const WithIcon = { | ||
render: Template, | ||
args: { | ||
children: <><NewIcon /><Text>Press me</Text></> | ||
} | ||
}; | ||
|
||
export const IconOnly = { | ||
render: Template, | ||
args: { | ||
children: <NewIcon /> | ||
} | ||
}; | ||
|
||
export {Fonts, UnsafeClassName}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import {ActionMenu} from '../src'; | ||
import {DynamicExample, Example} from '../stories/ActionMenu.stories'; | ||
import type {Meta, StoryObj} from '@storybook/react'; | ||
import {userEvent, within} from '@storybook/testing-library'; | ||
|
||
const meta: Meta<typeof ActionMenu> = { | ||
component: ActionMenu, | ||
parameters: { | ||
chromaticProvider: {colorSchemes: ['light'], backgrounds: ['base'], locales: ['en-US'], disableAnimations: true} | ||
}, | ||
title: 'S2 Chromatic/ActionMenu' | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof ActionMenu<any>>; | ||
|
||
export const Static: Story = {...Example}; | ||
|
||
Static.play = async ({canvasElement}) => { | ||
await userEvent.tab(); | ||
await userEvent.keyboard('[Enter]'); | ||
let body = canvasElement.ownerDocument.body; | ||
await within(body).findByRole('menu'); | ||
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can use your menu utils? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why tab and enter? why not use a single command which will do both? |
||
}; | ||
|
||
export const Dynamic = {...DynamicExample}; | ||
|
||
Dynamic.play = async ({canvasElement}) => { | ||
await userEvent.tab(); | ||
await userEvent.keyboard('[Enter]'); | ||
let body = canvasElement.ownerDocument.body; | ||
await within(body).findByRole('menu'); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import {ActionMenu} from '../src'; | ||
|
||
import type {Meta} from '@storybook/react'; | ||
|
||
const meta: Meta<typeof ActionMenu> = { | ||
component: ActionMenu, | ||
parameters: { | ||
chromaticProvider: {colorSchemes: ['dark'], backgrounds: ['base'], locales: ['ar-AE'], disableAnimations: true} | ||
}, | ||
title: 'S2 Chromatic/ActionMenuRTL' | ||
}; | ||
|
||
export default meta; | ||
export {Static, Dynamic} from './ActionMenu.stories'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import {AlertDialog} from '../src'; | ||
import {Example as Base} from '../stories/AlertDialog.stories'; | ||
import type {Meta, StoryObj} from '@storybook/react'; | ||
import {userEvent, within} from '@storybook/testing-library'; | ||
|
||
const meta: Meta<typeof AlertDialog> = { | ||
component: AlertDialog, | ||
parameters: { | ||
layout: 'centered', | ||
chromaticProvider: {colorSchemes: ['light'], backgrounds: ['base'], locales: ['en-US'], disableAnimations: true} | ||
}, | ||
title: 'S2 Chromatic/AlertDialog' | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Example = {...Base} as StoryObj; | ||
|
||
Example.play = async ({canvasElement}) => { | ||
await userEvent.tab(); | ||
await userEvent.keyboard('[Enter]'); | ||
let body = canvasElement.ownerDocument.body; | ||
await within(body).findByRole('alertdialog'); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import {AlertDialog} from '../src'; | ||
|
||
import type {Meta} from '@storybook/react'; | ||
|
||
const meta: Meta<typeof AlertDialog> = { | ||
component: AlertDialog, | ||
parameters: { | ||
chromaticProvider: {colorSchemes: ['dark'], backgrounds: ['base'], locales: ['ar-AE'], disableAnimations: true} | ||
}, | ||
title: 'S2 Chromatic/AlertDialogRTL' | ||
}; | ||
|
||
export default meta; | ||
export {Example} from './AlertDialog.stories'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import {Avatar} from '../src'; | ||
import type {Meta} from '@storybook/react'; | ||
import {style} from '../style/spectrum-theme' with { type: 'macro' }; | ||
|
||
const meta: Meta<typeof Avatar> = { | ||
component: Avatar, | ||
parameters: { | ||
chromaticProvider: {backgrounds: ['base', 'layer-1', 'layer-2'], disableAnimations: true} | ||
}, | ||
title: 'S2 Chromatic/Avatar' | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default = { | ||
render: () => <Avatar alt="design provided" src="https://i.imgur.com/xIe7Wlb.png" /> | ||
}; | ||
|
||
export const OverBackground = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need one which uses the spectrum layer background? or maybe taken care of by AvatarGroup stories when we get those |
||
render: () => ( | ||
<div className={style({backgroundColor: 'indigo-800', padding: 40})}> | ||
<Avatar alt="design provided" src="https://i.imgur.com/xIe7Wlb.png" /> | ||
</div> | ||
) | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright 2024 Adobe. All rights reserved. | ||
* This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under | ||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
* OF ANY KIND, either express or implied. See the License for the specific language | ||
* governing permissions and limitations under the License. | ||
*/ | ||
|
||
import {Badge} from '../src'; | ||
import {Example} from '../stories/Badge.stories'; | ||
import {generatePowerset} from '@react-spectrum/story-utils'; | ||
import type {Meta} from '@storybook/react'; | ||
import {shortName} from './utils'; | ||
import {style} from '../style/spectrum-theme' with { type: 'macro' }; | ||
|
||
const meta: Meta<typeof Badge> = { | ||
component: Badge, | ||
parameters: { | ||
chromaticProvider: {disableAnimations: true} | ||
}, | ||
title: 'S2 Chromatic/Badge' | ||
}; | ||
|
||
export default meta; | ||
|
||
let states = [ | ||
{size: ['S', 'M', 'L', 'XL']}, | ||
{fillStyle: ['bold', 'subtle', 'outline']}, | ||
{variant: ['accent', 'informative', 'neutral', 'positive', 'notice', 'negative', 'gray', 'red', 'orange', 'yellow', 'charteuse', 'celery', 'green', 'seafoam', 'cyan', 'blue', 'indigo', 'purple', 'fuchsia', 'magenta', 'pink', 'turquoise', 'brown', 'cinnamon', 'silver']} | ||
]; | ||
|
||
let combinations = generatePowerset(states); | ||
let chunkSize = Math.ceil(combinations.length / 3); | ||
|
||
const Template = ({combos, ...args}) => { | ||
return ( | ||
<div className={style({display: 'grid', gridTemplateColumns: 'repeat(4, minmax(0, 250px))', gridAutoFlow: 'row', alignItems: 'center', justifyItems: 'start', gap: 24, width: '[100vw]'})}> | ||
{combos.map(c => { | ||
let key = Object.keys(c).map(k => shortName(k, c[k])).join(' '); | ||
if (!key) { | ||
key = 'default'; | ||
} | ||
|
||
return <Badge key={key} {...args} {...c}>{key}</Badge>; | ||
})} | ||
</div> | ||
); | ||
}; | ||
|
||
export const Default = { | ||
render: Template, | ||
name: 'all visual option combos 1 of 3', | ||
args: {combos: combinations.slice(0, chunkSize)} | ||
}; | ||
|
||
export const ComboPt2 = { | ||
render: Template, | ||
args: {combos: combinations.slice(chunkSize, chunkSize * 2)}, | ||
name: 'all visual option combos 2 of 3' | ||
}; | ||
|
||
export const ComboPt3 = { | ||
render: Template, | ||
args: {combos: combinations.slice(chunkSize * 2, chunkSize * 3)}, | ||
name: 'all visual option combos 3 of 3' | ||
}; | ||
|
||
export {Example}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Readonly is allowed on ActionButton?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, thanks copy pasta