Skip to content

feat: upgrade storybook #880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:storybook/recommended"
],
"rules": {
"@typescript-eslint/no-var-requires": "off",
Expand Down
23 changes: 11 additions & 12 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module.exports = {
core: {
builder: 'webpack5',
},
stories: [
'../src/stories/Introduction.stories.mdx',
'../src/**/*.stories.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx)',
'./*.stories.mdx',
],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
stories: ['../src/stories/Introduction.stories.mdx', '../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)', './*.stories.mdx'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-mdx-gfm'],
features: {
storyStoreV7: true,
storyStoreV7: true
},
framework: {
name: '@storybook/react-webpack5',
options: {}
},
};
docs: {
autodocs: true
}
};
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
"node": ">=14"
},
"scripts": {
"build": "npm run build:icon && npm run build:next:icon && npm run build:lib && npm run build:es && npm run build:ts",
"build": "yarn build:icon && yarn build:next:icon && yarn build:lib && yarn build:es && yarn build:ts",
"build:lib": "rm -rf lib && babel src -d lib --extensions .ts,.tsx --ignore .storybook/**/*,src/**/*.test.tsx,src/**/*.test.ts,src/**/*.spec.tsx,src/**/*.spec.ts,src/**/*.stories.tsx",
"build:es": "rm -rf es && cross-env BABEL_ENV=es babel src -d es --extensions .ts,.tsx --ignore .storybook/**/*,src/**/*.test.tsx,src/**/*.test.ts,src/**/*.spec.tsx,src/**/*.spec.ts,src/**/*.stories.tsx",
"build:ts": "tsc --project tsconfig.declaration.json -d --declarationDir lib && tsc --project tsconfig.declaration.json -d --declarationDir es",
"build:icon": "rm -rf src/General/Icon/components && babel-node --extensions .ts,.tsx src/Utils/Icon/generateIcons.ts && npm run format:icon",
"build:icon": "rm -rf src/General/Icon/components && babel-node --extensions .ts,.tsx src/Utils/Icon/generateIcons.ts && yarn format:icon",
"build:next:icon": "npx @svgr/cli --typescript --out-dir src/@next/Icon/components -- src/@next/Icon/icons",
"format:icon": "prettier --write src/General/Icon/components/*.tsx",
"imports": "babel-node --extensions .ts scripts/count-imports/index.ts",
"lint": "npm run lint:css && npm run lint:ts",
"lint": "yarn lint:css && yarn lint:ts",
"lint:css": "stylelint '**/*Style.ts'",
"lint:ts": "eslint '**/*.{ts,tsx}'",
"test:update": "jest --env jsdom -u",
"test": "jest --env jsdom",
"coverage:src": "jest --coverage --collectCoverageFrom 'src/**/*.tsx' --coveragePathIgnorePatterns 'src/General/Icon/components/' --collectCoverageFrom='!src/**/*.stories.tsx' --collectCoverageFrom='!src/**/*StoryStyle.tsx' --collectCoverageFrom='!src/**/*StoriesHelpers.tsx' --collectCoverageFrom='!src/stories/story-components/**'",
"storybook": "start-storybook -p 6006",
"storybook:build": "rm -rf .out && npm run storybook:build:assets && npm run build:icon && npm run build:next:icon && build-storybook -o .out -s dist/public",
"storybook:build:test": "rm -rf storybook-static && npm run storybook:build:assets && npm run build:icon && npm run build:next:icon && build-storybook -o storybook-static -s dist/public",
"storybook": "storybook dev -p 6006",
"storybook:build": "rm -rf .out && yarn storybook:build:assets && yarn build:icon && yarn build:next:icon && sb build -o .out -s dist/public",
"storybook:build:test": "rm -rf storybook-static && yarn storybook:build:assets && yarn build:icon && yarn build:next:icon && storybook build -o storybook-static -s dist/public",
"storybook:build:assets": "webpack",
"prepare": "husky install",
"check-definition-files": "node checkDefinitionFiles.js"
Expand Down Expand Up @@ -59,12 +59,12 @@
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@playwright/test": "^1.29.0",
"@storybook/addon-actions": "^6.5.15",
"@storybook/addon-essentials": "^6.5.15",
"@storybook/addon-links": "^6.5.15",
"@storybook/builder-webpack5": "^6.5.15",
"@storybook/manager-webpack5": "^6.5.15",
"@storybook/react": "^6.5.15",
"@storybook/addon-actions": "^7.0.26",
"@storybook/addon-essentials": "^7.0.26",
"@storybook/addon-links": "^7.0.26",
"@storybook/addon-mdx-gfm": "^7.0.26",
"@storybook/react": "^7.0.26",
"@storybook/react-webpack5": "^7.0.26",
"@svgr/cli": "^6.5.1",
"@testing-library/dom": "^8.11.3",
"@testing-library/jest-dom": "^5.16.2",
Expand Down Expand Up @@ -100,6 +100,7 @@
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-storybook": "^0.6.12",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^1.3.4",
"generate-changelog": "^1.7.1",
Expand All @@ -117,6 +118,7 @@
"react-is": "^17.0.2",
"react-test-renderer": "^17.0.2",
"start-server-and-test": "^1.15.2",
"storybook": "^7.0.26",
"styled-components": "^5.1.1",
"stylelint": "^10.0.1",
"stylelint-config-recommended": "^2.2.0",
Expand Down
8 changes: 4 additions & 4 deletions src/@next/Bar/Bar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ const customActionGroupTemplate: Story<BarProps> = args => {
);
};

