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

Storybook show code fix #117

Merged
merged 28 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ba410e5
Show code showing actual code in layout Storybook.
ogjtech Mar 25, 2021
de91ee2
Show code showing actual code in navigation Storybook.
ogjtech Mar 25, 2021
12da8eb
Show code showing actual code in surfaces Storybook.
ogjtech Mar 25, 2021
11313c8
Show code showing actual code in data display Storybook.
ogjtech Mar 25, 2021
75a607e
Show code showing actual code in input Storybook.
ogjtech Mar 25, 2021
c1dfeb0
Experimental commit, providing different types of code docs per compo…
ogjtech Apr 3, 2021
7f9b9ee
Redefined code examples of components based on best possible overview
ogjtech Apr 3, 2021
5a124ee
Experimental commit: Show possibility of providing custom code docume…
MCarsjensGX Apr 9, 2021
17c179b
Experimental commit: custom code docs per component.
ogjtech Apr 10, 2021
c153c8a
Applied per-component docs specification for input components.
ogjtech Apr 17, 2021
f36e4cd
Applied per-component code doc specs to layout components.
ogjtech Apr 17, 2021
e47060a
Applied per-component code doc specs to navigation components.
ogjtech Apr 17, 2021
8e846c5
Applied per-component code doc specs to surface components.
ogjtech Apr 17, 2021
bc171aa
Merge remote-tracking branch 'origin/development' into storybook_show…
ogjtech Apr 17, 2021
26b806c
Shortened import
ogjtech Apr 17, 2021
cb63f06
Merge remote-tracking branch 'origin/storybook_show_code_fix' into st…
ogjtech Apr 24, 2021
eb0fcbf
Defined custom code in separate variable to fix indentation
ogjtech Apr 24, 2021
b707fcc
Defined custom code in separate variable to fix indentation for input…
ogjtech Apr 24, 2021
86f2620
Defined custom code in separate variable to fix indentation for navig…
ogjtech Apr 24, 2021
ab9ef0d
Defined custom code in separate variable to fix indentation for navig…
ogjtech Apr 24, 2021
49808df
Defined custom code in separate variable to fix indentation for surfa…
ogjtech Apr 24, 2021
3f39bd8
Fixed indendation for surfaces.. Again...
ogjtech Apr 24, 2021
bf48d2a
Fixed indendation for navigation.. Again...
ogjtech Apr 24, 2021
bb98908
Fixed indendation for layout.. Again...
ogjtech Apr 24, 2021
2ebfa87
Fixed indendation for input.. Again...
ogjtech Apr 24, 2021
f0bf340
Fixed indendation for datadisplay.. Again...
ogjtech Apr 24, 2021
26c5029
Prettifier go brrr
ogjtech Apr 24, 2021
e48e182
Prettifier go brrr and also fixed indentation again because Checkboxe…
ogjtech Apr 24, 2021
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
1 change: 1 addition & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
format: false
};
29 changes: 17 additions & 12 deletions src/stories/datadisplay/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import Avatar, { AvatarProps } from "../../components/Avatar";
import pkg from "../../components/Avatar/package.json";
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { Avatar, AvatarProps } from '../../components/Avatar';
import pkg from '../../components/Avatar/package.json';

export default {
title: "Components/Data Display/Avatar",
title: 'Components/Data Display/Avatar',
parameters: {
componentSubtitle: `${pkg.name} - ${pkg.version}`
componentSubtitle: `${pkg.name} - ${pkg.version}`,
docs: {
source: {
type: 'dynamic',
},
},
},
component: Avatar
component: Avatar,
} as Meta;

const Template: Story<AvatarProps> = (args: any) => <Avatar {...args} />;
const Template: Story<AvatarProps> = (args: AvatarProps) => <Avatar {...args} />;

/**
* Implementation of Avatar
*/
export const Default = Template.bind({});
Default.args = {
src: "https://c1.staticflickr.com/9/8486/8245351490_2746ef972c_b.jpg",
alt: "Planet Earth"
src: 'https://c1.staticflickr.com/9/8486/8245351490_2746ef972c_b.jpg',
alt: 'Planet Earth',
};

/**
* Implementation of Avatar using a Letter
*/
export const Letter = Template.bind({});
Letter.args = {
children: "DH"
children: 'DH',
};

