Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
99 changes: 99 additions & 0 deletions packages/@react-spectrum/s2/chromatic/Toast.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* 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 type {Meta, StoryObj} from '@storybook/react';
import React from 'react';
import {SpectrumToast, SpectrumToastValue} from '../src/Toast';
import {UNSTABLE_ToastStateContext} from 'react-aria-components';
import {useToastState} from 'react-stately';

function FakeToast(props: SpectrumToastValue) {
return (
<UNSTABLE_ToastStateContext.Provider value={useToastState()}>
<SpectrumToast
toast={{
key: 'toast',
content: props
}} />
</UNSTABLE_ToastStateContext.Provider>
);
}

const meta: Meta<typeof FakeToast> = {
component: FakeToast,
parameters: {
chromaticProvider: {colorSchemes: ['light'], backgrounds: ['base'], locales: ['en-US'], disableAnimations: true}
},
tags: ['autodocs'],
title: 'S2 Chromatic/Toast'
};

export default meta;
type Story = StoryObj<typeof FakeToast>;

export const Neutral: Story = {
args: {
variant: 'neutral',
children: 'Toast available'
}
};

export const Info: Story = {
args: {
variant: 'info',
children: 'Toasting…'
}
};

export const Positive: Story = {
args: {
variant: 'positive',
children: 'Toast is done!'
}
};

export const Negative: Story = {
args: {
variant: 'negative',
children: 'Toast is burned!'
}
};

export const WithAction: Story = {
args: {
variant: 'positive',
children: 'Toast is done!',
actionLabel: 'Undo'
}
};

export const LongContent: Story = {
args: {
variant: 'info',
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.'
}
};

export const LongContentWithAction: Story = {
args: {
variant: 'positive',
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.',
actionLabel: 'Undo'
}
};

export const LongWord: Story = {
args: {
variant: 'info',
children: 'LoremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquaUtenimaminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipeacommodoconsequat.'
}
};
5 changes: 4 additions & 1 deletion packages/@react-spectrum/s2/src/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ const toastContent = style({
alignItems: 'baseline',
gridArea: 'content',
cursor: 'default',
width: 'fit'
width: 'fit',
overflowWrap: 'break-word',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wordBreak: 'break-word',
minWidth: 0
});

const controls = style({
Expand Down
5 changes: 5 additions & 0 deletions packages/@react-spectrum/s2/stories/Toast.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export const Example: Story = {
variant="accent">
Show Long Toast
</Button>
<Button
onPress={() => UNSTABLE_ToastQueue.info('LoremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididuntutlaboreetdoloremagnaaliquaUtenimaminimveniamquisnostrudexercitationullamcolaborisnisiutaliquipeacommodoconsequat.', {...args, onClose: action('onClose')})}
variant="accent">
Show Long Word Toast
</Button>
</ButtonGroup>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/s2/style/spectrum-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ export const style = createTheme({
hyphens: ['none', 'manual', 'auto'] as const,
whiteSpace: ['normal', 'nowrap', 'pre', 'pre-line', 'pre-wrap', 'break-spaces'] as const,
textWrap: ['wrap', 'nowrap', 'balance', 'pretty'] as const,
wordBreak: ['normal', 'break-all', 'keep-all'] as const,
wordBreak: ['normal', 'break-all', 'keep-all', 'break-word'] as const,
overflowWrap: ['normal', 'anywhere', 'break-word'] as const,
boxDecorationBreak: ['slice', 'clone'] as const,

Expand Down