@storybook/components 5.2.1 → 5.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html.js +1 -1
- package/dist/typography/DocumentFormatting.js +2 -1
- package/dist/typography/DocumentWrapper.js +2 -2
- package/package.json +11 -5
- package/src/ActionBar/ActionBar.stories.tsx +0 -41
- package/src/ActionBar/ActionBar.tsx +0 -75
- package/src/Badge/Badge.stories.tsx +0 -11
- package/src/Badge/Badge.tsx +0 -68
- package/src/Button/Button.stories.tsx +0 -53
- package/src/Button/Button.tsx +0 -256
- package/src/ScrollArea/ScrollArea.stories.tsx +0 -85
- package/src/ScrollArea/ScrollArea.tsx +0 -62
- package/src/ScrollArea/ScrollAreaStyles.tsx +0 -166
- package/src/addon-panel/addon-panel.tsx +0 -33
- package/src/bar/bar.tsx +0 -93
- package/src/bar/button.ts +0 -89
- package/src/bar/separator.tsx +0 -39
- package/src/blocks/BlockBackgroundStyles.tsx +0 -9
- package/src/blocks/ColorPalette.stories.tsx +0 -29
- package/src/blocks/ColorPalette.tsx +0 -168
- package/src/blocks/Description.stories.tsx +0 -15
- package/src/blocks/Description.tsx +0 -18
- package/src/blocks/DocsPage.stories.tsx +0 -67
- package/src/blocks/DocsPage.tsx +0 -81
- package/src/blocks/DocsPageExampleCaption.md +0 -93
- package/src/blocks/DocsPageExampleCaption.mdx +0 -93
- package/src/blocks/EmptyBlock.stories.tsx +0 -9
- package/src/blocks/EmptyBlock.tsx +0 -23
- package/src/blocks/IFrame.tsx +0 -60
- package/src/blocks/IconGallery.stories.tsx +0 -32
- package/src/blocks/IconGallery.tsx +0 -72
- package/src/blocks/Preview.stories.tsx +0 -96
- package/src/blocks/Preview.tsx +0 -162
- package/src/blocks/PropsTable/PropDef.ts +0 -7
- package/src/blocks/PropsTable/PropRow.stories.tsx +0 -113
- package/src/blocks/PropsTable/PropRow.tsx +0 -102
- package/src/blocks/PropsTable/PropsTable.stories.tsx +0 -14
- package/src/blocks/PropsTable/PropsTable.tsx +0 -169
- package/src/blocks/Source.stories.tsx +0 -36
- package/src/blocks/Source.tsx +0 -72
- package/src/blocks/Story.stories.tsx +0 -25
- package/src/blocks/Story.tsx +0 -115
- package/src/blocks/Toolbar.tsx +0 -85
- package/src/blocks/Typeset.stories.tsx +0 -16
- package/src/blocks/Typeset.tsx +0 -68
- package/src/blocks/ZoomContext.tsx +0 -5
- package/src/blocks/index.ts +0 -10
- package/src/brand/StorybookIcon.stories.tsx +0 -6
- package/src/brand/StorybookIcon.tsx +0 -26
- package/src/brand/StorybookLogo.stories.tsx +0 -10
- package/src/brand/StorybookLogo.tsx +0 -33
- package/src/form/field/field.tsx +0 -42
- package/src/form/form.stories.tsx +0 -133
- package/src/form/index.tsx +0 -18
- package/src/form/input/input.tsx +0 -178
- package/src/html.tsx +0 -12
- package/src/icon/icon.stories.tsx +0 -77
- package/src/icon/icon.tsx +0 -22
- package/src/icon/icons.tsx +0 -310
- package/src/icon/svg.tsx +0 -24
- package/src/index.ts +0 -37
- package/src/placeholder/placeholder.stories.tsx +0 -24
- package/src/placeholder/placeholder.tsx +0 -25
- package/src/spaced/Spaced.stories.tsx +0 -72
- package/src/spaced/Spaced.tsx +0 -69
- package/src/syntaxhighlighter/formatter.test.js +0 -90
- package/src/syntaxhighlighter/formatter.ts +0 -26
- package/src/syntaxhighlighter/syntaxhighlighter.stories.tsx +0 -136
- package/src/syntaxhighlighter/syntaxhighlighter.tsx +0 -165
- package/src/tabs/tabs.stories.tsx +0 -207
- package/src/tabs/tabs.tsx +0 -252
- package/src/tooltip/ListItem.stories.tsx +0 -35
- package/src/tooltip/ListItem.tsx +0 -245
- package/src/tooltip/Tooltip.stories.tsx +0 -42
- package/src/tooltip/Tooltip.tsx +0 -146
- package/src/tooltip/TooltipLinkList.stories.tsx +0 -52
- package/src/tooltip/TooltipLinkList.tsx +0 -49
- package/src/tooltip/TooltipMessage.stories.tsx +0 -37
- package/src/tooltip/TooltipMessage.tsx +0 -67
- package/src/tooltip/TooltipNote.stories.tsx +0 -15
- package/src/tooltip/TooltipNote.tsx +0 -25
- package/src/tooltip/WithTooltip.stories.tsx +0 -85
- package/src/tooltip/WithTooltip.tsx +0 -159
- package/src/typings.d.ts +0 -4
- package/src/typography/DocumentFormatting.tsx +0 -355
- package/src/typography/DocumentFormattingSample.md +0 -127
- package/src/typography/DocumentWrapper.stories.tsx +0 -190
- package/src/typography/DocumentWrapper.tsx +0 -441
- package/src/typography/link/link.stories.tsx +0 -67
- package/src/typography/link/link.test.tsx +0 -108
- package/src/typography/link/link.tsx +0 -223
- package/src/typography/typography.stories.tsx +0 -111
- package/src/typography/withReset.tsx +0 -12
- package/tsconfig.json +0 -18
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { styled } from '@storybook/theming';
|
|
3
|
-
import { opacify, transparentize } from 'polished';
|
|
4
|
-
import { PropRow } from './PropRow';
|
|
5
|
-
import { PropDef } from './PropDef';
|
|
6
|
-
import { EmptyBlock } from '../EmptyBlock';
|
|
7
|
-
import { ResetWrapper } from '../../typography/DocumentFormatting';
|
|
8
|
-
|
|
9
|
-
export const Table = styled.table<{}>(({ theme }) => ({
|
|
10
|
-
'&&': {
|
|
11
|
-
// Resets for cascading/system styles
|
|
12
|
-
borderCollapse: 'collapse',
|
|
13
|
-
borderSpacing: 0,
|
|
14
|
-
color: theme.color.defaultText,
|
|
15
|
-
tr: {
|
|
16
|
-
border: 'none',
|
|
17
|
-
background: 'none',
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
'td, th': {
|
|
21
|
-
padding: 0,
|
|
22
|
-
border: 'none',
|
|
23
|
-
},
|
|
24
|
-
// End Resets
|
|
25
|
-
|
|
26
|
-
fontSize: theme.typography.size.s2,
|
|
27
|
-
lineHeight: '20px',
|
|
28
|
-
textAlign: 'left',
|
|
29
|
-
width: '100%',
|
|
30
|
-
|
|
31
|
-
// Margin collapse
|
|
32
|
-
marginTop: '25px',
|
|
33
|
-
marginBottom: '40px',
|
|
34
|
-
|
|
35
|
-
'th:first-of-type, td:first-of-type': {
|
|
36
|
-
paddingLeft: 20,
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
'th:last-of-type, td:last-of-type': {
|
|
40
|
-
paddingRight: '20px',
|
|
41
|
-
width: '20%',
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
th: {
|
|
45
|
-
color:
|
|
46
|
-
theme.base === 'light'
|
|
47
|
-
? transparentize(0.4, theme.color.defaultText)
|
|
48
|
-
: transparentize(0.6, theme.color.defaultText),
|
|
49
|
-
paddingTop: 10,
|
|
50
|
-
paddingBottom: 10,
|
|
51
|
-
|
|
52
|
-
'&:not(:first-of-type)': {
|
|
53
|
-
paddingLeft: 15,
|
|
54
|
-
paddingRight: 15,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
td: {
|
|
59
|
-
paddingTop: '16px',
|
|
60
|
-
paddingBottom: '16px',
|
|
61
|
-
|
|
62
|
-
'&:not(:first-of-type)': {
|
|
63
|
-
paddingLeft: 15,
|
|
64
|
-
paddingRight: 15,
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
'&:last-of-type': {
|
|
68
|
-
paddingRight: '20px',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
// Table "block" styling
|
|
73
|
-
// Emphasize tbody's background and set borderRadius
|
|
74
|
-
// Calling out because styling tables is finicky
|
|
75
|
-
|
|
76
|
-
// Makes border alignment consistent w/other DocBlocks
|
|
77
|
-
marginLeft: 1,
|
|
78
|
-
marginRight: 1,
|
|
79
|
-
|
|
80
|
-
'tr:first-child td:first-child': {
|
|
81
|
-
borderTopLeftRadius: theme.appBorderRadius,
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
'tr:first-child td:last-child': {
|
|
85
|
-
borderTopRightRadius: theme.appBorderRadius,
|
|
86
|
-
},
|
|
87
|
-
'tr:last-child td:first-child': {
|
|
88
|
-
borderBottomLeftRadius: theme.appBorderRadius,
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
'tr:last-child td:last-child': {
|
|
92
|
-
borderBottomRightRadius: theme.appBorderRadius,
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
tbody: {
|
|
96
|
-
// slightly different than the other DocBlock shadows to account for table styling gymnastics
|
|
97
|
-
boxShadow:
|
|
98
|
-
theme.base === 'light'
|
|
99
|
-
? `rgba(0, 0, 0, 0.10) 0 1px 3px 1px,
|
|
100
|
-
${transparentize(0.035, theme.appBorderColor)} 0 0 0 1px`
|
|
101
|
-
: `rgba(0, 0, 0, 0.20) 0 2px 5px 1px,
|
|
102
|
-
${opacify(0.05, theme.appBorderColor)} 0 0 0 1px`,
|
|
103
|
-
borderRadius: theme.appBorderRadius,
|
|
104
|
-
|
|
105
|
-
tr: {
|
|
106
|
-
background: 'transparent',
|
|
107
|
-
'&:not(:first-child)': {
|
|
108
|
-
borderTop: `1px solid ${theme.appBorderColor}`,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
td: {
|
|
113
|
-
background: theme.background.content,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
// End finicky table styling
|
|
117
|
-
},
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
export enum PropsTableError {
|
|
121
|
-
NO_COMPONENT = 'No component found',
|
|
122
|
-
PROPS_UNSUPPORTED = 'Props unsupported. See Props documentation for your framework.',
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export interface PropsTableRowsProps {
|
|
126
|
-
rows: PropDef[];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface PropsTableErrorProps {
|
|
130
|
-
error: PropsTableError;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export type PropsTableProps = PropsTableRowsProps | PropsTableErrorProps;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Display the props for a component as a props table. Each row is a collection of
|
|
137
|
-
* PropDefs, usually derived from docgen info for the component.
|
|
138
|
-
*/
|
|
139
|
-
const PropsTable: React.FunctionComponent<PropsTableProps> = props => {
|
|
140
|
-
const { error } = props as PropsTableErrorProps;
|
|
141
|
-
if (error) {
|
|
142
|
-
return <EmptyBlock>{error}</EmptyBlock>;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const { rows } = props as PropsTableRowsProps;
|
|
146
|
-
if (rows.length === 0) {
|
|
147
|
-
return <EmptyBlock>No props found for this component</EmptyBlock>;
|
|
148
|
-
}
|
|
149
|
-
return (
|
|
150
|
-
<ResetWrapper>
|
|
151
|
-
<Table className="docblock-propstable">
|
|
152
|
-
<thead>
|
|
153
|
-
<tr>
|
|
154
|
-
<th>Name</th>
|
|
155
|
-
<th>Description</th>
|
|
156
|
-
<th>Default</th>
|
|
157
|
-
</tr>
|
|
158
|
-
</thead>
|
|
159
|
-
<tbody>
|
|
160
|
-
{rows.map(row => (
|
|
161
|
-
<PropRow key={row.name} row={row} />
|
|
162
|
-
))}
|
|
163
|
-
</tbody>
|
|
164
|
-
</Table>
|
|
165
|
-
</ResetWrapper>
|
|
166
|
-
);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
export { PropsTable, PropDef };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Source, SourceError } from './Source';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Docs|Source',
|
|
6
|
-
component: Source,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const jsxCode = `
|
|
10
|
-
<MyComponent boolProp scalarProp={1} complexProp={{ foo: 1, bar: '2' }}>
|
|
11
|
-
<SomeOtherComponent funcProp={(a) => a.id} />
|
|
12
|
-
</MyComponent>
|
|
13
|
-
`.trim();
|
|
14
|
-
|
|
15
|
-
const jsxProps = {};
|
|
16
|
-
export const jsx = () => <Source code={jsxCode} language="jsx" />;
|
|
17
|
-
|
|
18
|
-
const cssCode = `
|
|
19
|
-
@-webkit-keyframes blinker {
|
|
20
|
-
from { opacity: 1.0; }
|
|
21
|
-
to { opacity: 0.0; }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.waitingForConnection {
|
|
25
|
-
-webkit-animation-name: blinker;
|
|
26
|
-
-webkit-animation-iteration-count: infinite;
|
|
27
|
-
-webkit-animation-timing-function: cubic-bezier(.5, 0, 1, 1);
|
|
28
|
-
-webkit-animation-duration: 1.7s;
|
|
29
|
-
}
|
|
30
|
-
`.trim();
|
|
31
|
-
|
|
32
|
-
export const css = () => <Source code={cssCode} language="css" />;
|
|
33
|
-
|
|
34
|
-
export const noStory = () => <Source error={SourceError.NO_STORY} />;
|
|
35
|
-
|
|
36
|
-
export const sourceUnavailable = () => <Source error={SourceError.SOURCE_UNAVAILABLE} />;
|
package/src/blocks/Source.tsx
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { styled, ThemeProvider, convert, themes } from '@storybook/theming';
|
|
3
|
-
import { EmptyBlock } from './EmptyBlock';
|
|
4
|
-
|
|
5
|
-
import { SyntaxHighlighter } from '../syntaxhighlighter/syntaxhighlighter';
|
|
6
|
-
|
|
7
|
-
const StyledSyntaxHighlighter = styled(SyntaxHighlighter)<{}>(({ theme }) => ({
|
|
8
|
-
// DocBlocks-specific styling and overrides
|
|
9
|
-
fontSize: `${theme.typography.size.s2 - 1}px`,
|
|
10
|
-
lineHeight: '19px',
|
|
11
|
-
margin: '25px 0 40px',
|
|
12
|
-
borderRadius: theme.appBorderRadius,
|
|
13
|
-
boxShadow:
|
|
14
|
-
theme.base === 'light' ? 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' : 'rgba(0, 0, 0, 0.20) 0 2px 5px 0',
|
|
15
|
-
|
|
16
|
-
'pre.hljs': {
|
|
17
|
-
padding: 20,
|
|
18
|
-
background: 'inherit',
|
|
19
|
-
},
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
export enum SourceError {
|
|
23
|
-
NO_STORY = 'There\u2019s no story here.',
|
|
24
|
-
SOURCE_UNAVAILABLE = 'Oh no! The source is not available.',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface SourceErrorProps {
|
|
28
|
-
error?: SourceError;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface SourceCodeProps {
|
|
32
|
-
language?: string;
|
|
33
|
-
code?: string;
|
|
34
|
-
format?: boolean;
|
|
35
|
-
dark?: boolean;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// FIXME: Using | causes a typescript error, so stubbing it with & for now
|
|
39
|
-
// and making `error` optional
|
|
40
|
-
export type SourceProps = SourceErrorProps & SourceCodeProps;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Syntax-highlighted source code for a component (or anything!)
|
|
44
|
-
*/
|
|
45
|
-
const Source: React.FunctionComponent<SourceProps> = props => {
|
|
46
|
-
const { error } = props as SourceErrorProps;
|
|
47
|
-
if (error) {
|
|
48
|
-
return <EmptyBlock {...props}>{error}</EmptyBlock>;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const { language, code, dark, format, ...rest } = props as SourceCodeProps;
|
|
52
|
-
|
|
53
|
-
const syntaxHighlighter = (
|
|
54
|
-
<StyledSyntaxHighlighter
|
|
55
|
-
bordered
|
|
56
|
-
copyable
|
|
57
|
-
format={format}
|
|
58
|
-
language={language}
|
|
59
|
-
className="docblock-source"
|
|
60
|
-
{...rest}
|
|
61
|
-
>
|
|
62
|
-
{code}
|
|
63
|
-
</StyledSyntaxHighlighter>
|
|
64
|
-
);
|
|
65
|
-
if (typeof dark === 'undefined') {
|
|
66
|
-
return syntaxHighlighter;
|
|
67
|
-
}
|
|
68
|
-
const overrideTheme = dark ? themes.dark : themes.light;
|
|
69
|
-
return <ThemeProvider theme={convert(overrideTheme)}>{syntaxHighlighter}</ThemeProvider>;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export { Source };
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Story, StoryError } from './Story';
|
|
3
|
-
import { Button } from '../Button/Button';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Docs|Story',
|
|
7
|
-
component: Story,
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const buttonFn = () => <Button secondary>Inline story</Button>;
|
|
11
|
-
|
|
12
|
-
const buttonHookFn = () => {
|
|
13
|
-
const [count, setCount] = React.useState(0);
|
|
14
|
-
return (
|
|
15
|
-
<Button secondary onClick={() => setCount(count + 1)}>
|
|
16
|
-
{`count: ${count}`}
|
|
17
|
-
</Button>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const inline = () => <Story inline storyFn={buttonFn} title="hello button" />;
|
|
22
|
-
|
|
23
|
-
export const error = () => <Story error={StoryError.NO_STORY} />;
|
|
24
|
-
|
|
25
|
-
export const reactHook = () => <Story inline storyFn={buttonHookFn} title="hello button" />;
|
package/src/blocks/Story.tsx
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { IFrame } from './IFrame';
|
|
3
|
-
import { EmptyBlock } from './EmptyBlock';
|
|
4
|
-
import { ZoomContext } from './ZoomContext';
|
|
5
|
-
|
|
6
|
-
const BASE_URL = 'iframe.html';
|
|
7
|
-
|
|
8
|
-
export enum StoryError {
|
|
9
|
-
NO_STORY = 'No component or story to display',
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/** error message for Story with null storyFn
|
|
13
|
-
* if the story id exists, it must be pointing to a non-existing story
|
|
14
|
-
* if there is assigned story id, the story must be empty
|
|
15
|
-
*/
|
|
16
|
-
const MISSING_STORY = (id?: string) => (id ? `Story "${id}" doesn't exist.` : StoryError.NO_STORY);
|
|
17
|
-
|
|
18
|
-
interface CommonProps {
|
|
19
|
-
title: string;
|
|
20
|
-
height?: string;
|
|
21
|
-
id: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type InlineStoryProps = {
|
|
25
|
-
storyFn: React.ElementType;
|
|
26
|
-
} & CommonProps;
|
|
27
|
-
|
|
28
|
-
type IFrameStoryProps = CommonProps;
|
|
29
|
-
|
|
30
|
-
type ErrorProps = {
|
|
31
|
-
error?: StoryError;
|
|
32
|
-
} & CommonProps;
|
|
33
|
-
|
|
34
|
-
// How do you XOR properties in typescript?
|
|
35
|
-
export type StoryProps = (InlineStoryProps | IFrameStoryProps | ErrorProps) & {
|
|
36
|
-
inline: boolean;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const InlineZoomWrapper: React.FC<{ scale: number }> = ({ scale, children }) => {
|
|
40
|
-
return scale === 1 ? (
|
|
41
|
-
<>{children}</>
|
|
42
|
-
) : (
|
|
43
|
-
<div style={{ overflow: 'hidden' }}>
|
|
44
|
-
<div
|
|
45
|
-
style={{
|
|
46
|
-
transform: `scale(${1 / scale})`,
|
|
47
|
-
transformOrigin: 'top left',
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
{children}
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const InlineStory: React.FunctionComponent<InlineStoryProps> = ({ storyFn, height, id }) => (
|
|
57
|
-
<div style={{ height }}>
|
|
58
|
-
<ZoomContext.Consumer>
|
|
59
|
-
{({ scale }) => (
|
|
60
|
-
<InlineZoomWrapper scale={scale}>
|
|
61
|
-
{storyFn ? React.createElement(storyFn) : <EmptyBlock>{MISSING_STORY(id)}</EmptyBlock>}
|
|
62
|
-
</InlineZoomWrapper>
|
|
63
|
-
)}
|
|
64
|
-
</ZoomContext.Consumer>
|
|
65
|
-
</div>
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const IFrameStory: React.FunctionComponent<IFrameStoryProps> = ({
|
|
69
|
-
id,
|
|
70
|
-
title,
|
|
71
|
-
height = '500px',
|
|
72
|
-
}) => (
|
|
73
|
-
<div style={{ width: '100%', height }}>
|
|
74
|
-
<ZoomContext.Consumer>
|
|
75
|
-
{({ scale }) => {
|
|
76
|
-
return (
|
|
77
|
-
<IFrame
|
|
78
|
-
key="iframe"
|
|
79
|
-
id={`iframe--${id}`}
|
|
80
|
-
title={title}
|
|
81
|
-
src={`${BASE_URL}?id=${id}&viewMode=story`}
|
|
82
|
-
allowFullScreen
|
|
83
|
-
scale={scale}
|
|
84
|
-
style={{
|
|
85
|
-
width: '100%',
|
|
86
|
-
height: '100%',
|
|
87
|
-
border: '0 none',
|
|
88
|
-
}}
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
91
|
-
}}
|
|
92
|
-
</ZoomContext.Consumer>
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* A story element, either renderend inline or in an iframe,
|
|
98
|
-
* with configurable height.
|
|
99
|
-
*/
|
|
100
|
-
const Story: React.FunctionComponent<StoryProps> = props => {
|
|
101
|
-
const { error } = props as ErrorProps;
|
|
102
|
-
const { storyFn } = props as InlineStoryProps;
|
|
103
|
-
const { id, inline, title, height } = props;
|
|
104
|
-
|
|
105
|
-
if (error) {
|
|
106
|
-
return <EmptyBlock>{error}</EmptyBlock>;
|
|
107
|
-
}
|
|
108
|
-
return inline ? (
|
|
109
|
-
<InlineStory id={id} storyFn={storyFn} title={title} height={height} />
|
|
110
|
-
) : (
|
|
111
|
-
<IFrameStory id={id} title={title} height={height} />
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export { Story };
|
package/src/blocks/Toolbar.tsx
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React, { Fragment } from 'react';
|
|
2
|
-
import { styled } from '@storybook/theming';
|
|
3
|
-
|
|
4
|
-
import { window } from 'global';
|
|
5
|
-
import { FlexBar } from '../bar/bar';
|
|
6
|
-
import { Icons } from '../icon/icon';
|
|
7
|
-
import { IconButton } from '../bar/button';
|
|
8
|
-
|
|
9
|
-
interface ZoomProps {
|
|
10
|
-
zoom: (val: number) => void;
|
|
11
|
-
resetZoom: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface EjectProps {
|
|
15
|
-
storyId?: string;
|
|
16
|
-
baseUrl?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface BarProps {
|
|
20
|
-
border?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type ToolbarProps = BarProps & ZoomProps & EjectProps;
|
|
24
|
-
|
|
25
|
-
const Zoom: React.FC<ZoomProps> = ({ zoom, resetZoom }) => (
|
|
26
|
-
<>
|
|
27
|
-
<IconButton
|
|
28
|
-
key="zoomin"
|
|
29
|
-
onClick={e => {
|
|
30
|
-
e.preventDefault();
|
|
31
|
-
zoom(0.8);
|
|
32
|
-
}}
|
|
33
|
-
title="Zoom in"
|
|
34
|
-
>
|
|
35
|
-
<Icons icon="zoom" />
|
|
36
|
-
</IconButton>
|
|
37
|
-
<IconButton
|
|
38
|
-
key="zoomout"
|
|
39
|
-
onClick={e => {
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
zoom(1.25);
|
|
42
|
-
}}
|
|
43
|
-
title="Zoom out"
|
|
44
|
-
>
|
|
45
|
-
<Icons icon="zoomout" />
|
|
46
|
-
</IconButton>
|
|
47
|
-
<IconButton
|
|
48
|
-
key="zoomreset"
|
|
49
|
-
onClick={e => {
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
resetZoom();
|
|
52
|
-
}}
|
|
53
|
-
title="Reset zoom"
|
|
54
|
-
>
|
|
55
|
-
<Icons icon="zoomreset" />
|
|
56
|
-
</IconButton>
|
|
57
|
-
</>
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
const Eject: React.FC<EjectProps> = ({ baseUrl, storyId }) => (
|
|
61
|
-
<IconButton
|
|
62
|
-
key="opener"
|
|
63
|
-
onClick={() => window.open(`${baseUrl}?id=${storyId}`)}
|
|
64
|
-
title="Open canvas in new tab"
|
|
65
|
-
>
|
|
66
|
-
<Icons icon="share" />
|
|
67
|
-
</IconButton>
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const Bar = styled(props => <FlexBar {...props} />)({
|
|
71
|
-
position: 'absolute',
|
|
72
|
-
left: 0,
|
|
73
|
-
right: 0,
|
|
74
|
-
top: 0,
|
|
75
|
-
transition: 'transform .2s linear',
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
export const Toolbar: React.FC<ToolbarProps> = ({ storyId, baseUrl, zoom, resetZoom, ...rest }) => (
|
|
79
|
-
<Bar {...rest}>
|
|
80
|
-
<Fragment key="left">
|
|
81
|
-
<Zoom {...{ zoom, resetZoom }} />
|
|
82
|
-
</Fragment>
|
|
83
|
-
<Fragment key="right">{storyId && <Eject {...{ storyId, baseUrl }} />}</Fragment>
|
|
84
|
-
</Bar>
|
|
85
|
-
);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Typeset } from './Typeset';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Docs|Typeset',
|
|
6
|
-
component: Typeset,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const fontSizes = [12, 14, 16, 20, 24, 32, 40, 48];
|
|
10
|
-
const fontWeight = 900;
|
|
11
|
-
|
|
12
|
-
export const withFontSizes = () => <Typeset fontSizes={fontSizes} />;
|
|
13
|
-
export const withFontWeight = () => <Typeset fontSizes={fontSizes} fontWeight={fontWeight} />;
|
|
14
|
-
export const withWeightText = () => (
|
|
15
|
-
<Typeset fontSizes={fontSizes} fontWeight={fontWeight} sampleText="Heading" />
|
|
16
|
-
);
|
package/src/blocks/Typeset.tsx
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { styled } from '@storybook/theming';
|
|
3
|
-
import { transparentize } from 'polished';
|
|
4
|
-
|
|
5
|
-
import { withReset } from '../typography/withReset';
|
|
6
|
-
import { getBlockBackgroundStyle } from './BlockBackgroundStyles';
|
|
7
|
-
|
|
8
|
-
const Label = styled.div<{}>(({ theme }) => ({
|
|
9
|
-
marginRight: 30,
|
|
10
|
-
fontSize: `${theme.typography.size.s1}px`,
|
|
11
|
-
color:
|
|
12
|
-
theme.base === 'light'
|
|
13
|
-
? transparentize(0.4, theme.color.defaultText)
|
|
14
|
-
: transparentize(0.6, theme.color.defaultText),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const Sample = styled.div({
|
|
18
|
-
lineHeight: 1,
|
|
19
|
-
overflow: 'hidden',
|
|
20
|
-
whiteSpace: 'nowrap',
|
|
21
|
-
textOverflow: 'ellipsis',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const TypeSpecimen = styled.div({
|
|
25
|
-
display: 'flex',
|
|
26
|
-
flexDirection: 'row',
|
|
27
|
-
alignItems: 'baseline',
|
|
28
|
-
'&:not(:last-child)': { marginBottom: '1rem' },
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const Wrapper = styled.div<{}>(withReset, ({ theme }) => ({
|
|
32
|
-
...getBlockBackgroundStyle(theme),
|
|
33
|
-
margin: '25px 0 40px',
|
|
34
|
-
padding: '30px 20px',
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
export interface TypesetProps {
|
|
38
|
-
fontSizes: number[];
|
|
39
|
-
fontWeight?: number;
|
|
40
|
-
sampleText?: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Convenient tyleguide documentation showing examples of type
|
|
45
|
-
* with different sizes and weights and configurable sample text.
|
|
46
|
-
*/
|
|
47
|
-
export const Typeset: React.FunctionComponent<TypesetProps> = ({
|
|
48
|
-
fontSizes,
|
|
49
|
-
fontWeight,
|
|
50
|
-
sampleText,
|
|
51
|
-
...props
|
|
52
|
-
}) => (
|
|
53
|
-
<Wrapper {...props} className="docblock-typeset">
|
|
54
|
-
{fontSizes.map(num => (
|
|
55
|
-
<TypeSpecimen key={num}>
|
|
56
|
-
<Label>{num}px</Label>
|
|
57
|
-
<Sample
|
|
58
|
-
style={{
|
|
59
|
-
fontSize: num,
|
|
60
|
-
fontWeight,
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
{sampleText || 'Was he a beast if music could move him so?'}
|
|
64
|
-
</Sample>
|
|
65
|
-
</TypeSpecimen>
|
|
66
|
-
))}
|
|
67
|
-
</Wrapper>
|
|
68
|
-
);
|
package/src/blocks/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './Description';
|
|
2
|
-
export * from './DocsPage';
|
|
3
|
-
export * from './Preview';
|
|
4
|
-
export * from './PropsTable/PropsTable';
|
|
5
|
-
export * from './Source';
|
|
6
|
-
export * from './Story';
|
|
7
|
-
export * from './IFrame';
|
|
8
|
-
export * from './Typeset';
|
|
9
|
-
export * from './ColorPalette';
|
|
10
|
-
export * from './IconGallery';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React, { FunctionComponent } from 'react';
|
|
2
|
-
|
|
3
|
-
export const StorybookIcon: FunctionComponent<{}> = ({ ...props }) => (
|
|
4
|
-
<svg viewBox="0 0 64 64" {...props}>
|
|
5
|
-
<title>Storybook icon</title>
|
|
6
|
-
<g id="Artboard" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">
|
|
7
|
-
<path
|
|
8
|
-
d="M8.04798541,58.7875918 L6.07908839,6.32540407 C6.01406344,4.5927838 7.34257463,3.12440831 9.07303814,3.01625434 L53.6958037,0.227331489 C55.457209,0.117243658 56.974354,1.45590096 57.0844418,3.21730626 C57.0885895,3.28366922 57.0906648,3.35014546 57.0906648,3.41663791 L57.0906648,60.5834697 C57.0906648,62.3483119 55.6599776,63.7789992 53.8951354,63.7789992 C53.847325,63.7789992 53.7995207,63.7779262 53.7517585,63.775781 L11.0978899,61.8600599 C9.43669044,61.7854501 8.11034889,60.4492961 8.04798541,58.7875918 Z"
|
|
9
|
-
id="path-1"
|
|
10
|
-
fill="#FF4785"
|
|
11
|
-
fillRule="nonzero"
|
|
12
|
-
/>
|
|
13
|
-
<path
|
|
14
|
-
d="M35.9095005,24.1768792 C35.9095005,25.420127 44.2838488,24.8242707 45.4080313,23.9509748 C45.4080313,15.4847538 40.8652557,11.0358878 32.5466666,11.0358878 C24.2280775,11.0358878 19.5673077,15.553972 19.5673077,22.3311017 C19.5673077,34.1346028 35.4965208,34.3605071 35.4965208,40.7987804 C35.4965208,42.606015 34.6115646,43.6790606 32.6646607,43.6790606 C30.127786,43.6790606 29.1248356,42.3834613 29.2428298,37.9783269 C29.2428298,37.0226907 19.5673077,36.7247626 19.2723223,37.9783269 C18.5211693,48.6535354 25.1720308,51.7326752 32.7826549,51.7326752 C40.1572906,51.7326752 45.939005,47.8018145 45.939005,40.6858282 C45.939005,28.035186 29.7738035,28.3740425 29.7738035,22.1051974 C29.7738035,19.5637737 31.6617103,19.2249173 32.7826549,19.2249173 C33.9625966,19.2249173 36.0864917,19.4328883 35.9095005,24.1768792 Z"
|
|
15
|
-
id="path9_fill-path"
|
|
16
|
-
fill="#FFFFFF"
|
|
17
|
-
fillRule="nonzero"
|
|
18
|
-
/>
|
|
19
|
-
<path
|
|
20
|
-
d="M44.0461638,0.830433986 L50.1874092,0.446606143 L50.443532,7.7810017 C50.4527198,8.04410717 50.2468789,8.26484453 49.9837734,8.27403237 C49.871115,8.27796649 49.7607078,8.24184808 49.6721567,8.17209069 L47.3089847,6.3104681 L44.5110468,8.43287463 C44.3012992,8.591981 44.0022839,8.55092814 43.8431776,8.34118051 C43.7762017,8.25288717 43.742082,8.14401677 43.7466857,8.03329059 L44.0461638,0.830433986 Z"
|
|
21
|
-
id="Path"
|
|
22
|
-
fill="#FFFFFF"
|
|
23
|
-
/>
|
|
24
|
-
</g>
|
|
25
|
-
</svg>
|
|
26
|
-
);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import React, { FunctionComponent } from 'react';
|
|
2
|
-
|
|
3
|
-
export interface StorybookLogoProps {
|
|
4
|
-
alt: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const StorybookLogo: FunctionComponent<StorybookLogoProps> = ({ alt, ...props }) => (
|
|
8
|
-
<svg width="200px" height="40px" viewBox="0 0 200 40" {...props} role="img">
|
|
9
|
-
{alt ? <title>{alt}</title> : null}
|
|
10
|
-
<defs>
|
|
11
|
-
<path
|
|
12
|
-
d="M1.2 36.9L0 3.9c0-1.1.8-2 1.9-2.1l28-1.8a2 2 0 0 1 2.2 1.9 2 2 0 0 1 0 .1v36a2 2 0 0 1-2 2 2 2 0 0 1-.1 0L3.2 38.8a2 2 0 0 1-2-2z"
|
|
13
|
-
id="a"
|
|
14
|
-
/>
|
|
15
|
-
</defs>
|
|
16
|
-
<g fill="none" fillRule="evenodd">
|
|
17
|
-
<path
|
|
18
|
-
d="M53.3 31.7c-1.7 0-3.4-.3-5-.7-1.5-.5-2.8-1.1-3.9-2l1.6-3.5c2.2 1.5 4.6 2.3 7.3 2.3 1.5 0 2.5-.2 3.3-.7.7-.5 1.1-1 1.1-1.9 0-.7-.3-1.3-1-1.7s-2-.8-3.7-1.2c-2-.4-3.6-.9-4.8-1.5-1.1-.5-2-1.2-2.6-2-.5-1-.8-2-.8-3.2 0-1.4.4-2.6 1.2-3.6.7-1.1 1.8-2 3.2-2.6 1.3-.6 2.9-.9 4.7-.9 1.6 0 3.1.3 4.6.7 1.5.5 2.7 1.1 3.5 2l-1.6 3.5c-2-1.5-4.2-2.3-6.5-2.3-1.3 0-2.3.2-3 .8-.8.5-1.2 1.1-1.2 2 0 .5.2 1 .5 1.3.2.3.7.6 1.4.9l2.9.8c2.9.6 5 1.4 6.2 2.4a5 5 0 0 1 2 4.2 6 6 0 0 1-2.5 5c-1.7 1.2-4 1.9-7 1.9zm21-3.6l1.4-.1-.2 3.5-1.9.1c-2.4 0-4.1-.5-5.2-1.5-1.1-1-1.6-2.7-1.6-4.8v-6h-3v-3.6h3V11h4.8v4.6h4v3.6h-4v6c0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 2 0 1.9 3z"
|
|
27
|
-
fill="#FFF"
|
|
28
|
-
fillRule="nonzero"
|
|
29
|
-
mask="url(#b)"
|
|
30
|
-
/>
|
|
31
|
-
</g>
|
|
32
|
-
</svg>
|
|
33
|
-
);
|