/**
Expand All @@ -36,5 +41,5 @@ Letter.args = {
export const Squared = Template.bind({});
Squared.args = {
...Default.args,
variant: "square"
variant: 'square',
};
29 changes: 17 additions & 12 deletions src/stories/datadisplay/AvatarGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import Avatar from "../../components/Avatar";
import AvatarGroup, { AvatarGroupProps } from "../../components/AvatarGroup";
import pkg from "../../components/AvatarGroup/package.json";
import React from 'react';
import { Meta, Story } from '@storybook/react';
import Avatar from '../../components/Avatar';
import AvatarGroup, { AvatarGroupProps } from '../../components/AvatarGroup';
import pkg from '../../components/AvatarGroup/package.json';

export default {
title: "Components/Data Display/AvatarGroup",
title: 'Components/Data Display/AvatarGroup',
parameters: {
componentSubtitle: `${pkg.name} - ${pkg.version}`
componentSubtitle: `${pkg.name} - ${pkg.version}`,
docs: {
source: {
type: 'dynamic',
},
},
},
component: AvatarGroup
component: AvatarGroup,
} as Meta;

const Template: Story<AvatarGroupProps> = (args: any) => (
const Template: Story<AvatarGroupProps> = (args: AvatarGroupProps) => (
<AvatarGroup {...args}>
<Avatar src={"https://c1.staticflickr.com/9/8486/8245351490_2746ef972c_b.jpg"} alt="Planet Earth" />
<Avatar src={'https://c1.staticflickr.com/9/8486/8245351490_2746ef972c_b.jpg'} alt="Planet Earth" />
<Avatar>DH</Avatar>
<Avatar
src={"https://images.fineartamerica.com/images/artworkimages/mediumlarge/1/the-portal-aged-pixel.jpg"}
src={'https://images.fineartamerica.com/images/artworkimages/mediumlarge/1/the-portal-aged-pixel.jpg'}
alt="Woman staring into a portal"
/>
</AvatarGroup>
Expand All @@ -33,5 +38,5 @@ export const Default = Template.bind({});
*/
export const SmallSpacing = Template.bind({});
SmallSpacing.args = {
spacing: "small"
spacing: 'small',
};
72 changes: 56 additions & 16 deletions src/stories/datadisplay/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import Badge, { BadgeProps } from "../../components/Badge";
import MailIcon from "@material-ui/icons/Mail";
import pkg from "../../components/Badge/package.json";
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { Badge, BadgeProps } from '../../components/Badge';
import MailIcon from '@material-ui/icons/Mail';
import pkg from '../../components/Badge/package.json';

export default {
title: "Components/Data Display/Badge",
title: 'Components/Data Display/Badge',
parameters: {
componentSubtitle: `${pkg.name} - ${pkg.version}`
componentSubtitle: `${pkg.name} - ${pkg.version}`,
docs: {
source: {
type: 'code',
},
},
},
component: Badge
component: Badge,
} as Meta;

