Skip to content

Commit 97b7f40

Browse files
committed
feat(toaster): implement component
1 parent f32eeef commit 97b7f40

File tree

40 files changed

+1584
-11
lines changed

40 files changed

+1584
-11
lines changed

packages/examples/accessibility-test/src/app/App.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
Text,
4040
Textarea,
4141
Timepicker, TimepickerControl, TimepickerTimezoneList,
42+
Toaster, toast,
4243
Toggle,
4344
Tooltip,
4445
TooltipContent,
@@ -1206,6 +1207,16 @@ function App(): ReactElement {
12061207
</FormField>
12071208
</section>
12081209

1210+
<section>
1211+
<h1>Toaster</h1>
1212+
1213+
<Toaster duration={ Infinity } />
1214+
1215+
<button onClick={ () => toast('Some message') }>
1216+
Trigger toast
1217+
</button>
1218+
</section>
1219+
12091220
<section>
12101221
<h1>Toggle</h1>
12111222

packages/ods-react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@ark-ui/react": "5.25.1",
3737
"classnames": "2.5.1",
3838
"libphonenumber-js": "1.12.8",
39+
"react-hot-toast": "2.6.0",
3940
"react-shiki": "0.9.0"
4041
},
4142
"peerDependencies": {

packages/ods-react/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ export * from './combobox/src';
4141

4242
export * from './tree-view/src';
4343
export * from './meter/src';
44+
45+
export * from './toaster/src';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { StorybookConfig } from '@storybook/react-vite';
2+
3+
const config: StorybookConfig = {
4+
core: {
5+
disableTelemetry: true,
6+
disableWhatsNewNotifications: true,
7+
},
8+
docs: {
9+
autodocs: false,
10+
},
11+
framework: '@storybook/react-vite',
12+
previewHead: (head) => `
13+
${head}
14+
<style>
15+
html, body {
16+
font-family: "Source Sans Pro", "Trebuchet MS", "Arial", "Segoe UI", sans-serif;
17+
}
18+
</style>
19+
`,
20+
stories: [
21+
'../src/dev.stories.tsx',
22+
'../tests/**/*.stories.tsx',
23+
],
24+
};
25+
26+
export default config;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { addons } from '@storybook/manager-api';
2+
3+
addons.register('custom-panel', (api) => {
4+
api.togglePanel(false);
5+
});
6+
7+
addons.setConfig({
8+
enableShortcuts: false,
9+
showToolbar: true,
10+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { type Preview } from '@storybook/react';
2+
import '@ovhcloud/ods-themes/default/css';
3+
import '@ovhcloud/ods-themes/default/fonts';
4+
5+
const preview: Preview = {
6+
parameters: {},
7+
};
8+
9+
export default preview;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const isCI = !!process.env.CI;
2+
3+
export default {
4+
launch: {
5+
headless: isCI,
6+
slowMo: isCI ? 0 : 300,
7+
product: 'chrome',
8+
args: [
9+
'--no-sandbox',
10+
'--disable-setuid-sandbox',
11+
"--disable-dev-shm-usage",
12+
"--disable-accelerated-2d-canvas",
13+
"--disable-gpu",
14+
'--font-render-hinting=none',
15+
],
16+
},
17+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const baseOption = {
2+
collectCoverage: false,
3+
testPathIgnorePatterns: [
4+
'node_modules/',
5+
'dist/',
6+
],
7+
testRegex: 'tests\\/.*\\.spec\\.(ts|tsx)$',
8+
transform: {
9+
'\\.(ts|tsx)$': 'ts-jest',
10+
},
11+
verbose: true,
12+
};
13+
14+
export default !!process.env.E2E ?
15+
{
16+
...baseOption,
17+
preset: 'jest-puppeteer',
18+
testRegex: 'tests\\/.*\\.e2e\\.ts$',
19+
testTimeout: 60000,
20+
} : {
21+
...baseOption,
22+
transform: {
23+
...baseOption.transform,
24+
'\\.scss$': 'jest-transform-stub',
25+
}
26+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module '*.css';
2+
declare module '*.scss';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@ovhcloud/ods-react-toaster",
3+
"version": "19.2.1",
4+
"private": true,
5+
"description": "ODS React Toaster component",
6+
"type": "module",
7+
"main": "dist/index.js",
8+
"scripts": {
9+
"clean": "rimraf documentation node_modules",
10+
"doc": "npm run clean && npm run doc:ts && npm run doc:css",
11+
"doc:css": "sass src/components:documentation --no-source-map --pkg-importer=node && node ../../../scripts/generate-component-token-list.js",
12+
"doc:ts": "typedoc",
13+
"lint:a11y": "eslint --config ../../../../../.eslintrc-a11y 'src/**/*.{js,ts,tsx}' --ignore-pattern '*.stories.tsx'",
14+
"lint:scss": "stylelint --aei 'src/components/**/*.scss'",
15+
"lint:ts": "eslint '{src,tests}/**/*.{js,ts,tsx}' --ignore-pattern '*.stories.tsx'",
16+
"start": "npm run start:storybook",
17+
"start:storybook": "storybook dev -p 3000 --no-open",
18+
"test:e2e": "E2E=true start-server-and-test 'npm run start:storybook' 3000 'jest -i --detectOpenHandles'",
19+
"test:e2e:ci": "CI=true npm run test:e2e",
20+
"test:spec": "jest --passWithNoTests",
21+
"test:spec:ci": "npm run test:spec"
22+
}
23+
}

0 commit comments

Comments
 (0)