@khanacademy/wonder-blocks-cell 2.2.15 → 2.2.17
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/CHANGELOG.md +38 -0
- package/dist/components/compact-cell.d.ts +22 -0
- package/dist/components/compact-cell.js.flow +30 -0
- package/dist/components/detail-cell.d.ts +39 -0
- package/dist/components/detail-cell.js.flow +51 -0
- package/dist/components/internal/cell-core.d.ts +26 -0
- package/dist/components/internal/cell-core.js.flow +38 -0
- package/dist/components/internal/common.d.ts +30 -0
- package/dist/components/internal/common.js.flow +45 -0
- package/dist/es/index.js +40 -32
- package/dist/index.d.ts +3 -0
- package/dist/index.js +57 -51
- package/dist/index.js.flow +10 -2
- package/dist/util/types.d.ts +122 -0
- package/dist/util/types.js.flow +148 -0
- package/package.json +9 -9
- package/src/components/__tests__/{compact-cell.test.js → compact-cell.test.tsx} +0 -1
- package/src/components/__tests__/{detail-cell.test.js → detail-cell.test.tsx} +0 -1
- package/src/components/{compact-cell.js → compact-cell.tsx} +2 -3
- package/src/components/{detail-cell.js → detail-cell.tsx} +17 -15
- package/src/components/internal/__tests__/{cell-core.test.js → cell-core.test.tsx} +0 -1
- package/src/components/internal/__tests__/{common.test.js → common.test.ts} +0 -2
- package/src/components/internal/{cell-core.js → cell-core.tsx} +27 -26
- package/src/components/internal/{common.js → common.ts} +1 -2
- package/src/{index.js → index.ts} +0 -1
- package/src/util/{types.js → types.ts} +25 -39
- package/tsconfig.json +17 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/src/components/__docs__/compact-cell.argtypes.js +0 -189
- package/src/components/__docs__/compact-cell.stories.js +0 -303
- package/src/components/__docs__/detail-cell.argtypes.js +0 -28
- package/src/components/__docs__/detail-cell.stories.js +0 -208
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import {StyleSheet} from "aphrodite";
|
|
4
|
-
|
|
5
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
6
|
-
import Color from "@khanacademy/wonder-blocks-color";
|
|
7
|
-
import {Strut} from "@khanacademy/wonder-blocks-layout";
|
|
8
|
-
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
9
|
-
import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
|
|
10
|
-
|
|
11
|
-
import type {StoryComponentType} from "@storybook/react";
|
|
12
|
-
|
|
13
|
-
import type {IconAsset} from "@khanacademy/wonder-blocks-icon";
|
|
14
|
-
|
|
15
|
-
import ComponentInfo from "../../../../../.storybook/components/component-info";
|
|
16
|
-
import {name, version} from "../../../package.json";
|
|
17
|
-
import CompactCellArgTypes, {AccessoryMappings} from "./compact-cell.argtypes";
|
|
18
|
-
|
|
19
|
-
import CompactCell from "../compact-cell";
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
title: "Cell / CompactCell",
|
|
23
|
-
component: CompactCell,
|
|
24
|
-
argTypes: CompactCellArgTypes,
|
|
25
|
-
parameters: {
|
|
26
|
-
componentSubtitle: ((
|
|
27
|
-
<ComponentInfo name={name} version={version} />
|
|
28
|
-
): any),
|
|
29
|
-
docs: {
|
|
30
|
-
description: {
|
|
31
|
-
component: null,
|
|
32
|
-
},
|
|
33
|
-
source: {
|
|
34
|
-
// See https://github.com/storybookjs/storybook/issues/12596
|
|
35
|
-
excludeDecorators: true,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
decorators: [
|
|
40
|
-
(Story: any): React.Node => (
|
|
41
|
-
<View style={styles.example}>{Story()}</View>
|
|
42
|
-
),
|
|
43
|
-
],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Default CompactCell example. It will be rendered as the first/default story and
|
|
48
|
-
* it can be interacted with the controls panel in the Browser.
|
|
49
|
-
*/
|
|
50
|
-
const Template = (args) => <CompactCell {...args} />;
|
|
51
|
-
|
|
52
|
-
export const DefaultCompactCell: StoryComponentType = Template.bind({});
|
|
53
|
-
|
|
54
|
-
DefaultCompactCell.args = {
|
|
55
|
-
title: "Basic Cell",
|
|
56
|
-
rightAccessory: <Icon icon={icons.caretRight} />,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
DefaultCompactCell.parameters = {
|
|
60
|
-
chromatic: {
|
|
61
|
-
// We have screenshots of other stories that cover other variants.
|
|
62
|
-
disableSnapshot: true,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Only including an accessory on the left.
|
|
68
|
-
*/
|
|
69
|
-
export const CompactCellLeft: StoryComponentType = () => (
|
|
70
|
-
<CompactCell
|
|
71
|
-
title="Intro to rational & irrational numbers"
|
|
72
|
-
leftAccessory={<Icon icon={icons.contentArticle} size="medium" />}
|
|
73
|
-
/>
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
CompactCellLeft.parameters = {
|
|
77
|
-
docs: {
|
|
78
|
-
storyDescription:
|
|
79
|
-
"You can create a minimal cell that only uses a title and an Icon that can be placed on the left or right (or both). In this case, we will place the icon on the left to show you how cell is flexible. Note that you can pass any of the existing WB components such as `Icon`, `IconButton`, `Tooltip`, etc.",
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Only including an accessory on the right.
|
|
85
|
-
*/
|
|
86
|
-
export const CompactCellRight: StoryComponentType = (args) => (
|
|
87
|
-
<CompactCell
|
|
88
|
-
title="Intro to rational & irrational numbers"
|
|
89
|
-
rightAccessory={<Icon icon={icons.caretRight} size="medium" />}
|
|
90
|
-
/>
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
CompactCellRight.parameters = {
|
|
94
|
-
docs: {
|
|
95
|
-
storyDescription:
|
|
96
|
-
"You can also create a cell with an accessory placed on the right. Note that you can pass any of the existing WB components such as `Icon`.",
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Adding multiline title to verify that the cell's height is correct.
|
|
102
|
-
*/
|
|
103
|
-
export const CompactCellWithDifferentHeights: StoryComponentType = (args) => (
|
|
104
|
-
<>
|
|
105
|
-
<CompactCell
|
|
106
|
-
title="Single line with short accessory."
|
|
107
|
-
rightAccessory={AccessoryMappings.withCaret}
|
|
108
|
-
/>
|
|
109
|
-
<Strut size={Spacing.xSmall_8} />
|
|
110
|
-
<CompactCell
|
|
111
|
-
title="Single line with tall accessory."
|
|
112
|
-
rightAccessory={AccessoryMappings.withIconText}
|
|
113
|
-
/>
|
|
114
|
-
<Strut size={Spacing.xSmall_8} />
|
|
115
|
-
<CompactCell
|
|
116
|
-
title="Multi line title with tall accessory. Content should fit within the container and the cell height should be consistent no matter the content length."
|
|
117
|
-
rightAccessory={AccessoryMappings.withIconText}
|
|
118
|
-
/>
|
|
119
|
-
</>
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
CompactCellWithDifferentHeights.parameters = {
|
|
123
|
-
docs: {
|
|
124
|
-
storyDescription:
|
|
125
|
-
"Cells should keep a consistent height no matter the content passed in the title prop. It should also respect a `minHeight` of 48px",
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* A CompactCell example adding both accessories (left and right)
|
|
131
|
-
*/
|
|
132
|
-
const calendarIcon: IconAsset = {
|
|
133
|
-
small: `M14.22 1.6H13.33V0H11.56V1.6H4.44V0H2.67V1.6H1.78C0.79 1.6 0.01 2.32 0.01 3.2L0 14.4C0 15.28 0.79 16 1.78 16H14.22C15.2 16 16 15.28 16 14.4V3.2C16 2.32 15.2 1.6 14.22 1.6ZM14.22 14.4H1.78V5.6H14.22V14.4ZM3.56 7.2H8V11.2H3.56V7.2Z`,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const CompactCellBoth: StoryComponentType = () => (
|
|
137
|
-
<CompactCell
|
|
138
|
-
title="Intro to rational & irrational numbers"
|
|
139
|
-
leftAccessory={<Icon icon={icons.contentArticle} size="medium" />}
|
|
140
|
-
rightAccessory={
|
|
141
|
-
<Icon icon={calendarIcon} size="medium" color={Color.blue} />
|
|
142
|
-
}
|
|
143
|
-
/>
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
CompactCellBoth.storyName = "CompactCell with both accessories";
|
|
147
|
-
|
|
148
|
-
CompactCellBoth.parameters = {
|
|
149
|
-
docs: {
|
|
150
|
-
storyDescription:
|
|
151
|
-
"You can also create a more complex cell with accessories placed on both sides. Note that you can extend the Icon component with custom paths such as the following example.",
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const CompactCellAccessoryStyles: StoryComponentType = () => (
|
|
156
|
-
<CompactCell
|
|
157
|
-
title="CompactCell with custom accessory styles"
|
|
158
|
-
leftAccessory={<Icon icon={icons.contentArticle} size="medium" />}
|
|
159
|
-
leftAccessoryStyle={{
|
|
160
|
-
minWidth: Spacing.xxLarge_48,
|
|
161
|
-
alignSelf: "flex-start",
|
|
162
|
-
alignItems: "flex-start",
|
|
163
|
-
}}
|
|
164
|
-
rightAccessory={<Icon icon={icons.caretRight} size="small" />}
|
|
165
|
-
rightAccessoryStyle={{
|
|
166
|
-
minWidth: Spacing.large_24,
|
|
167
|
-
alignSelf: "flex-end",
|
|
168
|
-
alignItems: "flex-end",
|
|
169
|
-
}}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
|
|
173
|
-
CompactCellAccessoryStyles.storyName =
|
|
174
|
-
"CompactCell accessories with custom styles";
|
|
175
|
-
|
|
176
|
-
CompactCellAccessoryStyles.parameters = {
|
|
177
|
-
docs: {
|
|
178
|
-
storyDescription:
|
|
179
|
-
"Accessories can also be customized to adapt to different sizes and alignments. In this example, we can see how a cell can be customized for both accessories.",
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Defining horizontal rule variants
|
|
185
|
-
*/
|
|
186
|
-
export const CompactCellHorizontalRules: StoryComponentType = () => (
|
|
187
|
-
<>
|
|
188
|
-
<CompactCell
|
|
189
|
-
title="This is a basic cell with an 'inset' horizontal rule"
|
|
190
|
-
leftAccessory={<Icon icon={icons.contentArticle} size="medium" />}
|
|
191
|
-
horizontalRule="inset"
|
|
192
|
-
/>
|
|
193
|
-
<CompactCell
|
|
194
|
-
title="This is a basic cell with a 'full-width' horizontal rule"
|
|
195
|
-
leftAccessory={<Icon icon={icons.contentArticle} size="medium" />}
|
|
196
|
-
horizontalRule="full-width"
|
|
197
|
-
/>
|
|
198
|
-
<CompactCell
|
|
199
|
-
title="This is a basic cell without a horizontal rule"
|
|
200
|
-
leftAccessory={<Icon icon={icons.contentArticle} size="medium" />}
|
|
201
|
-
horizontalRule="none"
|
|
202
|
-
/>
|
|
203
|
-
</>
|
|
204
|
-
);
|
|
205
|
-
|
|
206
|
-
CompactCellHorizontalRules.storyName = "Defining horizontal rule variants";
|
|
207
|
-
|
|
208
|
-
CompactCellHorizontalRules.parameters = {
|
|
209
|
-
docs: {
|
|
210
|
-
storyDescription:
|
|
211
|
-
"Cell components can use the `horizontalRule` prop to use a set of predefined variants that we can use to match our needs.",
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
export const CompactCellWithCustomStyles: StoryComponentType = () => (
|
|
216
|
-
<CompactCell
|
|
217
|
-
title="CompactCell with a darkBlue background"
|
|
218
|
-
leftAccessory={<Icon icon={icons.contentArticle} size="medium" />}
|
|
219
|
-
rightAccessory={<Icon icon={calendarIcon} color={Color.white} />}
|
|
220
|
-
style={{
|
|
221
|
-
background: Color.darkBlue,
|
|
222
|
-
color: Color.white,
|
|
223
|
-
}}
|
|
224
|
-
onClick={() => {}}
|
|
225
|
-
/>
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
CompactCellWithCustomStyles.parameters = {
|
|
229
|
-
docs: {
|
|
230
|
-
storyDescription:
|
|
231
|
-
"Cell components can also adapt to different visual needs. One example of this can be done by passing a custom style object to the `style` prop.",
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
/*
|
|
236
|
-
* CompactCell with onClick set
|
|
237
|
-
|
|
238
|
-
*/
|
|
239
|
-
|
|
240
|
-
export const ClickableCompactCell: StoryComponentType = () => (
|
|
241
|
-
<CompactCell
|
|
242
|
-
title="Intro to rational & irrational numbers"
|
|
243
|
-
rightAccessory={<Icon icon={icons.caretRight} />}
|
|
244
|
-
onClick={() => {}}
|
|
245
|
-
aria-label="Press to navigate to the article"
|
|
246
|
-
/>
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
ClickableCompactCell.parameters = {
|
|
250
|
-
chromatic: {
|
|
251
|
-
// This only includes interactions with the clickable cell, so no need
|
|
252
|
-
// to capture screenshots.
|
|
253
|
-
disableSnapshot: true,
|
|
254
|
-
},
|
|
255
|
-
docs: {
|
|
256
|
-
storyDescription:
|
|
257
|
-
"Cell components can also also be clickable. This is done by passing a `onClick` prop to the component.",
|
|
258
|
-
},
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
export const CompactCellActive: StoryComponentType = () => (
|
|
262
|
-
<CompactCell
|
|
263
|
-
title="Title for article item"
|
|
264
|
-
leftAccessory={
|
|
265
|
-
<Icon icon={icons.contentVideo} size="medium" color="black" />
|
|
266
|
-
}
|
|
267
|
-
rightAccessory={<Icon icon={calendarIcon} size="small" />}
|
|
268
|
-
active={true}
|
|
269
|
-
onClick={() => {}}
|
|
270
|
-
/>
|
|
271
|
-
);
|
|
272
|
-
|
|
273
|
-
CompactCellActive.parameters = {
|
|
274
|
-
docs: {
|
|
275
|
-
storyDescription:
|
|
276
|
-
"The cell also supports different states within itself. The different styles are defined internally (e.g hover, focused, pressed, active, disabled) and we allow passing some props to use the `active` or `disabled` state.",
|
|
277
|
-
},
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
export const CompactCellDisabled: StoryComponentType = () => (
|
|
281
|
-
<CompactCell
|
|
282
|
-
title="Title for article item"
|
|
283
|
-
leftAccessory={AccessoryMappings.withImage}
|
|
284
|
-
rightAccessory={<Icon icon={calendarIcon} size="small" />}
|
|
285
|
-
disabled={true}
|
|
286
|
-
onClick={() => {}}
|
|
287
|
-
/>
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
CompactCellDisabled.parameters = {
|
|
291
|
-
docs: {
|
|
292
|
-
storyDescription:
|
|
293
|
-
"In the following example we can see how the `disabled` state works. Note that we apply an opacity to all the elements to make it more apparent that the cell is disabled. This includes text, SVG icons, images, etc.",
|
|
294
|
-
},
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
const styles = StyleSheet.create({
|
|
298
|
-
example: {
|
|
299
|
-
backgroundColor: Color.offWhite,
|
|
300
|
-
padding: Spacing.large_24,
|
|
301
|
-
width: 320 + Spacing.xxLarge_48,
|
|
302
|
-
},
|
|
303
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import CompactCellArgTypes from "./compact-cell.argtypes";
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
...CompactCellArgTypes,
|
|
6
|
-
subtitle1: {
|
|
7
|
-
control: {
|
|
8
|
-
type: "text",
|
|
9
|
-
},
|
|
10
|
-
table: {
|
|
11
|
-
category: "Layout",
|
|
12
|
-
type: {
|
|
13
|
-
detail: "string | React.Element<Typography>",
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
subtitle2: {
|
|
18
|
-
control: {
|
|
19
|
-
type: "text",
|
|
20
|
-
},
|
|
21
|
-
table: {
|
|
22
|
-
category: "Layout",
|
|
23
|
-
type: {
|
|
24
|
-
detail: "string | React.Element<Typography>",
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
};
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import {StyleSheet} from "aphrodite";
|
|
4
|
-
import {MemoryRouter, Route, Switch} from "react-router-dom";
|
|
5
|
-
|
|
6
|
-
import {View} from "@khanacademy/wonder-blocks-core";
|
|
7
|
-
import Color from "@khanacademy/wonder-blocks-color";
|
|
8
|
-
import Spacing from "@khanacademy/wonder-blocks-spacing";
|
|
9
|
-
import Icon, {icons} from "@khanacademy/wonder-blocks-icon";
|
|
10
|
-
|
|
11
|
-
import type {StoryComponentType} from "@storybook/react";
|
|
12
|
-
|
|
13
|
-
import ComponentInfo from "../../../../../.storybook/components/component-info";
|
|
14
|
-
import {name, version} from "../../../package.json";
|
|
15
|
-
import DetailCellArgTypes from "./detail-cell.argtypes";
|
|
16
|
-
|
|
17
|
-
import DetailCell from "../detail-cell";
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
title: "Cell / DetailCell",
|
|
21
|
-
component: DetailCell,
|
|
22
|
-
argTypes: DetailCellArgTypes,
|
|
23
|
-
parameters: {
|
|
24
|
-
componentSubtitle: ((
|
|
25
|
-
<ComponentInfo name={name} version={version} />
|
|
26
|
-
): any),
|
|
27
|
-
docs: {
|
|
28
|
-
description: {
|
|
29
|
-
component: null,
|
|
30
|
-
},
|
|
31
|
-
source: {
|
|
32
|
-
// See https://github.com/storybookjs/storybook/issues/12596
|
|
33
|
-
excludeDecorators: true,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
decorators: [
|
|
38
|
-
(Story: any): React.Node => (
|
|
39
|
-
<View style={styles.example}>{Story()}</View>
|
|
40
|
-
),
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Default DetailCell example. It will be rendered as the first/default story and
|
|
46
|
-
* it can be interacted with the controls panel in the Browser.
|
|
47
|
-
*/
|
|
48
|
-
const Template = (args) => <DetailCell {...args} />;
|
|
49
|
-
|
|
50
|
-
export const DefaultDetailCell: StoryComponentType = Template.bind({});
|
|
51
|
-
|
|
52
|
-
DefaultDetailCell.args = {
|
|
53
|
-
title: "Title for article item",
|
|
54
|
-
subtitle1: "Subtitle 1 for article item",
|
|
55
|
-
subtitle2: "Subtitle 2 for article item",
|
|
56
|
-
leftAccessory: <Icon icon={icons.contentVideo} size="medium" />,
|
|
57
|
-
rightAccessory: <Icon icon={icons.caretRight} />,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Active detail cell example.
|
|
62
|
-
*/
|
|
63
|
-
export const DetailCellActive: StoryComponentType = () => (
|
|
64
|
-
<DetailCell
|
|
65
|
-
title="Title for article item"
|
|
66
|
-
subtitle1="Subtitle for article item"
|
|
67
|
-
subtitle2="Subtitle for article item"
|
|
68
|
-
leftAccessory={<Icon icon={icons.contentVideo} size="medium" />}
|
|
69
|
-
rightAccessory={<Icon icon={icons.caretRight} size="small" />}
|
|
70
|
-
active={true}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
DetailCellActive.parameters = {
|
|
75
|
-
docs: {
|
|
76
|
-
storyDescription:
|
|
77
|
-
"For more complex scenarios where we need to use more content such as subtitles, we provide a DetailCell component that can be used to cover these cases. The following example shows how to include a subtitle and use the active state.",
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Disabled detail cell example.
|
|
83
|
-
*/
|
|
84
|
-
export const DetailCellDisabled: StoryComponentType = () => (
|
|
85
|
-
<DetailCell
|
|
86
|
-
title="Title for article item"
|
|
87
|
-
subtitle1="Subtitle for article item"
|
|
88
|
-
subtitle2="Subtitle for article item"
|
|
89
|
-
leftAccessory={<Icon icon={icons.contentVideo} size="medium" />}
|
|
90
|
-
rightAccessory={<Icon icon={icons.caretRight} size="small" />}
|
|
91
|
-
disabled={true}
|
|
92
|
-
/>
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
DetailCellDisabled.parameters = {
|
|
96
|
-
docs: {
|
|
97
|
-
storyDescription:
|
|
98
|
-
"For more complex scenarios where we need to use more content such as subtitles, we provide a DetailCell component that can be used to cover these cases. The following example shows how to include a subtitle and use the active state.",
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Using custom styles.
|
|
104
|
-
*/
|
|
105
|
-
export const DetailCellWithCustomStyles: StoryComponentType = () => (
|
|
106
|
-
<DetailCell
|
|
107
|
-
title="Title for article item"
|
|
108
|
-
subtitle1="Subtitle for article item"
|
|
109
|
-
subtitle2="Subtitle for article item"
|
|
110
|
-
leftAccessory={<Icon icon={icons.caretLeft} size="small" />}
|
|
111
|
-
leftAccessoryStyle={{
|
|
112
|
-
alignSelf: "flex-start",
|
|
113
|
-
}}
|
|
114
|
-
rightAccessory={<Icon icon={icons.caretRight} size="small" />}
|
|
115
|
-
rightAccessoryStyle={{
|
|
116
|
-
alignSelf: "flex-start",
|
|
117
|
-
}}
|
|
118
|
-
style={{
|
|
119
|
-
textAlign: "center",
|
|
120
|
-
}}
|
|
121
|
-
/>
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
DetailCellWithCustomStyles.parameters = {
|
|
125
|
-
docs: {
|
|
126
|
-
storyDescription:
|
|
127
|
-
"Accessories can also be customized to adapt to different sizes and alignments. In this example, we can see how a cell can be customized for both accessories. ",
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const ClickableDetailCell: StoryComponentType = () => (
|
|
132
|
-
<DetailCell
|
|
133
|
-
title="Title for article item"
|
|
134
|
-
subtitle1="Subtitle for article item"
|
|
135
|
-
subtitle2="Subtitle for article item"
|
|
136
|
-
leftAccessory={<Icon icon={icons.contentVideo} size="medium" />}
|
|
137
|
-
rightAccessory={<Icon icon={icons.caretRight} />}
|
|
138
|
-
onClick={() => {}}
|
|
139
|
-
aria-label="Press to navigate to the article"
|
|
140
|
-
/>
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
ClickableDetailCell.parameters = {
|
|
144
|
-
chromatic: {
|
|
145
|
-
// This only includes interactions with the clickable cell, so no need
|
|
146
|
-
// to capture screenshots.
|
|
147
|
-
disableSnapshot: true,
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const DetailCellNavigation: StoryComponentType = () => (
|
|
152
|
-
<MemoryRouter>
|
|
153
|
-
<View>
|
|
154
|
-
<DetailCell
|
|
155
|
-
title="Data"
|
|
156
|
-
subtitle2="Subtitle for article item"
|
|
157
|
-
leftAccessory={<Icon icon={icons.contentVideo} size="medium" />}
|
|
158
|
-
rightAccessory={<Icon icon={icons.caretRight} />}
|
|
159
|
-
href="/math/algebra"
|
|
160
|
-
aria-label="Press to navigate to the article"
|
|
161
|
-
/>
|
|
162
|
-
<DetailCell
|
|
163
|
-
title="Geometry"
|
|
164
|
-
subtitle2="Subtitle for article item"
|
|
165
|
-
leftAccessory={<Icon icon={icons.contentVideo} size="medium" />}
|
|
166
|
-
rightAccessory={<Icon icon={icons.caretRight} />}
|
|
167
|
-
href="/math/geometry"
|
|
168
|
-
aria-label="Press to navigate to the article"
|
|
169
|
-
horizontalRule="none"
|
|
170
|
-
/>
|
|
171
|
-
</View>
|
|
172
|
-
|
|
173
|
-
<View style={styles.navigation}>
|
|
174
|
-
<Switch>
|
|
175
|
-
<Route path="/math/algebra">Navigates to /math/algebra</Route>
|
|
176
|
-
<Route path="/math/geometry">Navigates to /math/geometry</Route>
|
|
177
|
-
<Route path="*">See navigation changes here</Route>
|
|
178
|
-
</Switch>
|
|
179
|
-
</View>
|
|
180
|
-
</MemoryRouter>
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
DetailCellNavigation.storyName = "Client-side navigation with DetailCell";
|
|
184
|
-
|
|
185
|
-
DetailCellNavigation.parameters = {
|
|
186
|
-
chromatic: {
|
|
187
|
-
// This only includes interactions with the clickable cell, so no need
|
|
188
|
-
// to capture screenshots.
|
|
189
|
-
disableSnapshot: true,
|
|
190
|
-
},
|
|
191
|
-
docs: {
|
|
192
|
-
storyDescription:
|
|
193
|
-
"Cells accept an `href` prop to be able to navigate to a different URL. Note that this will use client-side navigation if the Cell component is within a React-Router environment.",
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const styles = StyleSheet.create({
|
|
198
|
-
example: {
|
|
199
|
-
backgroundColor: Color.offWhite,
|
|
200
|
-
padding: Spacing.large_24,
|
|
201
|
-
width: 376,
|
|
202
|
-
},
|
|
203
|
-
navigation: {
|
|
204
|
-
border: `1px dashed ${Color.lightBlue}`,
|
|
205
|
-
marginTop: Spacing.large_24,
|
|
206
|
-
padding: Spacing.large_24,
|
|
207
|
-
},
|
|
208
|
-
});
|