const Template: Story<BadgeProps> = (args: any) => (
const Template: Story<BadgeProps> = (args: BadgeProps) => (
<Badge {...args}>
<MailIcon />
</Badge>
Expand All @@ -23,32 +28,67 @@ const Template: Story<BadgeProps> = (args: any) => (
*/
export const Default = Template.bind({});
Default.args = {
badgeContent: 4
badgeContent: 4,
};

Default.parameters = {
docs: {
source: {
// language=HTML
code: `<Badge badgeContent={4}><MailIcon /></Badge>`,
},
},
};

/**
* Badge having the primary colour.
*/
export const PrimaryColoured = Template.bind({});
PrimaryColoured.args = {
color: "primary",
...Default.args
color: 'primary',
...Default.args,
};

PrimaryColoured.parameters = {
docs: {
source: {
// language=HTML
code: `<Badge badgeContent={4} color={'primary'}><MailIcon /></Badge>`,
},
},
};

/**
* Badge with circled overlap.
*/
export const CircleOverlap = Template.bind({});
CircleOverlap.args = {
overlap: "circle",
...PrimaryColoured.args
overlap: 'circle',
...PrimaryColoured.args,
};

CircleOverlap.parameters = {
docs: {
source: {
// language=HTML
code: `<Badge badgeContent={4} color={'primary'} overlap={'circle'}><MailIcon /></Badge>`,
},
},
};

/**
* Badge using the dot variant.
*/
export const DotVariant = Template.bind({});
DotVariant.args = {
variant: "dot",
...PrimaryColoured.args
variant: 'dot',
...PrimaryColoured.args,
};

DotVariant.parameters = {
docs: {
source: {
code: `<Badge badgeContent={4} color={'primary'} variant={'dot'}><MailIcon /></Badge>`,
},
},
};
137 changes: 123 additions & 14 deletions src/stories/datadisplay/Divider.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import React from "react";
import { Meta, Story } from "@storybook/react";
import Divider, { DividerProps } from "../../components/Divider";
import pkg from "../../components/Divider/package.json";
import List, { ListItem, ListItemIcon, ListItemText } from "../../components/List";
import InboxIcon from "@material-ui/icons/Inbox";
import DraftsIcon from "@material-ui/icons/Drafts";
import React from 'react';
import { Meta, Story } from '@storybook/react';
import { Divider, DividerProps } from '../../components/Divider';
import pkg from '../../components/Divider/package.json';
import { List, ListItem, ListItemIcon, ListItemText } from '../../components/List';
import InboxIcon from '@material-ui/icons/Inbox';
import DraftsIcon from '@material-ui/icons/Drafts';

export default {
title: "Components/Data Display/Divider",
title: 'Components/Data Display/Divider',
parameters: {
componentSubtitle: `${pkg.name} - ${pkg.version}`
componentSubtitle: `${pkg.name} - ${pkg.version}`,
docs: {
source: {
type: 'dynamic',
},
},
},
component: Divider
component: Divider,
} as Meta;

const Template: Story<DividerProps> = (args: any) => (
const Template: Story<DividerProps> = (args: DividerProps) => (
<List>
<ListItem button>
<ListItemIcon>
Expand All @@ -32,31 +37,135 @@ const Template: Story<DividerProps> = (args: any) => (
</List>
);

// language=JS
const defaultCode = `
<List>
<ListItem button>
<ListItemIcon>
<InboxIcon/>
</ListItemIcon>
<ListItemText primary="I am above the divider."/>
</ListItem>
<Divider/>
<ListItem button>
<ListItemIcon>
<DraftsIcon/>
</ListItemIcon>
<ListItemText primary="I am under the divider."/>
</ListItem>
</List>
`;

// language=JS
const insetCode = `
<List>
<ListItem button>
<ListItemIcon>
<InboxIcon/>
</ListItemIcon>
<ListItemText primary="I am above the divider."/>
</ListItem>
<Divider variant="inset"/>
<ListItem button>
<ListItemIcon>
<DraftsIcon/>
</ListItemIcon>
<ListItemText primary="I am under the divider."/>
</ListItem>
</List>
`;

// language=JS
const lightCode = `
<List>
<ListItem button>
<ListItemIcon>
<InboxIcon/>
</ListItemIcon>
<ListItemText primary="I am above the divider."/>
</ListItem>
<Divider light/>
<ListItem button>
<ListItemIcon>
<DraftsIcon/>
</ListItemIcon>
<ListItemText primary="I am under the divider."/>
</ListItem>
</List>
`;

// language=JS
const absoluteCode = `
<List>
<ListItem button>
<ListItemIcon>
<InboxIcon/>
</ListItemIcon>
<ListItemText primary="I am above the divider."/>
</ListItem>
<Divider absolute/>
<ListItem button>
<ListItemIcon>
<DraftsIcon/>
</ListItemIcon>
<ListItemText primary="I am under the divider."/>
</ListItem>
</List>
`;

/**
* Implementation of Divider.
*/
export const Default = Template.bind({});
Default.parameters = {
docs: {
source: {
code: defaultCode,
},
},
};

/**
* Divider in the inset variant.
*/
export const InsetVariant = Template.bind({});
InsetVariant.args = {
variant: "inset"
variant: 'inset',
};
InsetVariant.parameters = {
docs: {
source: {
code: insetCode,
},
},
};

/**
* Divider with a lighter colour.
*/
export const LightColoured = Template.bind({});
LightColoured.args = {
light: true
light: true,
};
LightColoured.parameters = {
docs: {
source: {
code: lightCode,
},
},
};

/**
* Divider with an absolute position.
*/
export const AbsolutePosition = Template.bind({});
AbsolutePosition.args = {
absolute: true
absolute: true,
};
AbsolutePosition.parameters = {
docs: {
source: {
code: absoluteCode,
},
},
};
Loading