@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.
Files changed (94) hide show
  1. package/dist/html.js +1 -1
  2. package/dist/typography/DocumentFormatting.js +2 -1
  3. package/dist/typography/DocumentWrapper.js +2 -2
  4. package/package.json +11 -5
  5. package/src/ActionBar/ActionBar.stories.tsx +0 -41
  6. package/src/ActionBar/ActionBar.tsx +0 -75
  7. package/src/Badge/Badge.stories.tsx +0 -11
  8. package/src/Badge/Badge.tsx +0 -68
  9. package/src/Button/Button.stories.tsx +0 -53
  10. package/src/Button/Button.tsx +0 -256
  11. package/src/ScrollArea/ScrollArea.stories.tsx +0 -85
  12. package/src/ScrollArea/ScrollArea.tsx +0 -62
  13. package/src/ScrollArea/ScrollAreaStyles.tsx +0 -166
  14. package/src/addon-panel/addon-panel.tsx +0 -33
  15. package/src/bar/bar.tsx +0 -93
  16. package/src/bar/button.ts +0 -89
  17. package/src/bar/separator.tsx +0 -39
  18. package/src/blocks/BlockBackgroundStyles.tsx +0 -9
  19. package/src/blocks/ColorPalette.stories.tsx +0 -29
  20. package/src/blocks/ColorPalette.tsx +0 -168
  21. package/src/blocks/Description.stories.tsx +0 -15
  22. package/src/blocks/Description.tsx +0 -18
  23. package/src/blocks/DocsPage.stories.tsx +0 -67
  24. package/src/blocks/DocsPage.tsx +0 -81
  25. package/src/blocks/DocsPageExampleCaption.md +0 -93
  26. package/src/blocks/DocsPageExampleCaption.mdx +0 -93
  27. package/src/blocks/EmptyBlock.stories.tsx +0 -9
  28. package/src/blocks/EmptyBlock.tsx +0 -23
  29. package/src/blocks/IFrame.tsx +0 -60
  30. package/src/blocks/IconGallery.stories.tsx +0 -32
  31. package/src/blocks/IconGallery.tsx +0 -72
  32. package/src/blocks/Preview.stories.tsx +0 -96
  33. package/src/blocks/Preview.tsx +0 -162
  34. package/src/blocks/PropsTable/PropDef.ts +0 -7
  35. package/src/blocks/PropsTable/PropRow.stories.tsx +0 -113
  36. package/src/blocks/PropsTable/PropRow.tsx +0 -102
  37. package/src/blocks/PropsTable/PropsTable.stories.tsx +0 -14
  38. package/src/blocks/PropsTable/PropsTable.tsx +0 -169
  39. package/src/blocks/Source.stories.tsx +0 -36
  40. package/src/blocks/Source.tsx +0 -72
  41. package/src/blocks/Story.stories.tsx +0 -25
  42. package/src/blocks/Story.tsx +0 -115
  43. package/src/blocks/Toolbar.tsx +0 -85
  44. package/src/blocks/Typeset.stories.tsx +0 -16
  45. package/src/blocks/Typeset.tsx +0 -68
  46. package/src/blocks/ZoomContext.tsx +0 -5
  47. package/src/blocks/index.ts +0 -10
  48. package/src/brand/StorybookIcon.stories.tsx +0 -6
  49. package/src/brand/StorybookIcon.tsx +0 -26
  50. package/src/brand/StorybookLogo.stories.tsx +0 -10
  51. package/src/brand/StorybookLogo.tsx +0 -33
  52. package/src/form/field/field.tsx +0 -42
  53. package/src/form/form.stories.tsx +0 -133
  54. package/src/form/index.tsx +0 -18
  55. package/src/form/input/input.tsx +0 -178
  56. package/src/html.tsx +0 -12
  57. package/src/icon/icon.stories.tsx +0 -77
  58. package/src/icon/icon.tsx +0 -22
  59. package/src/icon/icons.tsx +0 -310
  60. package/src/icon/svg.tsx +0 -24
  61. package/src/index.ts +0 -37
  62. package/src/placeholder/placeholder.stories.tsx +0 -24
  63. package/src/placeholder/placeholder.tsx +0 -25
  64. package/src/spaced/Spaced.stories.tsx +0 -72
  65. package/src/spaced/Spaced.tsx +0 -69
  66. package/src/syntaxhighlighter/formatter.test.js +0 -90
  67. package/src/syntaxhighlighter/formatter.ts +0 -26
  68. package/src/syntaxhighlighter/syntaxhighlighter.stories.tsx +0 -136
  69. package/src/syntaxhighlighter/syntaxhighlighter.tsx +0 -165
  70. package/src/tabs/tabs.stories.tsx +0 -207
  71. package/src/tabs/tabs.tsx +0 -252
  72. package/src/tooltip/ListItem.stories.tsx +0 -35
  73. package/src/tooltip/ListItem.tsx +0 -245
  74. package/src/tooltip/Tooltip.stories.tsx +0 -42
  75. package/src/tooltip/Tooltip.tsx +0 -146
  76. package/src/tooltip/TooltipLinkList.stories.tsx +0 -52
  77. package/src/tooltip/TooltipLinkList.tsx +0 -49
  78. package/src/tooltip/TooltipMessage.stories.tsx +0 -37
  79. package/src/tooltip/TooltipMessage.tsx +0 -67
  80. package/src/tooltip/TooltipNote.stories.tsx +0 -15
  81. package/src/tooltip/TooltipNote.tsx +0 -25
  82. package/src/tooltip/WithTooltip.stories.tsx +0 -85
  83. package/src/tooltip/WithTooltip.tsx +0 -159
  84. package/src/typings.d.ts +0 -4
  85. package/src/typography/DocumentFormatting.tsx +0 -355
  86. package/src/typography/DocumentFormattingSample.md +0 -127
  87. package/src/typography/DocumentWrapper.stories.tsx +0 -190
  88. package/src/typography/DocumentWrapper.tsx +0 -441
  89. package/src/typography/link/link.stories.tsx +0 -67
  90. package/src/typography/link/link.test.tsx +0 -108
  91. package/src/typography/link/link.tsx +0 -223
  92. package/src/typography/typography.stories.tsx +0 -111
  93. package/src/typography/withReset.tsx +0 -12
  94. package/tsconfig.json +0 -18
