-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: rename toast components (#1520)
Relates to #1301 As discussed with Jannick, we aligned the naming between UX and dev
- Loading branch information
1 parent
d4d35c9
commit 7b72cbc
Showing
69 changed files
with
550 additions
and
535 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"sit-onyx": major | ||
--- | ||
|
||
refactor: rename toast components | ||
|
||
- renamed `OnyxToast` to `OnyxToastMessage` | ||
- renamed `OnyxToastProvider` to `OnyxToast` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-46.2 KB
...x/playwright/snapshots/components/OnyxToast/Toast-clickable--chromium-linux.png
Binary file not shown.
Binary file removed
BIN
-87.6 KB
...yx/playwright/snapshots/components/OnyxToast/Toast-clickable--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-44.1 KB
...nyx/playwright/snapshots/components/OnyxToast/Toast-clickable--webkit-linux.png
Binary file not shown.
Binary file removed
BIN
-45.8 KB
...nyx/playwright/snapshots/components/OnyxToast/Toast-default--chromium-linux.png
Binary file not shown.
Binary file removed
BIN
-87.2 KB
...onyx/playwright/snapshots/components/OnyxToast/Toast-default--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-44.1 KB
...-onyx/playwright/snapshots/components/OnyxToast/Toast-default--webkit-linux.png
Binary file not shown.
Binary file removed
BIN
-92.2 KB
...playwright/snapshots/components/OnyxToast/Toast-description--chromium-linux.png
Binary file not shown.
Binary file removed
BIN
-208 KB
.../playwright/snapshots/components/OnyxToast/Toast-description--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-105 KB
...x/playwright/snapshots/components/OnyxToast/Toast-description--webkit-linux.png
Binary file not shown.
Binary file removed
BIN
-48 KB
...laywright/snapshots/components/OnyxToast/Toast-manual-close--chromium-linux.png
Binary file not shown.
Binary file removed
BIN
-89.1 KB
...playwright/snapshots/components/OnyxToast/Toast-manual-close--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-45.5 KB
.../playwright/snapshots/components/OnyxToast/Toast-manual-close--webkit-linux.png
Binary file not shown.
Binary file removed
BIN
-14.7 KB
.../playwright/snapshots/components/OnyxToast/Toast-truncation--chromium-linux.png
Binary file not shown.
Binary file removed
BIN
-27.1 KB
...x/playwright/snapshots/components/OnyxToast/Toast-truncation--firefox-linux.png
Binary file not shown.
Binary file removed
BIN
-16 KB
...yx/playwright/snapshots/components/OnyxToast/Toast-truncation--webkit-linux.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added
BIN
+47.7 KB
...apshots/components/OnyxToastMessage/Toast-message-clickable--chromium-linux.png
Oops, something went wrong.
Binary file added
BIN
+89.3 KB
...napshots/components/OnyxToastMessage/Toast-message-clickable--firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+44.8 KB
...snapshots/components/OnyxToastMessage/Toast-message-clickable--webkit-linux.png
Oops, something went wrong.
Binary file added
BIN
+47.3 KB
...snapshots/components/OnyxToastMessage/Toast-message-default--chromium-linux.png
Oops, something went wrong.
Binary file added
BIN
+89 KB
.../snapshots/components/OnyxToastMessage/Toast-message-default--firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+44.8 KB
...t/snapshots/components/OnyxToastMessage/Toast-message-default--webkit-linux.png
Oops, something went wrong.
Binary file added
BIN
+93.5 KB
...shots/components/OnyxToastMessage/Toast-message-description--chromium-linux.png
Oops, something went wrong.
Binary file added
BIN
+209 KB
...pshots/components/OnyxToastMessage/Toast-message-description--firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+106 KB
...apshots/components/OnyxToastMessage/Toast-message-description--webkit-linux.png
Oops, something went wrong.
Binary file added
BIN
+48.5 KB
...hots/components/OnyxToastMessage/Toast-message-manual-close--chromium-linux.png
Oops, something went wrong.
Binary file added
BIN
+90.2 KB
...shots/components/OnyxToastMessage/Toast-message-manual-close--firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+45.9 KB
...pshots/components/OnyxToastMessage/Toast-message-manual-close--webkit-linux.png
Oops, something went wrong.
Binary file added
BIN
+16.4 KB
...pshots/components/OnyxToastMessage/Toast-message-truncation--chromium-linux.png
Oops, something went wrong.
Binary file added
BIN
+28.3 KB
...apshots/components/OnyxToastMessage/Toast-message-truncation--firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+16.6 KB
...napshots/components/OnyxToastMessage/Toast-message-truncation--webkit-linux.png
Oops, something went wrong.
94 changes: 23 additions & 71 deletions
94
packages/sit-onyx/src/components/OnyxToast/OnyxToast.ct.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,31 @@ | ||
import { DENSITIES } from "../../composables/density"; | ||
import { test } from "../../playwright/a11y"; | ||
import { executeMatrixScreenshotTest } from "../../playwright/screenshots"; | ||
import type { OnyxColor } from "../../types"; | ||
import OnyxToast from "./OnyxToast.vue"; | ||
import { expect, test } from "../../playwright/a11y"; | ||
import { ONYX_BREAKPOINTS } from "../../types"; | ||
import PlaywrightTestWrapper from "./PlaywrightTestWrapper.vue"; | ||
|
||
const TOAST_COLORS = ["neutral", "danger", "warning", "success"] satisfies OnyxColor[]; | ||
Object.entries(ONYX_BREAKPOINTS).forEach(([breakpoint, width]) => { | ||
test(`should render (${breakpoint})`, async ({ mount, makeAxeBuilder, page }) => { | ||
await page.setViewportSize({ width, height: 512 }); | ||
|
||
test.beforeEach(async ({ page }) => { | ||
await page.addStyleTag({ | ||
content: `.onyx-toast__progress-bar { | ||
width: 100% | ||
}`, | ||
}); | ||
}); | ||
// ARRANGE | ||
const component = await mount(<PlaywrightTestWrapper />); | ||
|
||
test.describe("Screenshot tests", () => { | ||
for (const mode of ["default", "clickable", "manual-close"] as const) { | ||
executeMatrixScreenshotTest({ | ||
name: `Toast (${mode})`, | ||
columns: DENSITIES, | ||
rows: TOAST_COLORS, | ||
// ASSERT | ||
await expect(page).toHaveScreenshot(`breakpoint-${breakpoint}.png`); | ||
|
||
// ACT | ||
const accessibilityScanResults = await makeAxeBuilder() | ||
// TODO: remove when contrast issues are fixed in https://github.com/SchwarzIT/onyx/issues/410 | ||
disabledAccessibilityRules: ["color-contrast"], | ||
component: (column, row) => ( | ||
<OnyxToast | ||
headline="Test toast" | ||
color={row} | ||
density={column} | ||
duration={mode === "manual-close" ? 0 : undefined} | ||
clickable={mode === "clickable"} | ||
// margin is used to not cut off the box shadow in the screenshot | ||
style={{ margin: "1rem" }} | ||
/> | ||
), | ||
}); | ||
} | ||
}); | ||
.disableRules(["color-contrast"]) | ||
.analyze(); | ||
|
||
test.describe("Screenshot tests (description)", () => { | ||
executeMatrixScreenshotTest({ | ||
name: "Toast (description)", | ||
columns: DENSITIES, | ||
rows: TOAST_COLORS, | ||
// TODO: remove when contrast issues are fixed in https://github.com/SchwarzIT/onyx/issues/410 | ||
disabledAccessibilityRules: ["color-contrast"], | ||
component: (column, row) => ( | ||
<OnyxToast | ||
headline="Test toast" | ||
color={row} | ||
density={column} | ||
description="Lorem ipsum dolor sit amet consectetur. Non in felis erat velit consectetur. Sed integer non hac viverra nibh vehicula risus ultrices. Molestie cras lobortis vitae gravida et ut. Turpis nisl pharetra amet ante eu sagittis sit elementum ut." | ||
// margin is used to not cut off the box shadow in the screenshot | ||
style={{ margin: "1rem" }} | ||
/> | ||
), | ||
}); | ||
}); | ||
// ASSERT | ||
expect(accessibilityScanResults.violations).toEqual([]); | ||
await expect(component).toContainText("Example toast 1"); | ||
|
||
// ACT | ||
await component.getByLabel("Close").nth(4).click(); | ||
|
||
test.describe("Screenshot tests (truncation)", () => { | ||
executeMatrixScreenshotTest({ | ||
name: "Toast (truncation)", | ||
columns: ["default"], | ||
rows: ["default"], | ||
component: () => ( | ||
<OnyxToast | ||
headline={"Test".repeat(32)} | ||
description={"Test".repeat(96)} | ||
// margin is used to not cut off the box shadow in the screenshot | ||
style={{ margin: "1rem" }} | ||
/> | ||
), | ||
beforeScreenshot: async (component) => { | ||
await component.getByRole("paragraph").evaluate((element) => { | ||
element.scrollBy({ top: element.scrollHeight }); | ||
}); | ||
}, | ||
// ASSERT | ||
await expect(component).not.toContainText("Example toast 1"); | ||
}); | ||
}); |
121 changes: 47 additions & 74 deletions
121
packages/sit-onyx/src/components/OnyxToast/OnyxToast.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,58 @@ | ||
import { defineStorybookActionsAndVModels } from "@sit-onyx/storybook-utils"; | ||
import type { Meta, StoryObj } from "@storybook/vue3"; | ||
import { defineIconSelectArgType } from "../../utils/storybook"; | ||
import OnyxToast from "./OnyxToast.vue"; | ||
import StorybookExample from "./StorybookExample.vue"; | ||
import StorybookExampleSourceCode from "./StorybookExample.vue?raw"; | ||
|
||
/** | ||
* Single toast component. Is mainly intended to be used with the [OnyxToastProvider](/docs/feedback-toastprovider--docs). | ||
* The toast is used to display toast messages to the user. | ||
* For a full list of toast examples, you can check out the [OnyxToastMessage](/docs/support-toastmessage--docs) component. | ||
* | ||
* For a good user experience, make sure to not display too many toasts at the same time (we recommend a limit of 5 toasts). | ||
* | ||
* ### Setup | ||
* | ||
* #### Step 1: Use the `<OnyxToast />` component | ||
* | ||
* Place the `<OnyxToast />` component once anywhere in your application (e.g. in your App.vue file). | ||
* It will take care of displaying the toasts correctly. | ||
* | ||
* #### Step 2: Create the toast provider | ||
* | ||
* **If you are using the `createOnyx()` Vue plugin, you can skip this step since this will already be set up for you.** | ||
* | ||
* The toast works with Vue's [provide/inject](https://vuejs.org/guide/components/provide-inject) API so you need to create a toast provider once. | ||
* To do so, add the following code to your `main.ts` file to set up the toasts globally: | ||
* | ||
* ```ts | ||
* import { createToastProvider, TOAST_PROVIDER_INJECTION_KEY } from "sit-onyx"; | ||
* | ||
* app.provide(TOAST_PROVIDER_INJECTION_KEY, createToastProvider()); | ||
* ``` | ||
* | ||
* Afterwards, toasts can be shown using the `useToast()` composable as shown in the example below. | ||
*/ | ||
const meta: Meta<typeof OnyxToast> = { | ||
title: "Support/Toast", | ||
const meta: Meta<typeof StorybookExample> = { | ||
title: "Feedback/Toast", | ||
...defineStorybookActionsAndVModels({ | ||
component: OnyxToast, | ||
events: ["click", "close"], | ||
argTypes: { | ||
icon: defineIconSelectArgType(), | ||
}, | ||
component: StorybookExample, | ||
events: [], | ||
decorators: [ | ||
(story) => ({ | ||
components: { story }, | ||
template: `<div style="height: 24rem;"> <story /> </div>`, | ||
}), | ||
], | ||
}), | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: StorybookExampleSourceCode.replace('from "../.."', 'from "sit-onyx"'), | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof OnyxToast>; | ||
|
||
export const Default = { | ||
args: { | ||
headline: "Example toast", | ||
description: "Lorem ipsum dolor sit amet consectetur. Non in felis erat velit consectetur.", | ||
}, | ||
} satisfies Story; | ||
|
||
export const Danger = { | ||
args: { | ||
...Default.args, | ||
color: "danger", | ||
}, | ||
} satisfies Story; | ||
|
||
export const Warning = { | ||
args: { | ||
...Default.args, | ||
color: "warning", | ||
}, | ||
} satisfies Story; | ||
|
||
export const Success = { | ||
args: { | ||
...Default.args, | ||
color: "success", | ||
}, | ||
} satisfies Story; | ||
type Story = StoryObj<typeof StorybookExample>; | ||
|
||
export const Clickable = { | ||
args: { | ||
...Default.args, | ||
clickable: true, | ||
}, | ||
} satisfies Story; | ||
|
||
export const ManualClose = { | ||
args: { | ||
...Default.args, | ||
duration: 0, | ||
}, | ||
} satisfies Story; | ||
|
||
/** | ||
* This example shows a toast with a very long description that is limited to 3 lines. | ||
* The user can scroll to see the rest of the description. | ||
*/ | ||
export const LongDescription = { | ||
args: { | ||
...Default.args, | ||
description: | ||
"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", | ||
}, | ||
} satisfies Story; | ||
|
||
/** | ||
* This example shows a toast with the minimal amount of data. | ||
*/ | ||
export const MinimalData = { | ||
args: { | ||
headline: Default.args.headline, | ||
icon: false, | ||
}, | ||
} satisfies Story; | ||
export const Default = { args: {} } satisfies Story; |
Oops, something went wrong.