Skip to content

Commit

Permalink
docs(storybook): add badges to deprecated components
Browse files Browse the repository at this point in the history
Ref UXD-1672
  • Loading branch information
ajkl2533 committed Nov 25, 2024
1 parent bb46b0a commit 9458a4f
Show file tree
Hide file tree
Showing 129 changed files with 61 additions and 26 deletions.
19 changes: 19 additions & 0 deletions .storybook/decorators/withMockedDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {makeDecorator} from '@storybook/preview-api'
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import MockDate from 'mockdate';

dayjs.extend(utc)

export const withMockedDate = makeDecorator({
name: 'withMockedDate',
parameterName: 'mockDate',
wrapper: (storyFn, context, {parameters: date}) => {
MockDate.reset();

if (date instanceof Date) {
MockDate.set(dayjs(date).utc(true).toDate())
}
return storyFn(context)
}
})
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const config: StorybookConfig = {
'@storybook/addon-designs',
'@storybook/addon-themes',
'@storybook/addon-coverage',
'@storybook/addon-a11y',
'storycap',
'@storybook/addon-a11y'
'storybook-addon-tag-badges'
],
docs: { defaultName: 'Documentation' },
typescript: {
Expand Down
3 changes: 2 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import '@fontsource/inter/700.css';
import '@fontsource/space-mono/400.css';
import '../src/tokens/tokens.css';
import { SlowBuffer } from 'buffer';
import { withMockedDate } from './decorators/withMockedDate';

function clearDatatableLS() {
Object.keys(localStorage)
Expand Down Expand Up @@ -139,7 +140,6 @@ const preview: Preview = {
},
},
decorators: [
// @ts-expect-error as the type of the withScreenshot is too wide
withScreenshot,
withI18next,
withThemeByClassName({
Expand All @@ -149,6 +149,7 @@ const preview: Preview = {
},
defaultTheme: 'Light',
}),
withMockedDate(),
(storyFn) => (
<DSProvider config={{ debugMode: true }}>{storyFn()}</DSProvider>
),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
"semantic-release": "^24.1.0",
"semantic-release-export-data": "^1.1.0",
"storybook": "^8.4.4",
"storybook-addon-tag-badges": "^1.3.0",
"storycap": "^5.0.0",
"styled-components": "^5.3.3",
"stylelint": "^16.6.1",
Expand Down
1 change: 1 addition & 0 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default {
},
},
},
tags: ['deprecated'],
} as Meta;

export const Playground: StoryFn<ButtonProps> = (args) => <Button {...args} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { actionsMock } from '../../mocks/actions';
import { BatchActionsProps } from './BatchActions.types';