export const customActionGroup = customActionGroupTemplate.bind({});
customActionGroup.parameters = {
export const CustomActionGroup = customActionGroupTemplate.bind({});
CustomActionGroup.parameters = {
docs: {
source: {
code: `
const customActionGroup = (
const CustomActionGroup = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storybook plugin dictates that PascalCase should be used

<>
<PopoverMenu
title="Select"
Expand All @@ -238,7 +238,7 @@ customActionGroup.parameters = {
{...args}
heading={'Page Title 2'}
subheading={'Additional Content'}
customActionGroup={customActionGroup}
customActionGroup={CustomActionGroup}
/>
);
`,
Expand Down
8 changes: 4 additions & 4 deletions src/@next/Combobox/Combobox.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Meta, Story } from '@storybook/react';
import { Meta, StoryFn } from '@storybook/react';
import React from 'react';

import { withGlintsPortalContainer } from '../../helpers/storybook/Decorators';
import { Option, OptionList, TextInput } from './components';
import { Combobox, ComboboxProps } from './Combobox';
import { ComboboxMultiSelect } from './comboboxStoryHelper/ComboboxMultuSelect';
import { Option, OptionList, TextInput } from './components';

(Combobox as React.FunctionComponent<ComboboxProps>).displayName = 'Combobox';

Expand Down Expand Up @@ -32,7 +32,7 @@ const countries = [

const slicedCountries = countries.slice(0, 5);

const MultiSelectTemplate: Story<ComboboxProps> = args => (
const MultiSelectTemplate: StoryFn<ComboboxProps> = args => (
<ComboboxMultiSelect {...args} countries={slicedCountries} />
);

Expand Down Expand Up @@ -152,7 +152,7 @@ MultiSelect.parameters = {
},
};

const MultiSelectScrollableTemplate: Story<ComboboxProps> = args => (
const MultiSelectScrollableTemplate: StoryFn<ComboboxProps> = args => (
<ComboboxMultiSelect {...args} countries={countries} />
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const ComboboxMultiSelect = ({
}, [isSearchEmpty, options]);

return (
<div style={{ maxWidth: '500px' }}>
<div style={{ maxWidth: 500 }}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need to use non-unit number else it will have problem rendering this storybook

<Combobox.Label>Label</Combobox.Label>
<Combobox
{...args}
Expand Down
4 changes: 2 additions & 2 deletions src/@next/Divider/Divider.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Story } from '@storybook/react';
import { Meta } from '@storybook/react';
import React from 'react';

import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
Expand All @@ -12,7 +12,7 @@ export default {
decorators: [Story => <BaseContainer>{Story()}</BaseContainer>],
} as Meta;

const Template: Story<void> = () => (
const Template = () => (
<div>
some text
<Divider />
Expand Down
10 changes: 5 additions & 5 deletions src/@next/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Interactive.args = {
showCloseButton: true,
};

const WithLargeContentTemplate: Story<void> = () => {
const WithLargeContentTemplate = () => {
const [iOpen, setOpen] = useState(false);

useEffect(() => {
Expand Down Expand Up @@ -117,7 +117,7 @@ const WithLargeContentTemplate: Story<void> = () => {
export const WithLargeContent = WithLargeContentTemplate.bind({});
WithLargeContent.args = {};

const WithOverlflowContentTemplate: Story<void> = () => {
const WithOverlflowContentTemplate = () => {
const [iOpen, setOpen] = useState(false);

useEffect(() => {
Expand Down Expand Up @@ -376,7 +376,7 @@ WithLockedScrollableBackdrop.args = {
showCloseButton: true,
};

const WithSpinnerTemplate: Story<void> = () => {
const WithSpinnerTemplate = () => {
const [iOpen, setOpen] = useState(false);

useEffect(() => {
Expand Down Expand Up @@ -406,7 +406,7 @@ const WithSpinnerTemplate: Story<void> = () => {
export const WithSpinner = WithSpinnerTemplate.bind({});
WithSpinner.args = {};

const WithCustomActionsTemplate: Story<void> = () => {
const WithCustomActionsTemplate = () => {
const [showModal, setShowModal] = useState(false);
const triggerAlert = () => {
setShowModal(true);
Expand Down Expand Up @@ -442,7 +442,7 @@ const WithCustomActionsTemplate: Story<void> = () => {
export const WithCustomActions = WithCustomActionsTemplate.bind({});
WithCustomActions.args = {};

const WithNumberInputAndTooltipTemplate: Story<void> = () => {
const WithNumberInputAndTooltipTemplate = () => {
const [showModal, setShowModal] = useState(false);
const triggerAlert = () => {
setShowModal(true);
Expand Down
12 changes: 6 additions & 6 deletions src/@next/Modal/ModalWithProvider.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Meta, Story } from '@storybook/react';
import { Meta } from '@storybook/react';
import React from 'react';

import { Button } from '../Button';
import { useModal } from './useModal';
import { ModalWithProvider } from './ModalWithProvider';
import {
withGlintsPortalContainer,
withModalProvider,
} from '../../helpers/storybook/Decorators';
import { Button } from '../Button';
import { space16 } from '../utilities/spacing';
import { ModalWithProvider } from './ModalWithProvider';
import { useModal } from './useModal';

(ModalWithProvider as React.FunctionComponent<void>).displayName =
'ModalWithProvider';
Expand All @@ -18,7 +18,7 @@ export default {
component: ModalWithProvider,
} as Meta;

const Template: Story<void> = () => {
const Template = () => {
const { open: showModal } = useModal();

const primaryAction = {
Expand Down Expand Up @@ -106,7 +106,7 @@ Interactive.parameters = {
},
};

const WithLockedScrollableBackdropTemplate: Story<void> = () => {
const WithLockedScrollableBackdropTemplate = () => {
const { open: showModal } = useModal();

const primaryAction = {
Expand Down
8 changes: 5 additions & 3 deletions src/@next/Select/components/Activator/ActivatorSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { Blue, Neutral } from '../../../utilities/colors';
import {
StyledSelect,
StyledSelectTypography,
StyledTag,
TagsContainer,
} from './ActivatorStyle';
import { Tag } from '../../../Tag';
import { space8 } from '../../../utilities/spacing/Spacing';

export interface ActivatorSelectProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
Expand Down Expand Up @@ -76,13 +77,14 @@ export const ActivatorSelect = ({
if (hasSelectedValues) {
return (
<TagsContainer>
<StyledTag
<Tag
style={{ width: 28, marginRight: space8 }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somehow it will have error rendering this page if we use styled component of Tag in this page

so i have to not use styled component instead assign a style like the above to the tag

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm can we investigate this more? I don't think we should update the implementations to cater storybook upgrade

key={`option-${selectedValues[0]}`}
onRemove={onRemoveTag({ option: selectedValues[0] })}
textColor={Blue.S99}
>
{selectedLabels[0]}
</StyledTag>
</Tag>
{selectedValues.length > 1 && (
<Typography
variant="caption"
Expand Down
16 changes: 7 additions & 9 deletions src/@next/Select/components/Activator/ActivatorStyle.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import styled from 'styled-components';

import * as Breakpoints from '../../../utilities/breakpoints/Breakpoints';
import { TextInput } from '../../../TextInput';
import { Typography } from '../../../Typography';
import { borderRadius4 } from '../../../utilities/borderRadius';
import * as Breakpoints from '../../../utilities/breakpoints/Breakpoints';
import { Neutral, Red } from '../../../utilities/colors';
import { NotoSans } from '../../../utilities/fonts';
import { space8 } from '../../../utilities/spacing';
import { ActivatorSelectProps } from './ActivatorSelect';
import { TextInput } from '../../../TextInput';
import { Tag } from '../../../Tag';
import { Typography } from '../../../Typography';

export const StyledSelect = styled.button<ActivatorSelectProps>`
display: flex;
Expand Down Expand Up @@ -59,10 +57,10 @@ export const TagsContainer = styled.div`
align-items: center;
`;

export const StyledTag = styled(Tag)`
height: 28px;
margin-right: ${space8};
`;
// export const StyledTag = styled(Tag)`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keeping this because of the above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

// height: 28px;
// margin-right: ${space8};
// `;

export const StyledTextInput = styled(TextInput)`
width: ${props => props.width};
Expand Down
10 changes: 5 additions & 5 deletions src/@next/Tag/Tag.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Meta, Story } from '@storybook/react';
import { Meta, StoryFn } from '@storybook/react';
import React, { useCallback, useState } from 'react';

import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer';
Expand Down Expand Up @@ -54,11 +54,11 @@ export default {
},
} as Meta;

const DefaultTemplate: Story<TagProps> = args => {
const DefaultTemplate: StoryFn<TagProps> = args => {
return <Tag {...args}>Basic Tag</Tag>;
};

const RemoveableTemplate: Story<TagProps> = () => {
const RemoveableTemplate: StoryFn<TagProps> = () => {
const [selectedTags, setSelectedTags] = useState([
'Years of Experience: 0 to 3 Years, 3 to 5 Years',
'Expected Salary: $1.000.000 to $3.000.000',
Expand Down Expand Up @@ -87,15 +87,15 @@ const RemoveableTemplate: Story<TagProps> = () => {
return <>{tagMarkup}</>;
};

const ClickableTemplate: Story<TagProps> = args => {
const ClickableTemplate: StoryFn<TagProps> = args => {
return (
<Tag textColor={args.textColor} onClick={() => window.alert('Clicked')}>
Clickable Tag
</Tag>
);
};

const ClickableDisabledTemplate: Story<TagProps> = args => {
const ClickableDisabledTemplate: StoryFn<TagProps> = args => {
return (
<Tag
textColor={args.textColor}
Expand Down
4 changes: 2 additions & 2 deletions src/General/Divider/Divider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Template: Story<Props> = args => <Divider {...args} />;

export const Interactive = Template.bind({});

export const dividerWithGreyTheme = Template.bind({});
dividerWithGreyTheme.args = {
export const DividerWithGreyTheme = Template.bind({});
DividerWithGreyTheme.args = {
theme: 'grey',
};
4 changes: 2 additions & 2 deletions src/Input/Textarea/Textarea.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Interactive.args = {
label: 'Description',
};

export const removeFloatingLabelIsTrue = Template.bind({});
removeFloatingLabelIsTrue.args = {
export const RemoveFloatingLabelIsTrue = Template.bind({});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

storybook plugin dictates that PascalCase should be used

RemoveFloatingLabelIsTrue.args = {
label: 'Remove Floating Label Is True',
removeFloatingLabel: true,
};
2 changes: 1 addition & 1 deletion src/stories/Introduction.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta } from '@storybook/addon-docs';
const { version } = require('../../package.json');
import { version } from '../../package.json';
import { AriesStatus } from './story-components/AriesStatus';

<Meta title="Introduction" />
Expand Down
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/e2e/alert/alert.spec.ts-snapshots/alert-chromium-linux.png
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.
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.
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.
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.
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.
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.
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.
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.
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.
Binary file modified test/e2e/badge/badge.spec.ts-snapshots/badge-chromium-linux.png
Binary file modified test/e2e/banner/banner.spec.ts-snapshots/banner-chromium-linux.png
Binary file modified test/e2e/bar/bar.spec.ts-snapshots/bar-chromium-linux.png
Binary file modified test/e2e/card/card.spec.ts-snapshots/card-chromium-linux.png
Binary file modified test/e2e/link/link.spec.ts-snapshots/link-chromium-linux.png
Binary file modified test/e2e/modal/modal.spec.ts-snapshots/modal-chromium-linux.png
Loading