diff --git a/packages/@react-spectrum/s2/chromatic/Toast.stories.tsx b/packages/@react-spectrum/s2/chromatic/Toast.stories.tsx new file mode 100644 index 00000000000..5d89bbc6189 --- /dev/null +++ b/packages/@react-spectrum/s2/chromatic/Toast.stories.tsx @@ -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 ( + + + + ); +} + +const meta: Meta = { + 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; + +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.' + } +}; diff --git a/packages/@react-spectrum/s2/src/Toast.tsx b/packages/@react-spectrum/s2/src/Toast.tsx index 0391cf2bc23..92ae9dae582 100644 --- a/packages/@react-spectrum/s2/src/Toast.tsx +++ b/packages/@react-spectrum/s2/src/Toast.tsx @@ -296,7 +296,10 @@ const toastContent = style({ alignItems: 'baseline', gridArea: 'content', cursor: 'default', - width: 'fit' + width: 'fit', + overflowWrap: 'break-word', + wordBreak: 'break-word', + minWidth: 0 }); const controls = style({ diff --git a/packages/@react-spectrum/s2/stories/Toast.stories.tsx b/packages/@react-spectrum/s2/stories/Toast.stories.tsx index 15630064fb8..1aeff128f1e 100644 --- a/packages/@react-spectrum/s2/stories/Toast.stories.tsx +++ b/packages/@react-spectrum/s2/stories/Toast.stories.tsx @@ -79,6 +79,11 @@ export const Example: Story = { variant="accent"> Show Long Toast + ) diff --git a/packages/@react-spectrum/s2/style/spectrum-theme.ts b/packages/@react-spectrum/s2/style/spectrum-theme.ts index b14e5f08eff..c217db1b0cd 100644 --- a/packages/@react-spectrum/s2/style/spectrum-theme.ts +++ b/packages/@react-spectrum/s2/style/spectrum-theme.ts @@ -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,