export default {
title: 'components/Datatable/internalComponents/BatchModule/BatchActions',
title: 'tests/Datatable/BatchModule/BatchActions',
component: BatchActions,
parameters: {
viewMode: 'story',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { DatatableStore } from '../Datatable.store';
import { defaultTableConfig } from '../defaultConfigs';

export default {
title: 'components/Datatable/internalComponents/BatchModule',
title: 'tests/Datatable/BatchModule',
component: BatchModule,
decorators: [(storyFn) => <MemoryRouter>{storyFn()}</MemoryRouter>],
parameters: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ElementCounterProps } from './ElementCounter.types';
import { defaultTableConfig } from '../../defaultConfigs';

export default {
title: 'components/Datatable/internalComponents/BatchModule/ElementCounter',
title: 'tests/Datatable/BatchModule/ElementCounter',
component: ElementCounter,
parameters: {
viewMode: 'story',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { simpleColumns } from '../../_internal/BaseTable/mocks/columns';
import { Data } from '../../_internal/BaseTable/mocks/types';

export default {
title: 'components/Datatable/internalComponents/ControlsModule',
title: 'tests/Datatable/ControlsModule',
component: ControlsModule,
parameters: {
viewMode: 'story',
Expand Down
5 changes: 2 additions & 3 deletions src/components/Datatable/Datatable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { MemoryRouter } from 'react-router-dom';
import { action } from '@storybook/addon-actions';
import { Meta, StoryFn } from '@storybook/react';
import MockDate from 'mockdate';

import assets from '../_internal/BaseTable/mocks/ipAssets.json';
import { Data } from '../_internal/BaseTable/mocks/types';
Expand All @@ -22,12 +21,11 @@ import {
import Datatable from './Datatable';
import { DatatableProps } from './Datatable.types';

MockDate.set('2021-03-31T00:00:00Z');

export default {
title: 'components/Datatable',
component: Datatable,
parameters: {
mockDate: new Date('2021-03-31T00:00:00Z'),
screenshot: { skip: true },
docs: {
source: { type: 'code' },
Expand Down Expand Up @@ -112,6 +110,7 @@ const MyFancyDatatable = () => <Datatable ...props />
},
},
},
tags: ['deprecated'],
} as Meta;

export const ServerSidePlayground: StoryFn<DatatableProps<Data>> = (args) => {
Expand Down
6 changes: 2 additions & 4 deletions src/components/Datatable/DatatableTests.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect } from 'react';
import { Meta, StoryFn } from '@storybook/react';
import { MemoryRouter } from 'react-router-dom';
import MockDate from 'mockdate';

import Datatable from './Datatable';
import {
Expand All @@ -17,15 +16,14 @@ import { tableActionsMock } from './mocks/actions';
import { Text } from '../Text';
import { Stack } from '../layout';

MockDate.set('2021-03-31T00:00:00Z');

export default {
title: 'components/Datatable/internalComponents/Datatable',
title: 'tests/Datatable/Datatable',
component: Datatable,
parameters: {
viewMode: 'story',
docs: { disable: true },
previewTabs: { 'storybook/docs/panel': { hidden: true } },
mockDate: new Date('2021-03-31T00:00:00Z'),
},
decorators: [(storyFn) => <MemoryRouter>{storyFn()}</MemoryRouter>],
} as Meta;
Expand Down
6 changes: 2 additions & 4 deletions src/components/Datatable/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect } from 'react';
import { Meta, StoryFn } from '@storybook/react';
import { MemoryRouter } from 'react-router-dom';
import { omit } from 'ramda';
import MockDate from 'mockdate';

import Table from './Table';
import { TableProps } from './Table.types';
Expand All @@ -13,10 +12,8 @@ import { simpleColumns } from '../../_internal/BaseTable/mocks/columns';
import { datatableRowActions } from '../mocks/actions';
import { DatatableStore, datatableInitialState } from '../Datatable.store';

MockDate.set('2021-03-31T00:00:00Z');

export default {
title: 'components/Datatable/internalComponents/Table',
title: 'tests/Datatable/Table',
component: Table,
parameters: {
viewMode: 'story',
Expand All @@ -26,6 +23,7 @@ export default {
height: 720,
},
},
mockDate: new Date('2021-03-31T00:00:00Z'),
},
argTypes: {
data: { controls: { type: 'disabled' } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { useColumnsControls } from '../../hooks/useColumnsControls';
import { ColumnsControlsProps } from './ColumnsControls.types';

export default {
title:
'components/Datatable/internalComponents/ControlsModule/ColumnsControls',
title: 'tests/Datatable/ControlsModule/ColumnsControls',
component: ColumnsControls,
parameters: {
viewMode: 'story',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ControlButton from './ControlButton';
import { ControlButtonProps } from './ControlButton.types';

export default {
title: 'components/Datatable/internalComponents/ControlsModule/ControlButton',
title: 'tests/Datatable/ControlsModule/ControlButton',
component: ControlButton,
parameters: {
viewMode: 'story',
Expand Down
1 change: 1 addition & 0 deletions src/components/FlexContainer/FlexContainer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ leo tincidunt vehicula non a dolor. Suspendisse placerat turpis nisl, quis gravi
export default {
title: 'components/FlexContainer',
component: FlexContainer,
tags: ['deprecated'],
} as Meta;

export const Sample: StoryFn = () => (
Expand Down
1 change: 1 addition & 0 deletions src/components/ListView/ListView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const meta = {
},
getRowId: (row) => row.id,
},
tags: ['new'],
} satisfies Meta<typeof ListView<FakeData>>;

export default meta;
Expand Down
3 changes: 3 additions & 0 deletions src/components/SingleDatePicker/SingleDatePicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export default {
decorators: [
(storyFn) => <div style={{ paddingBottom: '300px' }}>{storyFn()}</div>,
],
parameters: {
mockDate: new Date('2021/03/31'),
},
} as Meta;

export const Playground: StoryFn<SingleDatePickerProps> = (args) => (
Expand Down
5 changes: 2 additions & 3 deletions src/components/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Meta, StoryFn } from '@storybook/react';
import { MemoryRouter } from 'react-router-dom';
import MockDate from 'mockdate';
import { action } from '@storybook/addon-actions';

import { Data } from '../_internal/BaseTable/mocks/types';
Expand All @@ -11,8 +10,6 @@ import Table from './Table';
import { TableProps } from './Table.types';
import { datatableRowActions } from '../Datatable/mocks/actions';

MockDate.set('2021-03-31T00:00:00Z');

export default {
title: 'components/Table',
component: Table,
Expand All @@ -36,6 +33,7 @@ ${comparisonTable}
height: 720,
},
},
mockDate: new Date('2021-03-31T00:00:00Z'),
},
decorators: [
(storyFn) => (
Expand All @@ -44,6 +42,7 @@ ${comparisonTable}
</MemoryRouter>
),
],
tags: ['deprecated'],
} as Meta;

const TableTemplate: StoryFn<TableProps<Data>> = (args) => (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Text/Text.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const ContextText: StoryFn = () => (
</>
);

ContextText.storyName = 'Context Text (DEPRECATED)';
ContextText.tags = ['deprecated'];

export const MonospaceText: StoryFn = () => (
<>
Expand Down
1 change: 1 addition & 0 deletions src/components/TreeView/TreeView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const Playground: Story = {
parameters: {
screenshot: { skip: true },
},
tags: ['new'],
};

export const ContentRenderers: Story = {
Expand Down
1 change: 1 addition & 0 deletions src/components/Wizard/Wizard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
source: { type: 'code' },
},
},
tags: ['deprecated'],
} as Meta;

const WizardTemplate = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Footer from './Footer';
import { FooterProps } from './Footer.types';

export default {
title: 'components/Datatable/internalComponents/Table/Footer',
title: 'tests/Datatable/Table/Footer',
component: Footer,
parameters: {
viewMode: 'story',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { CellTypes } from './renderers.enums';
import { abbreviateNumber } from '../../../../utils';

export default {
title: 'components/Datatable/internalComponents/Table/renderers',
title: 'tests/Datatable/Table/renderers',
component: CellRenderer,
decorators: [
(storyFn) => (
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3722,6 +3722,7 @@ __metadata:
semantic-release: "npm:^24.1.0"
semantic-release-export-data: "npm:^1.1.0"
storybook: "npm:^8.4.4"
storybook-addon-tag-badges: "npm:^1.3.0"
storycap: "npm:^5.0.0"
styled-components: "npm:^5.3.3"
stylelint: "npm:^16.6.1"
Expand Down Expand Up @@ -17480,6 +17481,17 @@ __metadata:
languageName: node
linkType: hard

"storybook-addon-tag-badges@npm:^1.3.0":
version: 1.3.0
resolution: "storybook-addon-tag-badges@npm:1.3.0"
dependencies:
"@storybook/icons": "npm:^1.2.12"
peerDependencies:
storybook: ^8.4.4
checksum: 10/1630bed21ed8e63018874d8102190fa30ade4dc055a64a040d895ee6f6d51eb9295f987a5954a57a647131c13b5cfbcf6d94ebbd00f09f80bf5b3f2a90467328
languageName: node
linkType: hard

"storybook@npm:^8.4.4":
version: 8.4.4
resolution: "storybook@npm:8.4.4"
Expand Down

0 comments on commit 9458a4f

Please sign in to comment.