@khanacademy/wonder-blocks-cell 2.2.14 → 2.2.16

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 (33) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/components/compact-cell.d.ts +22 -0
  3. package/dist/components/compact-cell.js.flow +30 -0
  4. package/dist/components/detail-cell.d.ts +39 -0
  5. package/dist/components/detail-cell.js.flow +51 -0
  6. package/dist/components/internal/cell-core.d.ts +26 -0
  7. package/dist/components/internal/cell-core.js.flow +38 -0
  8. package/dist/components/internal/common.d.ts +30 -0
  9. package/dist/components/internal/common.js.flow +45 -0
  10. package/dist/es/index.js +40 -32
  11. package/dist/index.d.ts +3 -0
  12. package/dist/index.js +57 -51
  13. package/dist/index.js.flow +10 -2
  14. package/dist/util/types.d.ts +122 -0
  15. package/dist/util/types.js.flow +148 -0
  16. package/package.json +9 -9
  17. package/src/components/__tests__/{compact-cell.test.js → compact-cell.test.tsx} +1 -2
  18. package/src/components/__tests__/{detail-cell.test.js → detail-cell.test.tsx} +1 -2
  19. package/src/components/{compact-cell.js → compact-cell.tsx} +4 -5
  20. package/src/components/{detail-cell.js → detail-cell.tsx} +20 -18
  21. package/src/components/internal/__tests__/{cell-core.test.js → cell-core.test.tsx} +1 -2
  22. package/src/components/internal/__tests__/{common.test.js → common.test.ts} +1 -3
  23. package/src/components/internal/{cell-core.js → cell-core.tsx} +28 -27
  24. package/src/components/internal/{common.js → common.ts} +2 -3
  25. package/src/index.ts +4 -0
  26. package/src/util/{types.js → types.ts} +25 -39
  27. package/tsconfig.json +17 -0
  28. package/tsconfig.tsbuildinfo +1 -0
  29. package/src/components/__docs__/compact-cell.argtypes.js +0 -189
  30. package/src/components/__docs__/compact-cell.stories.js +0 -305
  31. package/src/components/__docs__/detail-cell.argtypes.js +0 -28
  32. package/src/components/__docs__/detail-cell.stories.js +0 -208
  33. package/src/index.js +0 -5
@@ -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.js";
14
- import {name, version} from "../../../package.json";
15
- import DetailCellArgTypes from "./detail-cell.argtypes.js";
16
-
17
- import DetailCell from "../detail-cell.js";
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
- });
package/src/index.js DELETED
@@ -1,5 +0,0 @@
1
- // @flow
2
- import CompactCell from "./components/compact-cell.js";
3
- import DetailCell from "./components/detail-cell.js";
4
-
5
- export {CompactCell, DetailCell};