The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Keep notification countdowns in Toast (#26912)
Raphaël Bosi5d63109c2ded
diff --git a/packages/twenty-companion/src/renderer/components/Notification.module.scss b/packages/twenty-companion/src/renderer/components/Notification.module.scssindex cc0cd741da5..e55e5b2d1b5 100644--- a/packages/twenty-companion/src/renderer/components/Notification.module.scss+++ b/packages/twenty-companion/src/renderer/components/Notification.module.scss@@ -1,35 +1,14 @@.container {- backdrop-filter: var(--t-blur-medium);- background: var(--t-background-transparent-primary);+ --tw-button-size: var(--t-spacing-8);+border-radius: var(--t-border-radius-md);- box-shadow: var(--t-box-shadow-strong);- box-sizing: border-box;- padding: var(--t-spacing-2);- position: relative;- width: 296px;- max-width: 100%;+ font-family: var(--t-font-family);+ inline-size: 296px;+ margin-block-start: 0;+ max-inline-size: 100%;overflow: hidden;}-.content {- position: relative;- display: flex;- align-items: center;- gap: var(--t-spacing-2);- > svg {- flex-shrink: 0;- }-}+.message {- flex: 1;- color: var(--t-font-color-secondary);- font-family: var(--t-font-family);- font-size: var(--t-font-size-sm);-}-.progress {- position: absolute;- inset: 0;- pointer-events: none;- > [role='progressbar'] {- height: 100%;- }+ font-weight: var(--t-font-weight-regular);}diff --git a/packages/twenty-companion/src/renderer/components/Notification.module.scss.d.ts b/packages/twenty-companion/src/renderer/components/Notification.module.scss.d.tsindex ebc34e2d50a..4fb45ce35db 100644--- a/packages/twenty-companion/src/renderer/components/Notification.module.scss.d.ts+++ b/packages/twenty-companion/src/renderer/components/Notification.module.scss.d.ts@@ -1,7 +1,5 @@declare const styles: {readonly container: string;- readonly content: string;readonly message: string;- readonly progress: string;};export default styles;diff --git a/packages/twenty-companion/src/renderer/components/Notification.tsx b/packages/twenty-companion/src/renderer/components/Notification.tsxindex fe12d51890f..fadbebb8595 100644--- a/packages/twenty-companion/src/renderer/components/Notification.tsx+++ b/packages/twenty-companion/src/renderer/components/Notification.tsx@@ -1,8 +1,4 @@-import { useState } from 'react';-import { IconInfoCircle, IconX } from '@ui/icon';-import { IconButton } from '@ui/components/input/IconButton/IconButton';-import { ProgressBar } from '@ui/primitives/feedback/ProgressBar/ProgressBar';-import { useTheme } from '@ui/theme';+import { Toast } from '@ui/components/feedback/Toast/Toast';import styles from './Notification.module.scss';type NotificationProps = {@@ -16,43 +12,15 @@ export const Notification = ({closeLabel,onClose,}: NotificationProps) => {- const theme = useTheme();- const [paused, setPaused] = useState(false);return (- <div+ <ToastclassName={styles.container}- role="status"- aria-live="polite"- onMouseEnter={() => setPaused(true)}- onMouseLeave={() => setPaused(false)}- onFocus={() => setPaused(true)}- onBlur={() => setPaused(false)}+ variant="info"+ duration={6000}+ closeLabel={closeLabel}+ onClose={onClose}>- <div className={styles.progress}>- <ProgressBar- value={100}- barColor={theme.snackBar.info.backgroundColor}- countdownDurationInMs={6000}- isCountdownPaused={paused}- onCountdownComplete={onClose}- />- </div>- <div className={styles.content}>- <IconInfoCircle- size={theme.icon.size.md}- color={theme.snackBar.info.color}- aria-hidden- />- <span className={styles.message}>{message}</span>- <IconButton- aria-label={closeLabel}- onClick={onClose}- variant="ghost"- size="md"- >- <IconX />- </IconButton>- </div>- </div>+ <span className={styles.message}>{message}</span>+ </Toast>);};diff --git a/packages/twenty-docs/snippets/ui/generated/feedback/progress-bar.mdx b/packages/twenty-docs/snippets/ui/generated/feedback/progress-bar.mdxindex b69250a2a17..bfbf86bb004 100644--- a/packages/twenty-docs/snippets/ui/generated/feedback/progress-bar.mdx+++ b/packages/twenty-docs/snippets/ui/generated/feedback/progress-bar.mdx@@ -27,18 +27,6 @@CSS class applied to the progress root.</ParamField>-<ParamField body="countdownDurationInMs" type="number">- Starts a visual animation from full to empty over this duration in milliseconds. Does not update `value`.-</ParamField>--<ParamField body="isCountdownPaused" type="boolean" default="false">- Pauses the countdown animation without resetting its position.-</ParamField>--<ParamField body="onCountdownComplete" type="(() => void)">- Called when the countdown animation ends.-</ParamField>-<ParamField body="onGrowInComplete" type="(() => void)">Called when the grow-in animation ends.</ParamField>@@ -48,7 +36,7 @@</ParamField><ParamField body="value" type="number" required>- Current progress from 0 to 100. Also supplies the accessible value during a countdown.+ Current progress from 0 to 100.</ParamField><ParamField body="withBorderRadius" type="boolean" default="false">diff --git a/packages/twenty-docs/snippets/ui/generated/feedback/toast.mdx b/packages/twenty-docs/snippets/ui/generated/feedback/toast.mdxindex 386d7c1b6b2..4eecc706741 100644--- a/packages/twenty-docs/snippets/ui/generated/feedback/toast.mdx+++ b/packages/twenty-docs/snippets/ui/generated/feedback/toast.mdx@@ -29,7 +29,7 @@<ParamField body="duration" type="number" default="6000">Milliseconds before `onClose` is called. The countdown pauses while the- pointer is over the toast.+ pointer is over the toast or keyboard focus is inside it.</ParamField><ParamField body="icon" type="ReactNode">diff --git a/packages/twenty-docs/ui/components/toast.mdx b/packages/twenty-docs/ui/components/toast.mdxindex 2c7e10539a0..20bc26d9fc0 100644--- a/packages/twenty-docs/ui/components/toast.mdx+++ b/packages/twenty-docs/ui/components/toast.mdx@@ -83,7 +83,7 @@ export const SaveNotification = () => {};```-`onClose` is called by the close button and when the countdown completes. Remove the toast in that callback. The countdown defaults to 6,000 milliseconds and pauses while the pointer is over the toast.+`onClose` is called by the close button and when the countdown completes. Remove the toast in that callback. The countdown defaults to 6,000 milliseconds and pauses while the pointer is over the toast or a control inside it has keyboard focus. It resumes when both leave the toast.## Progress and cancellationdiff --git a/packages/twenty-docs/ui/primitives/feedback/progress-bar.mdx b/packages/twenty-docs/ui/primitives/feedback/progress-bar.mdxindex e4da2829bc9..8cfd99a498f 100644--- a/packages/twenty-docs/ui/primitives/feedback/progress-bar.mdx+++ b/packages/twenty-docs/ui/primitives/feedback/progress-bar.mdx@@ -1,6 +1,6 @@---title: ProgressBar-description: Show measured progress or a visual countdown with a horizontal bar.+description: Show measured progress with a horizontal bar.---import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';@@ -38,47 +38,7 @@ export const ImportProgress = ({ percentage }: ImportProgressProps) => (`value` is required and controlled by the application. There is no `defaultValue` mode. The component does not start a request or advance numeric progress by itself. Use [Loader](/ui/primitives/feedback/loader) when progress is unknown.-## Countdown--```tsx-import { useState } from 'react';-import { ProgressBar } from 'twenty-ui/primitives/feedback';-import { Button } from 'twenty-ui/primitives/input';-import { Text } from 'twenty-ui/primitives/typography';--export const PreviewCountdown = () => {- const [isPaused, setIsPaused] = useState(false);- const [isComplete, setIsComplete] = useState(false);-- return (- <>- <Text role="status">- {isComplete ? 'Preview ended' : 'Preview available'}- </Text>- {!isComplete && (- <>- <div aria-hidden="true">- <ProgressBar- value={100}- ariaLabel="Preview countdown"- countdownDurationInMs={10000}- isCountdownPaused={isPaused}- onCountdownComplete={() => setIsComplete(true)}- />- </div>- <Button onClick={() => setIsPaused((paused) => !paused)}>- {isPaused ? 'Resume countdown' : 'Pause countdown'}- </Button>- </>- )}- </>- );-};-```--`countdownDurationInMs` animates the bar from full to empty. Pausing preserves the current animation position. Completion calls `onCountdownComplete`; mount a fresh instance to restart the animation.--The animation does not change `value` or its accessible numeric value. This example hides the decorative bar from assistive technology and announces completion separately. If remaining time matters, track and display it in application state. Use application timing for deadlines, since the callback follows a visual animation.+Use [Toast](/ui/components/toast) for notifications with a dismiss countdown and hover pause.## Appearancediff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsxindex 74ffd2e5311..47d340fa1a7 100644--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx@@ -9,6 +9,7 @@ import { buttonControlsTest } from '@/__stories__/twenty-ui-gallery/utils/buttonimport { responsiveHooksTest } from '@/__stories__/twenty-ui-gallery/utils/responsiveHooksTest';import { RESPONSIVE_HOOKS_WIDGET_SIZING } from '@/__stories__/twenty-ui-gallery/constants/RESPONSIVE_HOOKS_WIDGET_SIZING';import { dialogTest } from '@/__stories__/twenty-ui-gallery/utils/dialogTest';+import { toastCountdownTest } from '@/__stories__/twenty-ui-gallery/utils/toastCountdownTest';import { dropdownSandboxFailureTest } from '@/__stories__/twenty-ui-gallery/utils/dropdownSandboxFailureTest';import { selectPreactTest } from '@/__stories__/twenty-ui-gallery/utils/selectPreactTest';import { type Meta } from '@storybook/react-vite';@@ -337,6 +338,18 @@ export const ToastPreact: Story = createGalleryStory({play: toastTest,});+export const ToastCountdownReact: Story = createGalleryStory({+ frontComponentBundleName: 'twenty-ui-toast-countdown',+ runtime: 'react',+ play: toastCountdownTest,+});++export const ToastCountdownPreact: Story = createGalleryStory({+ frontComponentBundleName: 'twenty-ui-toast-countdown',+ runtime: 'preact',+ play: toastCountdownTest,+});+export const AlertDialogReact: Story = createGalleryStory({frontComponentBundleName: 'twenty-ui-alert-dialog',runtime: 'react',diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-toast-countdown.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-toast-countdown.front-component.tsxnew file mode 100644index 00000000000..ee79d564d1b--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-toast-countdown.front-component.tsx@@ -0,0 +1,40 @@+import { useState } from 'react';+import { defineFrontComponent } from 'twenty-sdk/define';+import { Toast } from 'twenty-ui/components';+import { Button } from 'twenty-ui/primitives/input';+import { Text } from 'twenty-ui/primitives/typography';++import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';++const ToastCountdownExample = () => {+ const [isVisible, setIsVisible] = useState(false);+ const [closeCount, setCloseCount] = useState(0);++ return (+ <TwentyUiGalleryCard title="Toast countdown">+ <Button onClick={() => setIsVisible(true)}>+ Show timed notification+ </Button>+ {isVisible && (+ <Toast+ variant="success"+ duration={1200}+ onClose={() => {+ setCloseCount((count) => count + 1);+ setIsVisible(false);+ }}+ >+ Changes saved+ </Toast>+ )}+ <Text>Closed notifications: {closeCount}</Text>+ </TwentyUiGalleryCard>+ );+};++export default defineFrontComponent({+ universalIdentifier: 'deedd53b-4e60-4a2c-abba-c80dd9c66ced',+ name: 'twenty-ui-toast-countdown',+ description: 'Toast countdown, hover pause and completion in the sandbox',+ component: ToastCountdownExample,+});diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/toastCountdownTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/toastCountdownTest.tsnew file mode 100644index 00000000000..68c1c1ba003--- /dev/null+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/toastCountdownTest.ts@@ -0,0 +1,33 @@+import { expect, userEvent, waitFor, within } from 'storybook/test';++import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';+import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';++export const toastCountdownTest: TwentyUiGalleryPlayFunction = async ({+ canvasElement,+}) => {+ const canvas = within(canvasElement);+ await expectFrontComponentMounted(canvas);+ await userEvent.click(+ canvas.getByRole('button', { name: 'Show timed notification' }),+ );+ const toast = await canvas.findByRole('status');++ await userEvent.hover(toast);+ await new Promise((resolve) => setTimeout(resolve, 1500));+ expect(toast).toBeVisible();+ expect(canvas.getByText('Closed notifications: 0')).toBeVisible();+ await userEvent.tab();+ expect(canvas.getByRole('button', { name: 'Close' })).toHaveFocus();+ await userEvent.unhover(toast);+ await new Promise((resolve) => setTimeout(resolve, 1500));+ expect(toast).toBeVisible();+ expect(canvas.getByText('Closed notifications: 0')).toBeVisible();+ await userEvent.tab({ shift: true });+ await waitFor(() => expect(toast).not.toBeInTheDocument(), {+ timeout: 3000,+ });+ expect(canvas.getByText('Closed notifications: 1')).toBeVisible();+ expect(errorHandler).not.toHaveBeenCalled();+};diff --git a/packages/twenty-ui/CHANGELOG.md b/packages/twenty-ui/CHANGELOG.mdindex 70c8ca1ad1d..866b85588ee 100644--- a/packages/twenty-ui/CHANGELOG.md+++ b/packages/twenty-ui/CHANGELOG.md@@ -4,6 +4,7 @@### Breaking Changes+- `ProgressBar` no longer accepts `countdownDurationInMs`, `isCountdownPaused`, or `onCountdownComplete`. Notification countdowns belong to `Toast`. Its duration, hover pause, manual progress, and close behavior are preserved, and keyboard focus now also pauses the countdown. The desktop companion uses the shared Toast.- Removed `ClickToActionLink`. Use `Button variant="link"` from `twenty-ui/primitives/input`: pass `onClick` for actions or `href` for navigation. The link appearance preserves compact text styling while actions gain native button keyboard behavior and prop forwarding.- Removed `soon` and `soonLabel` from `Button`, `MainButton`, and `LightButton`. Compose a disabled button with `Pill` from `twenty-ui/primitives/data-display` and supply the upcoming-feature label from the application.- Removed `CircularProgressBar`. Use `Loader` from `twenty-ui/primitives/feedback` for indeterminate loading. The separately versioned Granola app will migrate when its `twenty-ui` dependency is upgraded.diff --git a/packages/twenty-ui/docs/progressBarPropDescriptions.ts b/packages/twenty-ui/docs/progressBarPropDescriptions.tsindex 2b24a31c121..97ad1fcaeb5 100644--- a/packages/twenty-ui/docs/progressBarPropDescriptions.ts+++ b/packages/twenty-ui/docs/progressBarPropDescriptions.ts@@ -3,8 +3,7 @@ import { type ComponentProps } from 'react';import { type ProgressBar } from '../src/primitives/feedback/ProgressBar/ProgressBar';export const PROGRESS_BAR_PROP_DESCRIPTIONS = {- value:- 'Current progress from 0 to 100. Also supplies the accessible value during a countdown.',+ value: 'Current progress from 0 to 100.',size: 'Bar height: `sm` (6px) or `md` (8px).',className: 'CSS class applied to the progress root.',barColor: 'CSS color of the filled bar. Defaults to the primary text color.',@@ -17,10 +16,5 @@ export const PROGRESS_BAR_PROP_DESCRIPTIONS = {'Animates value changes with a spring that slightly overshoots the target.',withMinimumFillWidth: 'Keeps a small visible fill for any value above zero.',ariaLabel: 'Accessible name describing the operation being measured.',- countdownDurationInMs:- 'Starts a visual animation from full to empty over this duration in milliseconds. Does not update `value`.',- isCountdownPaused:- 'Pauses the countdown animation without resetting its position.',- onCountdownComplete: 'Called when the countdown animation ends.',onGrowInComplete: 'Called when the grow-in animation ends.',} satisfies Partial<Record<keyof ComponentProps<typeof ProgressBar>, string>>;diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 109eb769478..ef3907b4665 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -172,27 +172,6 @@"defaultValue": null,"description": "CSS class applied to the progress root."},- {- "name": "countdownDurationInMs",- "type": "number",- "required": false,- "defaultValue": null,- "description": "Starts a visual animation from full to empty over this duration in milliseconds. Does not update `value`."- },- {- "name": "isCountdownPaused",- "type": "boolean",- "required": false,- "defaultValue": "false",- "description": "Pauses the countdown animation without resetting its position."- },- {- "name": "onCountdownComplete",- "type": "(() => void)",- "required": false,- "defaultValue": null,- "description": "Called when the countdown animation ends."- },{"name": "onGrowInComplete","type": "(() => void)",@@ -212,7 +191,7 @@"type": "number","required": true,"defaultValue": null,- "description": "Current progress from 0 to 100. Also supplies the accessible value during a countdown."+ "description": "Current progress from 0 to 100."},{"name": "withBorderRadius",@@ -6117,7 +6096,7 @@"type": "number","required": false,"defaultValue": "6000",- "description": "Milliseconds before `onClose` is called. The countdown pauses while the\npointer is over the toast."+ "description": "Milliseconds before `onClose` is called. The countdown pauses while the\npointer is over the toast or keyboard focus is inside it."},{"name": "icon",diff --git a/packages/twenty-ui/src/components/feedback/Toast/Toast.module.scss b/packages/twenty-ui/src/components/feedback/Toast/Toast.module.scssindex 9e5edc37bd8..ae2175e04ab 100644--- a/packages/twenty-ui/src/components/feedback/Toast/Toast.module.scss+++ b/packages/twenty-ui/src/components/feedback/Toast/Toast.module.scss@@ -1,6 +1,6 @@.root {backdrop-filter: var(--t-blur-medium);- background-color: var(--t-background-transparent-primary);+ background-color: var(--t-background-primary);border-radius: var(--t-border-radius-md);box-shadow: var(--t-box-shadow-strong);box-sizing: border-box;@@ -34,6 +34,7 @@font-weight: var(--t-font-weight-medium);gap: var(--t-spacing-2);margin-block-end: var(--t-spacing-1);+ position: relative;}.message {diff --git a/packages/twenty-ui/src/components/feedback/Toast/Toast.tsx b/packages/twenty-ui/src/components/feedback/Toast/Toast.tsxindex 0d4c37b3e4e..9d1e981d1fe 100644--- a/packages/twenty-ui/src/components/feedback/Toast/Toast.tsx+++ b/packages/twenty-ui/src/components/feedback/Toast/Toast.tsx@@ -1,6 +1,6 @@import { useRender } from '@base-ui/react/use-render';import { clsx } from 'clsx';-import { type MouseEvent, useState } from 'react';+import { type FocusEvent, type MouseEvent, useState } from 'react';import {IconAlertTriangle,@@ -8,13 +8,13 @@ import {IconSquareRoundedCheck,IconX,} from '@ui/icon';-import { ProgressBar } from '@ui/primitives/feedback/ProgressBar/ProgressBar';import { Button } from '@ui/primitives/input/Button/Button';import { HorizontalSeparator } from '@ui/primitives/layout/HorizontalSeparator/HorizontalSeparator';import { useTheme } from '@ui/theme';import { isDefined } from '@ui/utilities/utils/isDefined';import styles from './Toast.module.scss';+import { ToastProgress } from './internal/components/ToastProgress';import { type ToastProps } from './types/ToastProps';import { type ToastVariant } from './types/ToastVariant';@@ -43,12 +43,15 @@ export const Toast = ({className,onMouseEnter,onMouseLeave,+ onFocus,+ onBlur,render,ref,...props}: ToastProps) => {const theme = useTheme();- const [isPaused, setIsPaused] = useState(false);+ const [isHovered, setIsHovered] = useState(false);+ const [isFocused, setIsFocused] = useState(false);const Icon = TOAST_ICONS[variant];return useRender({@@ -60,22 +63,37 @@ export const Toast = ({...props,className: clsx(styles.root, className),onMouseEnter: (event: MouseEvent<HTMLDivElement>) => {- setIsPaused(true);+ setIsHovered(true);onMouseEnter?.(event);},onMouseLeave: (event: MouseEvent<HTMLDivElement>) => {- setIsPaused(false);+ setIsHovered(false);onMouseLeave?.(event);},+ onFocus: (event: FocusEvent<HTMLDivElement>) => {+ setIsFocused(true);+ onFocus?.(event);+ },+ onBlur: (event: FocusEvent<HTMLDivElement>) => {+ const isFocusInsideToast = event.currentTarget.contains(+ event.relatedTarget,+ );++ if (!isFocusInsideToast) {+ setIsFocused(false);+ }++ onBlur?.(event);+ },children: (<><div className={styles.progress} aria-hidden>- <ProgressBar+ <ToastProgressbarColor={theme.snackBar[variant].backgroundColor}- value={progress ?? 100}- countdownDurationInMs={isDefined(progress) ? undefined : duration}- isCountdownPaused={isPaused}- onCountdownComplete={onClose}+ progress={progress}+ duration={duration}+ isPaused={isHovered || isFocused}+ onClose={onClose}/></div><div className={styles.header}>diff --git a/packages/twenty-ui/src/components/feedback/Toast/__stories__/Toast.stories.tsx b/packages/twenty-ui/src/components/feedback/Toast/__stories__/Toast.stories.tsxindex e1bc3c3c6f0..836442d9d28 100644--- a/packages/twenty-ui/src/components/feedback/Toast/__stories__/Toast.stories.tsx+++ b/packages/twenty-ui/src/components/feedback/Toast/__stories__/Toast.stories.tsx@@ -193,13 +193,58 @@ export const PauseOnHover: Story = {},};+export const PauseOnFocus: Story = {+ ...Countdown,+ args: {+ ...Countdown.args,+ duration: 1200,+ onCancel: fn(),+ onFocus: fn(),+ onBlur: fn(),+ },+ play: async ({ canvasElement, args }) => {+ const canvas = within(canvasElement);+ const toast = canvas.getByRole('status');+ await userEvent.hover(toast);+ await userEvent.tab();+ await userEvent.tab();+ expect(canvas.getByRole('button', { name: 'Cancel' })).toHaveFocus();+ await userEvent.unhover(toast);+ await new Promise((resolve) => setTimeout(resolve, 1400));+ expect(toast).toBeVisible();+ expect(args.onClose).not.toHaveBeenCalled();+ expect(args.onFocus).toHaveBeenCalledOnce();+ await userEvent.tab();+ expect(canvas.getByRole('button', { name: 'Close' })).toHaveFocus();+ await new Promise((resolve) => setTimeout(resolve, 1400));+ expect(toast).toBeVisible();+ expect(args.onClose).not.toHaveBeenCalled();+ expect(args.onFocus).toHaveBeenCalledTimes(2);+ expect(args.onBlur).toHaveBeenCalledOnce();+ await userEvent.tab({ shift: true });+ expect(canvas.getByRole('button', { name: 'Cancel' })).toHaveFocus();+ await userEvent.tab({ shift: true });+ expect(+ canvas.getByRole('button', { name: 'Show notification' }),+ ).toHaveFocus();+ expect(args.onBlur).toHaveBeenCalledTimes(3);+ await waitFor(() => expect(args.onClose).toHaveBeenCalledOnce(), {+ timeout: 3000,+ });+ },+};+export const ExplicitProgress: Story = {...Countdown,- args: { progress: 40, duration: 100, onClose: fn() },+ args: { progress: 0, duration: 100, onClose: fn() },play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);await new Promise((resolve) => setTimeout(resolve, 300));expect(canvas.getByRole('status')).toBeVisible();+ expect(canvas.getByRole('progressbar', { hidden: true })).toHaveAttribute(+ 'aria-valuenow',+ '0',+ );expect(args.onClose).not.toHaveBeenCalled();await userEvent.click(canvas.getByRole('button', { name: 'Close' }));expect(args.onClose).toHaveBeenCalledOnce();diff --git a/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.module.scss b/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.module.scssnew file mode 100644index 00000000000..07b2db0bbc5--- /dev/null+++ b/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.module.scss@@ -0,0 +1,19 @@+.countdown {+ animation: toastCountdown var(--toast-countdown-duration) linear forwards;+ background-color: var(--toast-countdown-color);+ height: 100%;++ &[data-paused] {+ animation-play-state: paused;+ }+}++@keyframes toastCountdown {+ from {+ width: 100%;+ }++ to {+ width: 0;+ }+}diff --git a/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.module.scss.d.ts b/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.module.scss.d.tsnew file mode 100644index 00000000000..a44370ca033--- /dev/null+++ b/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.module.scss.d.ts@@ -0,0 +1,4 @@+declare const classNames: {+ readonly countdown: 'countdown';+};+export default classNames;diff --git a/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.tsx b/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.tsxnew file mode 100644index 00000000000..b0302b693ba--- /dev/null+++ b/packages/twenty-ui/src/components/feedback/Toast/internal/components/ToastProgress.tsx@@ -0,0 +1,40 @@+import { type CSSProperties } from 'react';++import { ProgressBar } from '@ui/primitives/feedback/ProgressBar/ProgressBar';+import { isDefined } from '@ui/utilities/utils/isDefined';++import styles from './ToastProgress.module.scss';++type ToastProgressProps = {+ progress?: number;+ duration: number;+ isPaused: boolean;+ barColor: string;+ onClose?: () => void;+};++export const ToastProgress = ({+ progress,+ duration,+ isPaused,+ barColor,+ onClose,+}: ToastProgressProps) => {+ if (isDefined(progress)) {+ return <ProgressBar value={progress} barColor={barColor} />;+ }++ return (+ <div+ className={styles.countdown}+ data-paused={isPaused || undefined}+ onAnimationEnd={onClose}+ style={+ {+ '--toast-countdown-color': barColor,+ '--toast-countdown-duration': `${duration}ms`,+ } as CSSProperties+ }+ />+ );+};diff --git a/packages/twenty-ui/src/components/feedback/Toast/types/ToastProps.ts b/packages/twenty-ui/src/components/feedback/Toast/types/ToastProps.tsindex b9714a4a78b..8cf2090513b 100644--- a/packages/twenty-ui/src/components/feedback/Toast/types/ToastProps.ts+++ b/packages/twenty-ui/src/components/feedback/Toast/types/ToastProps.ts@@ -29,7 +29,7 @@ export type ToastProps = ComponentPropsWithRef<'div'> & {progress?: number;/*** Milliseconds before `onClose` is called. The countdown pauses while the- * pointer is over the toast.+ * pointer is over the toast or keyboard focus is inside it.*/duration?: number;/**diff --git a/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scss b/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scssindex e7df6e900a6..774211d7824 100644--- a/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scss+++ b/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scss@@ -81,25 +81,6 @@transform: translateX(-100%);}-.countdown {- animation: progressBarCountdown- var(--progress-bar-countdown-duration, #{duration(normal)}) linear forwards;-- &[data-paused] {- animation-play-state: paused;- }-}--@keyframes progressBarCountdown {- from {- width: 100%;- }-- to {- width: 0;- }-}-@keyframes progressBarGrowIn {from {width: 0;diff --git a/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scss.d.ts b/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scss.d.tsindex 270be59ea00..261a16c7b3d 100644--- a/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scss.d.ts+++ b/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.module.scss.d.ts@@ -3,6 +3,5 @@ declare const classNames: {readonly track: 'track';readonly indicator: 'indicator';readonly glint: 'glint';- readonly countdown: 'countdown';};export default classNames;diff --git a/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.tsx b/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.tsxindex c88d1e2c21c..34050d003f6 100644--- a/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.tsx+++ b/packages/twenty-ui/src/primitives/feedback/ProgressBar/ProgressBar.tsx@@ -1,25 +1,10 @@import { Progress } from '@base-ui/react/progress';+import { isNonEmptyString } from '@sniptt/guards';import { clsx } from 'clsx';+import { type CSSProperties } from 'react';import styles from './ProgressBar.module.scss';--export type ProgressBarProps = {- value: number;- size?: 'sm' | 'md';- className?: string;- barColor?: string;- backgroundColor?: string;- withBorderRadius?: boolean;- withGrowIn?: boolean;- withGlint?: boolean;- withSpringFill?: boolean;- withMinimumFillWidth?: boolean;- ariaLabel?: string;- countdownDurationInMs?: number;- isCountdownPaused?: boolean;- onCountdownComplete?: () => void;- onGrowInComplete?: () => void;-};+import { type ProgressBarProps } from './types/ProgressBarProps';export const ProgressBar = ({value,@@ -33,13 +18,8 @@ export const ProgressBar = ({withSpringFill = false,withMinimumFillWidth = true,ariaLabel,- countdownDurationInMs,- isCountdownPaused = false,- onCountdownComplete,onGrowInComplete,}: ProgressBarProps) => {- const isCountdown = countdownDurationInMs !== undefined;-return (<Progress.RootclassName={clsx(styles.bar, className)}@@ -56,25 +36,18 @@ export const ProgressBar = ({style={{'--progress-bar-background-color': backgroundColor,- ...(barColor ? { '--progress-bar-color': barColor } : {}),- ...(isCountdown- ? {- '--progress-bar-countdown-duration': `${countdownDurationInMs}ms`,- }+ ...(isNonEmptyString(barColor)+ ? { '--progress-bar-color': barColor }: {}),- } as React.CSSProperties+ } as CSSProperties}><Progress.Track className={styles.track}><Progress.Indicator- className={clsx(styles.indicator, isCountdown && styles.countdown)}+ className={styles.indicator}data-with-border-radius={withBorderRadius || undefined}data-spring-fill={withSpringFill || undefined}- data-nonzero={- (withMinimumFillWidth && value > 0 && !isCountdown) || undefined- }- data-paused={(isCountdown && isCountdownPaused) || undefined}- onAnimationEnd={isCountdown ? onCountdownComplete : undefined}+ data-nonzero={(withMinimumFillWidth && value > 0) || undefined}>{withGlint && <span key={value} className={styles.glint} />}</Progress.Indicator>diff --git a/packages/twenty-ui/src/primitives/feedback/ProgressBar/__stories__/ProgressBar.stories.tsx b/packages/twenty-ui/src/primitives/feedback/ProgressBar/__stories__/ProgressBar.stories.tsxindex 9a582000ddf..01707ed102b 100644--- a/packages/twenty-ui/src/primitives/feedback/ProgressBar/__stories__/ProgressBar.stories.tsx+++ b/packages/twenty-ui/src/primitives/feedback/ProgressBar/__stories__/ProgressBar.stories.tsx@@ -1,7 +1,10 @@import { type Meta, type StoryObj } from '@storybook/react-vite';-import { expect, within } from 'storybook/test';+import { useState } from 'react';+import { expect, userEvent, within } from 'storybook/test';+import { ComponentDecorator } from '@ui/testing/decorators/ComponentDecorator';import { ProgressBar } from '@ui/primitives/feedback/ProgressBar/ProgressBar';+import { Button } from '@ui/primitives/input/Button/Button';const meta: Meta<typeof ProgressBar> = {title: 'UI/Feedback/ProgressBar/ProgressBar',@@ -74,17 +77,34 @@ export const SpringFill: Story = {},};-export const Countdown: Story = {- tags: ['!test'],- argTypes: {- value: { control: false },- },- args: {- value: 100,- ariaLabel: 'Progress',- countdownDurationInMs: 10000,- },- parameters: {- chromatic: { disableSnapshot: true },+const ControlledProgressBar = () => {+ const [value, setValue] = useState(0);++ return (+ <>+ <ProgressBar value={value} ariaLabel="Import progress" />+ <Button onClick={() => setValue(50)}>Report progress</Button>+ <Button onClick={() => setValue(100)}>Complete import</Button>+ </>+ );+};++export const Controlled: Story = {+ render: () => <ControlledProgressBar />,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const progress = canvas.getByRole('progressbar', {+ name: 'Import progress',+ });++ expect(progress).toHaveAttribute('aria-valuenow', '0');+ await userEvent.click(+ canvas.getByRole('button', { name: 'Report progress' }),+ );+ expect(progress).toHaveAttribute('aria-valuenow', '50');+ await userEvent.click(+ canvas.getByRole('button', { name: 'Complete import' }),+ );+ expect(progress).toHaveAttribute('aria-valuenow', '100');},};diff --git a/packages/twenty-ui/src/primitives/feedback/ProgressBar/types/ProgressBarProps.ts b/packages/twenty-ui/src/primitives/feedback/ProgressBar/types/ProgressBarProps.tsnew file mode 100644index 00000000000..615b60f63bb--- /dev/null+++ b/packages/twenty-ui/src/primitives/feedback/ProgressBar/types/ProgressBarProps.ts@@ -0,0 +1,14 @@+export type ProgressBarProps = {+ value: number;+ size?: 'sm' | 'md';+ className?: string;+ barColor?: string;+ backgroundColor?: string;+ withBorderRadius?: boolean;+ withGrowIn?: boolean;+ withGlint?: boolean;+ withSpringFill?: boolean;+ withMinimumFillWidth?: boolean;+ ariaLabel?: string;+ onGrowInComplete?: () => void;+};diff --git a/packages/twenty-ui/src/primitives/feedback/index.ts b/packages/twenty-ui/src/primitives/feedback/index.tsindex b3a0a3b2f99..d7e5d071110 100644--- a/packages/twenty-ui/src/primitives/feedback/index.ts+++ b/packages/twenty-ui/src/primitives/feedback/index.ts@@ -10,5 +10,5 @@export type { BannerColor, BannerVariant } from './Banner/Banner';export { Banner } from './Banner/Banner';export { Loader } from './Loader/Loader';-export type { ProgressBarProps } from './ProgressBar/ProgressBar';export { ProgressBar } from './ProgressBar/ProgressBar';+export type { ProgressBarProps } from './ProgressBar/types/ProgressBarProps';