Skip to content
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

📝 Added/Improved Storybook #256

Merged
merged 31 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6973f1d
:bug: Fixed onClose not running when clicking close button
mariush2 Jul 21, 2023
9a132ac
:memo: Updated ConfirmationPopup story
mariush2 Jul 21, 2023
9d1f865
:memo: Updated HourglassProgress story
mariush2 Jul 21, 2023
e33c087
:memo: Updated SkeletonBase story
mariush2 Jul 21, 2023
3820063
:memo: Updated Stepper story
mariush2 Jul 21, 2023
ca4150a
:memo: Updated EquinorLogo story
mariush2 Jul 21, 2023
697434c
:bug: Fixed CommentField focus-within still showing outline
mariush2 Jul 21, 2023
61bf189
:recycle: Refactored CopyText
mariush2 Jul 21, 2023
9f083a6
:memo: Updated NewCommentField story
mariush2 Jul 21, 2023
83a3ebf
:bug: Fixed outline still visible on EditableField focus
mariush2 Jul 21, 2023
f0bf4a9
:memo: Added text which says the component is deprecated for FieldSel…
mariush2 Jul 21, 2023
6e88178
:memo: Added description for FileUploadArea 'accept' prop
mariush2 Jul 21, 2023
1dde621
:memo: Added args to IconToggleButton story
mariush2 Jul 21, 2023
5d467ff
:memo: Added missing hooks to storybook documentation
mariush2 Jul 21, 2023
244ec08
:memo: Added PageMenuProvider to providers docs
mariush2 Jul 21, 2023
3a8cdfa
:rotating_light: Fixed linter errors caused by CopyText not having 'i…
mariush2 Jul 24, 2023
b835ddc
:white_check_mark: Updated uses of faker.betweens in sortByDate test
mariush2 Jul 24, 2023
139879d
:package: Removed coverage-c8 and added the new coverage-v8
mariush2 Jul 24, 2023
69f2458
:arrow_up: Upgraded storybook to 7.1.x
mariush2 Jul 24, 2023
fbe95bc
:wrench: Added react-docgen to storybook (shows prop types)
mariush2 Jul 24, 2023
20c9a0e
:memo: Added description to CommentField story
mariush2 Jul 24, 2023
816d7a6
:bug: Fixed bad width in CopyText wrapper
mariush2 Jul 24, 2023
2640639
:recycle: Renamed IStep -> Step in Tutorial component
mariush2 Jul 24, 2023
12fd852
:memo: Added description to OptionalTooltip story
mariush2 Jul 24, 2023
65d2d3d
:memo: Added story to InfoElement stories
mariush2 Jul 24, 2023
ff78ae8
:recycle: Changed ProfileAvatar so name with only 1 word returns only…
mariush2 Jul 24, 2023
3339cfb
:memo: Added story to ProfileAvatar stories
mariush2 Jul 24, 2023
0429837
:memo: Added "Re-run animation" button to AnimatedCheckmark.stories.tsx
mariush2 Jul 24, 2023
293a32d
:memo: Fixed FullPageSpinner story width/height
mariush2 Jul 24, 2023
1f4a746
:memo: Made SideBar stories fullscreen
mariush2 Jul 25, 2023
88c2c85
:bookmark: 4.2.0
mariush2 Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ module.exports = {
'../src/intro.stories.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx|mdx)',
],
addons: [
'@storybook/addon-docs',
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-mdx-gfm',
],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
typescript: {
reactDocgen: 'none',
reactDocgen: 'react-docgen-typescript',
},
build: {
sourcemap: false,
Expand All @@ -22,4 +17,5 @@ module.exports = {
docs: {
autodocs: true,
},
staticDirs: ['../static'],
};
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/amplify-components",
"version": "4.1.2",
"version": "4.2.0",
"description": "Frontend Typescript components for the Amplify team",
"main": "dist/index.js",
"types": "dist/types/index.d.ts",
Expand All @@ -19,7 +19,7 @@
],
"sideEffects": false,
"scripts": {
"start": "NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6006 -s public",
"start": "NODE_OPTIONS=--openssl-legacy-provider && storybook dev -p 6006",
"build-storybook": "NODE_OPTIONS='--openssl-legacy-provider --max-old-space-size=2048' storybook build",
"setup": "yarn",
"pretty": "prettier --check ./src",
Expand Down Expand Up @@ -73,14 +73,14 @@
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-terser": "^0.4.3",
"@rollup/plugin-typescript": "^11.1.1",
"@storybook/addon-actions": "^7.0.22",
"@storybook/addon-docs": "^7.0.22",
"@storybook/addon-essentials": "^7.0.22",
"@storybook/addon-links": "^7.0.22",
"@storybook/addons": "^7.0.22",
"@storybook/node-logger": "^7.0.22",
"@storybook/react": "^7.0.22",
"@storybook/react-vite": "^7.0.22",
"@storybook/addon-actions": "^7.1.0",
"@storybook/addon-docs": "^7.1.0",
"@storybook/addon-essentials": "^7.1.0",
"@storybook/addon-links": "^7.1.0",
"@storybook/addons": "^7.1.0",
"@storybook/node-logger": "^7.1.0",
"@storybook/react": "^7.1.0",
"@storybook/react-vite": "^7.1.0",
"@tanstack/react-query": "^4.29.14",
"@testing-library/dom": "^9.3.1",
"@testing-library/jest-dom": "^5.16.5",
Expand All @@ -103,12 +103,12 @@
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"@vitejs/plugin-react": "^4.0.1",
"@vitest/coverage-c8": "^0.32.2",
"@vitest/coverage-v8": "^0.33.0",
"eslint": "^8.43.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-storybook": "^0.6.12",
"eslint-plugin-storybook": "^0.6.13",
"jest-styled-components": "^7.1.1",
"jsdom": "^22.1.0",
"ora": "^6.3.1",
Expand All @@ -120,7 +120,7 @@
"resize-observer-polyfill": "^1.5.1",
"rollup": "^3.25.1",
"rollup-plugin-delete": "^2.0.0",
"storybook": "^7.0.22",
"storybook": "^7.1.0",
"storybook-addon-react-router-v6": "^1.0.2",
"styled-components": "^5.3.11",
"typescript": "^5.1.3",
Expand Down
3 changes: 3 additions & 0 deletions src/components/DataDisplay/InfoElement.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ const Template: StoryFn<InfoElementProps> = (args) => <InfoElement {...args} />;

export const Primary = Template.bind({});
Primary.args = {};

export const WithCopyTextTrue = Template.bind({});
WithCopyTextTrue.args = { copyableContent: true, copyBackground: '#ffffff' };
6 changes: 3 additions & 3 deletions src/components/DataDisplay/InfoElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ export interface InfoElementProps {
content: ReactElement | string;
capitalizeContent?: boolean;
copyableContent?: boolean;
copyIconRightPos?: string;
copyBackground?: string;
}

const InfoElement = forwardRef<HTMLDivElement, InfoElementProps>(
(
{ title, content, copyableContent, capitalizeContent, copyIconRightPos },
{ title, content, copyableContent, capitalizeContent, copyBackground },
ref
) => {
const contentElement =
Expand All @@ -28,7 +28,7 @@ const InfoElement = forwardRef<HTMLDivElement, InfoElementProps>(
</Typography>
{typeof content === 'string' ? (
copyableContent ? (
<CopyText iconRightPos={copyIconRightPos} textToCopy={content}>
<CopyText hoverBackground={copyBackground} textToCopy={content}>
<Typography variant="h6">{contentElement}</Typography>
</CopyText>
) : (
Expand Down
8 changes: 8 additions & 0 deletions src/components/DataDisplay/OptionalTooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export default {
component: OptionalTooltip,
argTypes: { title: { control: 'text' } },
args: { title: 'Optional tooltip title' },
parameters: {
docs: {
description: {
component:
'This component enables us to show a tooltip optionally, so if the title is either null or empty it hides the tooltip',
},
},
},
} as Meta;

export const Primary: StoryFn = (args) => (
Expand Down
6 changes: 6 additions & 0 deletions src/components/DataDisplay/ProfileAvatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ export const Primary: StoryFn = (args) => {
/>
);
};

export const WithoutImage: StoryFn = (args) => {
return (
<ProfileAvatar size={args.size} name={args.name} disabled={args.disabled} />
);
};
2 changes: 1 addition & 1 deletion src/components/DataDisplay/ProfileAvatar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ test('Name parser works as expected when given name with 1 word', () => {

const initials = nameToInitials(firstName);

expect(initials).toBe(firstName[0] + '.');
expect(initials).toBe(firstName[0]);
});
2 changes: 1 addition & 1 deletion src/components/DataDisplay/ProfileAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function nameToInitials(name: string) {
};

if (splitNames.length === 1 && splitNames[0] !== '') {
return splitNames[0].charAt(0) + '.';
return splitNames[0].charAt(0);
}

if (lastNameCommaFirstName) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/DataDisplay/Tutorial/Tutorial.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { Typography } from '@equinor/eds-core-react';
import { Meta, StoryFn } from '@storybook/react';

import { TutorialStepsProvider } from '../../../providers';
import Tutorial, { IStep, TutorialProps } from './Tutorial';
import Tutorial, { Step, TutorialProps } from './Tutorial';
import TutorialStoryComponent from './TutorialStoryComponent';

export default {
title: 'DataDisplay/Tutorial',
component: Tutorial,
} as Meta;

const steps: IStep[] = [
const steps: Step[] = [
{
key: 'step-one',
title: 'Field',
Expand Down
6 changes: 3 additions & 3 deletions src/components/DataDisplay/Tutorial/Tutorial.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { faker } from '@faker-js/faker';

import TutorialStepsProvider from '../../../providers/TutorialStepsProvider';
import { render, screen, userEvent } from '../../../tests/test-utils';
import Tutorial, { IStep, TutorialProps } from './Tutorial';
import Tutorial, { Step, TutorialProps } from './Tutorial';

function fakeStep(): IStep {
function fakeStep(): Step {
return {
key: faker.string.uuid(),
title: faker.animal.dog(),
Expand All @@ -14,7 +14,7 @@ function fakeStep(): IStep {
}

function fakeProps(withImage = false): TutorialProps {
const steps: IStep[] = [];
const steps: Step[] = [];
for (let i = 0; i < faker.number.int({ min: 2, max: 10 }); i++) {
steps.push(fakeStep());
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/DataDisplay/Tutorial/Tutorial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { useTutorialSteps } from '../../../providers/TutorialStepsProvider';
import TutorialStart from './TutorialStart';
import TutorialSteps from './TutorialSteps';

export interface IStep {
export interface Step {
key: string;
title: string;
body: ReactElement;
button: string;
}

export type TutorialProps = {
steps: IStep[];
steps: Step[];
tutorialTitle: string;
imageSource?: string;
tutorialIntro: string;
Expand Down
4 changes: 2 additions & 2 deletions src/components/DataDisplay/Tutorial/TutorialSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { Button, Dialog as EDSDialog } from '@equinor/eds-core-react';
import { tokens } from '@equinor/eds-tokens';

import { useTutorialSteps } from '../../../providers/TutorialStepsProvider';
import { IStep } from './Tutorial';
import { Step } from './Tutorial';

import styled, { keyframes } from 'styled-components';
const { colors, spacings } = tokens;

type TutorialStepsProps = {
show: boolean;
onClose: () => void;
steps: IStep[];
steps: Step[];
};

const spawn = keyframes`
Expand Down
40 changes: 39 additions & 1 deletion src/components/Feedback/AnimatedCheckmark.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
import { useState } from 'react';

import { Button } from '@equinor/eds-core-react';
import { StoryFn } from '@storybook/react';

import AnimatedCheckmark from './AnimatedCheckmark';

import styled from 'styled-components';

export default {
title: 'Feedback/AnimatedCheckmark',
component: AnimatedCheckmark,
parameters: {
docs: {
description: {
component:
'Renders an AnimatedCheckMark on initial render, to re-run the animation the component needs to be re-rendered',
},
},
},
};

export const Primary: StoryFn = () => <AnimatedCheckmark />;
const Container = styled.div`
display: grid;
grid-template-rows: 170px auto;
> button {
grid-row: 2;
width: fit-content;
}
`;

export const Primary: StoryFn = () => {
const [show, setShow] = useState(true);

const handleRerun = () => {
setShow(false);
setTimeout(() => {
setShow(true);
}, 100);
};

return (
<Container>
{show && <AnimatedCheckmark />}
<Button onClick={handleRerun}>Re-run animation</Button>
</Container>
);
};
36 changes: 26 additions & 10 deletions src/components/Feedback/ConfirmationPopup.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useState } from 'react';

import { Button } from '@equinor/eds-core-react';
import { StoryFn } from '@storybook/react';

Expand All @@ -7,7 +9,6 @@ export default {
title: 'Feedback/ConfirmationPopup',
component: ConfirmationPopup,
argTypes: {
show: { control: 'boolean' },
title: {
control: 'text',
},
Expand All @@ -18,26 +19,41 @@ export default {
action: 'Ran onClose',
},
actions: {
control: 'array',
description: 'Array with buttons',
},
width: {
control: 'text',
},
},
args: {
show: true,
title: 'This is the title',
body: 'This is the body',
actions: [
<Button key="A1" variant="ghost" color="secondary">
Cancel
</Button>,
<Button key="A2">Action</Button>,
],
width: '400px',
},
};

export const Primary: StoryFn<ConfirmationPopupProps> = (args) => {
return <ConfirmationPopup {...args} />;
const [show, setShow] = useState(false);

const handleOpen = () => setShow(true);
const handleOnClose = () => setShow(false);

return (
<>
<Button onClick={handleOpen}>Open confirmation popup</Button>
<ConfirmationPopup
{...args}
show={show}
onClose={handleOnClose}
actions={[
<Button key="cancel" variant="ghost" onClick={handleOnClose}>
Cancel
</Button>,
<Button key="continue " onClick={handleOnClose}>
Continue
</Button>,
]}
/>
</>
);
};
4 changes: 2 additions & 2 deletions src/components/Feedback/ConfirmationPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const ConfirmationPopup = forwardRef<HTMLDivElement, ConfirmationPopupProps>(
<StyledDialog ref={ref} open={show} style={{ width }}>
<DialogHeader data-testid="dialog-header">
{title}
<Button variant="ghost_icon">
<Icon data={close} onClick={onClose} />
<Button variant="ghost_icon" onClick={onClose}>
<Icon data={close} />
</Button>
</DialogHeader>
<Dialog.CustomContent>
Expand Down
8 changes: 5 additions & 3 deletions src/components/Feedback/FullPageSpinner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ export default {
args: {
variant: undefined,
},
parameters: {
layout: 'fullscreen',
},
} as Meta;

const Container = styled.div`
width: 100%;
height: 100%;
aspect-ratio: 16 / 9;
overflow: hidden;

& > div {
width: 100%;
height: 100%;
position: none;
}
`;

Expand Down
Loading