@@ -1,207 +0,0 @@
1
- import React, { Fragment, Key } from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { action } from '@storybook/addon-actions';
4
- import { logger } from '@storybook/client-logger';
5
-
6
- import { Tabs, TabsState, TabWrapper } from './tabs';
7
-
8
- const colours = Array.from(new Array(15), (val, index) => index).map(i =>
9
- Math.floor((1 / 15) * i * 16777215)
10
- .toString(16)
11
- .padStart(6, '0')
12
- );
13
-
14
- interface FibonacciMap {
15
- [key: string]: number;
16
- }
17
-
18
- function fibonacci(num: number, memo?: FibonacciMap): number {
19
- /* eslint-disable no-param-reassign */
20
- if (!memo) {
21
- memo = {};
22
- }
23
- if (memo[num]) {
24
- return memo[num];
25
- }
26
- if (num <= 1) {
27
- return 1;
28
- }
29
-
30
- memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo);
31
- return memo[num];
32
- /* eslint-enable no-param-reassign */
33
- }
34
-
35
- interface Panels {
36
- [key: string]: {
37
- title: string;
38
- color: string;
39
- render: ({ active, key }: { active: boolean; key: Key }) => JSX.Element;
40
- };
41
- }
42
-
43
- const panels: Panels = {
44
- test1: {
45
- title: 'Tab title #1',
46
- render: ({ active, key }) =>
47
- active ? (
48
- <div id="test1" key={key}>
49
- CONTENT 1
50
- </div>
51
- ) : null,
52
- },
53
- test2: {
54
- title: 'Tab title #2',
55
- render: ({ active, key }) => (
56
- <div
57
- key={key}
58
- id="test2"
59
- style={{ background: 'hotpink', minHeight: '100%', display: active ? 'block' : 'none' }}
60
- >
61
- CONTENT 2
62
- </div>
63
- ),
64
- },
65
- test3: {
66
- title: 'Tab with scroll!',
67
- render: ({ active, key }) =>
68
- active ? (
69
- <div id="test3" key={key}>
70
- {colours.map((colour, i) => (
71
- <div
72
- key={colour}
73
- style={{
74
- background: `#${colour}`,
75
- height: 30 + fibonacci(i + 5) / 10,
76
- }}
77
- />
78
- ))}
79
- </div>
80
- ) : null,
81
- },
82
- test4: {
83
- title: 'Tab title #4',
84
- render: ({ active, key }) =>
85
- active ? (
86
- <div key={key} id="test4">
87
- CONTENT 4
88
- </div>
89
- ) : null,
90
- },
91
- test5: {
92
- title: 'Tab title #5',
93
- render: ({ active, key }) =>
94
- active ? (
95
- <div key={key} id="test5">
96
- CONTENT 5
97
- </div>
98
- ) : null,
99
- },
100
- test6: {
101
- title: 'Tab title #6',
102
- render: ({ active, key }) => (
103
- <TabWrapper key={key} active={active} render={() => <div>CONTENT 6</div>} />
104
- ),
105
- },
106
- };
107
-
108
- const onSelect = action('onSelect');
109
-
110
- const content = Object.entries(panels).map(([k, v]) => (
111
- <div key={k} id={k} title={v.title}>
112
- {v.render}
113
- </div>
114
- ));
115
-
116
- storiesOf('Basics|Tabs', module)
117
- .addDecorator(s => (
118
- <div
119
- style={{
120
- position: 'relative',
121
- height: 'calc(100vh - 20px)',
122
- width: 'calc(100vw - 20px)',
123
- margin: 10,
124
- }}
125
- >
126
- {s()}
127
- </div>
128
- ))
129
- .add('stateful - static', () => (
130
- <TabsState initial="test2">
131
- <div id="test1" title="With a function">
132
- {({ active, selected }: { active: boolean; selected: string }) =>
133
- active ? <div>{selected} is selected</div> : null
134
- }
135
- </div>
136
- <div id="test2" title="With markup">
137
- <div>test2 is always active (but visually hidden)</div>
138
- </div>
139
- </TabsState>
140
- ))
141
- .add('stateful - static with set button text colors', () => (
142
- <div>
143
- <TabsState initial="test2">
144
- <div id="test1" title="With a function" color="red">
145
- {({ active, selected }: { active: boolean; selected: string }) =>
146
- active ? <div>{selected} is selected</div> : null
147
- }
148
- </div>
149
- <div id="test2" title="With markup" color="green">
150
- <div>test2 is always active (but visually hidden)</div>
151
- </div>
152
- </TabsState>
153
- </div>
154
- ))
155
- .add('stateful - static with set backgroundColor', () => (
156
- <div>
157
- <TabsState initial="test2" backgroundColor="rgba(0,0,0,.05)">
158
- <div id="test1" title="With a function" color="red">
159
- {({ active, selected }: { active: boolean; selected: string }) =>
160
- active ? <div>{selected} is selected</div> : null
161
- }
162
- </div>
163
- <div id="test2" title="With markup" color="green">
164
- <div>test2 is always active (but visually hidden)</div>
165
- </div>
166
- </TabsState>
167
- </div>
168
- ))
169
- .add('stateful - dynamic', () => (
170
- <TabsState initial="test3">
171
- {Object.entries(panels).map(([k, v]) => (
172
- <div key={k} id={k} title={v.title}>
173
- {v.render}
174
- </div>
175
- ))}
176
- </TabsState>
177
- ))
178
- .add('stateful - no initial', () => <TabsState>{content}</TabsState>)
179
- .add('stateless - bordered', () => (
180
- <Tabs bordered absolute={false} selected="test3" actions={{ onSelect }}>
181
- {content}
182
- </Tabs>
183
- ))
184
- .add('stateless - with tools', () => (
185
- <Tabs
186
- selected="test3"
187
- actions={{ onSelect }}
188
- tools={
189
- <Fragment>
190
- <button type="button" onClick={() => logger.log('1')}>
191
- 1
192
- </button>
193
- <button type="button" onClick={() => logger.log('2')}>
194
- 2
195
- </button>
196
- </Fragment>
197
- }
198
- >
199
- {content}
200
- </Tabs>
201
- ))
202
- .add('stateless - absolute', () => (
203
- <Tabs bordered absolute selected="test3" actions={{ onSelect }}>
204
- {content}
205
- </Tabs>
206
- ))
207
- .add('stateless - empty', () => <Tabs actions={{ onSelect }} bordered absolute />);
package/src/tabs/tabs.tsx DELETED
@@ -1,252 +0,0 @@
1
- import React, {
2
- Children,
3
- Component,
4
- Fragment,
5
- FunctionComponent,
6
- MouseEvent,
7
- ReactNode,
8
- } from 'react';
9
- import PropTypes from 'prop-types';
10
- import { styled } from '@storybook/theming';
11
-
12
- import { Placeholder } from '../placeholder/placeholder';
13
- import { FlexBar } from '../bar/bar';
14
- import { TabButton } from '../bar/button';
15
-
16
- const ignoreSsrWarning =
17
- '/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */';
18
-
19
- export interface WrapperProps {
20
- bordered?: boolean;
21
- absolute?: boolean;
22
- }
23
-
24
- const Wrapper = styled.div<WrapperProps>(
25
- ({ theme, bordered }) =>
26
- bordered
27
- ? {
28
- backgroundClip: 'padding-box',
29
- border: `1px solid ${theme.appBorderColor}`,
30
- borderRadius: theme.appBorderRadius,
31
- overflow: 'hidden',
32
- }
33
- : {},
34
- ({ absolute }) =>
35
- absolute
36
- ? {
37
- width: '100%',
38
- height: '100%',
39
- boxSizing: 'border-box',
40
- display: 'flex',
41
- flexDirection: 'column',
42
- }
43
- : {
44
- display: 'block',
45
- }
46
- );
47
-
48
- export const TabBar = styled.div({
49
- overflow: 'hidden',
50
-
51
- '&:first-of-type': {
52
- marginLeft: 0,
53
- },
54
- });
55
-
56
- export interface ContentProps {
57
- absolute?: boolean;
58
- }
59
-
60
- const Content = styled.div<ContentProps>(
61
- {
62
- display: 'block',
63
- position: 'relative',
64
- },
65
- ({ theme }) => ({
66
- fontSize: theme.typography.size.s2 - 1,
67
- }),
68
- ({ absolute }) =>
69
- absolute
70
- ? {
71
- height: 'calc(100% - 40px)',
72
-
73
- position: 'absolute',
74
- left: 0,
75
- right: 0,
76
- bottom: 0,
77
- top: 40,
78
- overflow: 'auto',
79
- [`& > *:first-child${ignoreSsrWarning}`]: {
80
- position: 'absolute',
81
- left: 0,
82
- right: 0,
83
- bottom: 0,
84
- top: 0,
85
- height: '100%',
86
- overflow: 'auto',
87
- },
88
- }
89
- : {}
90
- );
91
-
92
- export interface VisuallyHiddenProps {
93
- active?: boolean;
94
- }
95
-
96
- const VisuallyHidden = styled.div<VisuallyHiddenProps>(({ active }) =>
97
- active ? { display: 'block' } : { display: 'none' }
98
- );
99
-
100
- export interface TabWrapperProps {
101
- active: boolean;
102
- render?: () => JSX.Element;
103
- children?: ReactNode;
104
- }
105
-
106
- export const TabWrapper: FunctionComponent<TabWrapperProps> = ({ active, render, children }) => (
107
- <VisuallyHidden active={active}>{render ? render() : children}</VisuallyHidden>
108
- );
109
-
110
- export const panelProps = {
111
- active: PropTypes.bool,
112
- };
113
-
114
- const childrenToList = (children: any, selected: string) =>
115
- Children.toArray(children).map(
116
- ({ props: { title, id, color, children: childrenOfChild } }, index) => {
117
- const content = Array.isArray(childrenOfChild) ? childrenOfChild[0] : childrenOfChild;
118
- return {
119
- active: selected ? id === selected : index === 0,
120
- title,
121
- id,
122
- color,
123
- render:
124
- typeof content === 'function'
125
- ? content
126
- : ({ active, key }: any) => (
127
- <VisuallyHidden key={key} active={active} role="tabpanel">
128
- {content}
129
- </VisuallyHidden>
130
- ),
131
- };
132
- }
133
- );
134
-
135
- export interface TabsProps {
136
- id?: string;
137
- children?: ReactNode;
138
- tools?: ReactNode;
139
- selected?: string;
140
- actions?: {
141
- onSelect: (id: string) => void;
142
- };
143
- backgroundColor?: string;
144
- absolute?: boolean;
145
- bordered?: boolean;
146
- }
147
-
148
- export const Tabs = React.memo<TabsProps>(
149
- ({
150
- children,
151
- selected,
152
- actions,
153
- absolute,
154
- bordered,
155
- tools,
156
- backgroundColor,
157
- id: htmlId,
158
- }: TabsProps) => {
159
- const list = childrenToList(children, selected);
160
-
161
- return list.length ? (
162
- <Wrapper absolute={absolute} bordered={bordered} id={htmlId}>
163
- <FlexBar border backgroundColor={backgroundColor}>
164
- <TabBar role="tablist">
165
- {list.map(({ title, id, active, color }) => (
166
- <TabButton
167
- type="button"
168
- key={id}
169
- active={active}
170
- textColor={color}
171
- onClick={(e: MouseEvent) => {
172
- e.preventDefault();
173
- actions.onSelect(id);
174
- }}
175
- role="tab"
176
- >
177
- {typeof title === 'function' ? title() : title}
178
- </TabButton>
179
- ))}
180
- </TabBar>
181
- {tools ? <Fragment>{tools}</Fragment> : null}
182
- </FlexBar>
183
- <Content absolute={absolute}>
184
- {list.map(({ id, active, render }) => render({ key: id, active }))}
185
- </Content>
186
- </Wrapper>
187
- ) : (
188
- <Placeholder>
189
- <Fragment key="title">Nothing found</Fragment>
190
- </Placeholder>
191
- );
192
- }
193
- );
194
- Tabs.displayName = 'Tabs';
195
- (Tabs as any).defaultProps = {
196
- id: null,
197
- children: null,
198
- tools: null,
199
- selected: null,
200
- absolute: false,
201
- bordered: false,
202
- };
203
-
204
- type FuncChilden = () => void;
205
-
206
- export interface TabsStateProps {
207
- children: (ReactNode | FuncChilden)[];
208
- initial: string;
209
- absolute: boolean;
210
- bordered: boolean;
211
- backgroundColor: string;
212
- }
213
-
214
- export interface TabsStateState {
215
- selected: string;
216
- }
217
-
218
- export class TabsState extends Component<TabsStateProps, TabsStateState> {
219
- static defaultProps: TabsStateProps = {
220
- children: [],
221
- initial: null,
222
- absolute: false,
223
- bordered: false,
224
- backgroundColor: '',
225
- };
226
-
227
- constructor(props: TabsStateProps) {
228
- super(props);
229
-
230
- this.state = {
231
- selected: props.initial,
232
- };
233
- }
234
-
235
- render() {
236
- const { bordered = false, absolute = false, children, backgroundColor } = this.props;
237
- const { selected } = this.state;
238
- return (
239
- <Tabs
240
- bordered={bordered}
241
- absolute={absolute}
242
- selected={selected}
243
- backgroundColor={backgroundColor}
244
- actions={{
245
- onSelect: id => this.setState({ selected: id }),
246
- }}
247
- >
248
- {children}
249
- </Tabs>
250
- );
251
- }
252
- }
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import ListItem from './ListItem';
4
-
5
- import { Icons } from '../icon/icon';
6
-
7
- storiesOf('basics|Tooltip/ListItem', module)
8
- .add('all', () => (
9
- <div>
10
- <ListItem loading />
11
- <ListItem title="Default" />
12
- <ListItem title="Default icon" right={<Icons icon="eye" />} />
13
- <ListItem left="left" title="title" center="center" right="right" />
14
- <ListItem active left="left" title="active" center="center" right="right" />
15
- <ListItem
16
- active
17
- left="left"
18
- title="active icon"
19
- center="center"
20
- right={<Icons icon="eye" />}
21
- />
22
- <ListItem disabled left="left" title="disabled" center="center" right="right" />
23
- </div>
24
- ))
25
- .add('loading', () => <ListItem loading />)
26
- .add('default', () => <ListItem title="Default" />)
27
- .add('default icon', () => <ListItem title="Default icon" right={<Icons icon="eye" />} />)
28
- .add('active icon', () => <ListItem active title="active icon" right={<Icons icon="eye" />} />)
29
- .add('w/positions', () => <ListItem left="left" title="title" center="center" right="right" />)
30
- .add('w/positions active', () => (
31
- <ListItem active left="left" title="active" center="center" right="right" />
32
- ))
33
- .add('disabled', () => (
34
- <ListItem disabled left="left" title="disabled" center="center" right="right" />
35
- ));