Skip to content

Commit 54fd05a

Browse files
committed
add chromatic stories for Toast
1 parent a781902 commit 54fd05a

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright 2024 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
import type {Meta, StoryObj} from '@storybook/react';
14+
import React from 'react';
15+
import {SpectrumToast, SpectrumToastValue} from '../src/Toast';
16+
import {UNSTABLE_ToastStateContext} from 'react-aria-components';
17+
import {useToastState} from 'react-stately';
18+
19+
function FakeToast(props: SpectrumToastValue) {
20+
return (
21+
<UNSTABLE_ToastStateContext.Provider value={useToastState()}>
22+
<SpectrumToast
23+
toast={{
24+
key: 'toast',
25+
content: props
26+
}} />
27+
</UNSTABLE_ToastStateContext.Provider>
28+
);
29+
}
30+
31+
const meta: Meta<typeof FakeToast> = {
32+
component: FakeToast,
33+
parameters: {
34+
chromaticProvider: {colorSchemes: ['light'], backgrounds: ['base'], locales: ['en-US'], disableAnimations: true}
35+
},
36+
tags: ['autodocs'],
37+
title: 'S2 Chromatic/Toast'
38+
};
39+
40+
export default meta;
41+
type Story = StoryObj<typeof FakeToast>;
42+
43+
export const Neutral: Story = {
44+
args: {
45+
variant: 'neutral',
46+
children: 'Toast available'
47+
}
48+
};
49+
50+
export const Info: Story = {
51+
args: {
52+
variant: 'info',
53+
children: 'Toasting…'
54+
}
55+
};
56+
57+
export const Positive: Story = {
58+
args: {
59+
variant: 'positive',
60+
children: 'Toast is done!'
61+
}
62+
};
63+
64+
export const Negative: Story = {
65+
args: {
66+
variant: 'negative',
67+
children: 'Toast is burned!'
68+
}
69+
};
70+
71+
export const WithAction: Story = {
72+
args: {
73+
variant: 'positive',
74+
children: 'Toast is done!',
75+
actionLabel: 'Undo'
76+
}
77+
};
78+
79+
export const LongContent: Story = {
80+
args: {
81+
variant: 'info',
82+
children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
83+
}
84+
};
85+
86+
export const LongContentWithAction: Story = {
87+
args: {
88+
variant: 'positive',
89+
children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
90+
actionLabel: 'Undo'
91+
}
92+
};
93+
94+
export const LongWord: Story = {
95+
args: {
96+
variant: 'info',
97+
children: 'LoremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquaUtenimaminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipeacommodoconsequat.'
98+
}
99+
};

0 commit comments

Comments
 (0)