@khanacademy/wonder-blocks-toolbar 2.1.35 → 2.1.36

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @khanacademy/wonder-blocks-toolbar
2
2
 
3
+ ## 2.1.36
4
+
5
+ ### Patch Changes
6
+
7
+ - f3bcc1a9: Modify layout to be more flexible
8
+
3
9
  ## 2.1.35
4
10
 
5
11
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import { StyleSheet } from 'aphrodite';
3
3
  import Color from '@khanacademy/wonder-blocks-color';
4
4
  import { View } from '@khanacademy/wonder-blocks-core';
5
+ import Spacing from '@khanacademy/wonder-blocks-spacing';
5
6
  import { LabelSmall, LabelLarge, HeadingSmall } from '@khanacademy/wonder-blocks-typography';
6
7
 
7
8
  class Toolbar extends React.Component {
@@ -18,22 +19,18 @@ class Toolbar extends React.Component {
18
19
  return React.createElement(View, {
19
20
  style: [sharedStyles.container, color === "dark" && sharedStyles.dark, size === "small" && sharedStyles.small]
20
21
  }, React.createElement(View, {
21
- style: sharedStyles.column
22
- }, React.createElement(View, {
23
- style: sharedStyles.leftColumn
24
- }, leftContent)), title && React.createElement(View, {
22
+ style: [sharedStyles.column, sharedStyles.leftColumn, title ? sharedStyles.withTitle : null]
23
+ }, leftContent), title && React.createElement(View, {
25
24
  style: [sharedStyles.column, sharedStyles.wideColumn]
26
25
  }, React.createElement(View, {
27
- style: [sharedStyles.titles, sharedStyles.verticalAlign, sharedStyles.center]
26
+ style: [sharedStyles.titles, sharedStyles.center]
28
27
  }, React.createElement(TitleComponent, {
29
28
  id: "wb-toolbar-title"
30
29
  }, title), subtitle && React.createElement(LabelSmall, {
31
30
  style: color === "light" && sharedStyles.subtitle
32
31
  }, subtitle))), React.createElement(View, {
33
- style: sharedStyles.column
34
- }, React.createElement(View, {
35
- style: sharedStyles.rightColumn
36
- }, rightContent)));
32
+ style: [sharedStyles.column, sharedStyles.rightColumn, title ? sharedStyles.withTitle : null]
33
+ }, rightContent));
37
34
  }
38
35
 
39
36
  }
@@ -45,13 +42,13 @@ Toolbar.defaultProps = {
45
42
  };
46
43
  const sharedStyles = StyleSheet.create({
47
44
  container: {
48
- border: "1px solid rgba(33, 36, 44, 0.16)",
49
- display: "flex",
45
+ border: `1px solid ${Color.offBlack16}`,
46
+ flex: 1,
50
47
  flexDirection: "row",
48
+ justifyContent: "space-between",
51
49
  minHeight: 66,
52
- paddingLeft: 16,
53
- paddingRight: 16,
54
- position: "relative",
50
+ paddingLeft: Spacing.medium_16,
51
+ paddingRight: Spacing.medium_16,
55
52
  width: "100%"
56
53
  },
57
54
  small: {
@@ -59,22 +56,23 @@ const sharedStyles = StyleSheet.create({
59
56
  },
60
57
  dark: {
61
58
  backgroundColor: Color.darkBlue,
62
- boxShadow: "0 1px 0 0 rgba(255, 255, 255, 0.64)",
59
+ boxShadow: `0 1px 0 0 ${Color.white64}`,
63
60
  color: "white"
64
61
  },
65
- verticalAlign: {
66
- justifyContent: "center"
67
- },
68
62
  column: {
69
- flex: 1,
70
63
  justifyContent: "center"
71
64
  },
65
+ withTitle: {
66
+ flex: 1
67
+ },
72
68
  wideColumn: {
69
+ flex: 1,
73
70
  flexBasis: "50%"
74
71
  },
75
72
  leftColumn: {
76
73
  alignItems: "center",
77
74
  flexDirection: "row",
75
+ flexShrink: 0,
78
76
  justifyContent: "flex-start"
79
77
  },
80
78
  rightColumn: {
@@ -86,10 +84,10 @@ const sharedStyles = StyleSheet.create({
86
84
  textAlign: "center"
87
85
  },
88
86
  subtitle: {
89
- color: "rgba(33, 36, 44, 0.64)"
87
+ color: Color.offBlack64
90
88
  },
91
89
  titles: {
92
- padding: 12
90
+ padding: Spacing.small_12
93
91
  }
94
92
  });
95
93
 
package/dist/index.js CHANGED
@@ -82,7 +82,7 @@ module.exports =
82
82
  /******/
83
83
  /******/
84
84
  /******/ // Load entry module and return exports
85
- /******/ return __webpack_require__(__webpack_require__.s = 6);
85
+ /******/ return __webpack_require__(__webpack_require__.s = 7);
86
86
  /******/ })
87
87
  /************************************************************************/
88
88
  /******/ ([
@@ -101,24 +101,38 @@ module.exports = require("@khanacademy/wonder-blocks-core");
101
101
  /* 2 */
102
102
  /***/ (function(module, exports) {
103
103
 
104
- module.exports = require("@khanacademy/wonder-blocks-typography");
104
+ module.exports = require("@khanacademy/wonder-blocks-color");
105
105
 
106
106
  /***/ }),
107
107
  /* 3 */
108
+ /***/ (function(module, exports) {
109
+
110
+ module.exports = require("@khanacademy/wonder-blocks-spacing");
111
+
112
+ /***/ }),
113
+ /* 4 */
114
+ /***/ (function(module, exports) {
115
+
116
+ module.exports = require("@khanacademy/wonder-blocks-typography");
117
+
118
+ /***/ }),
119
+ /* 5 */
108
120
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
109
121
 
110
122
  "use strict";
111
123
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Toolbar; });
112
124
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
113
125
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
114
- /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
126
+ /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
115
127
  /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
116
- /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
128
+ /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
117
129
  /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2__);
118
130
  /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
119
131
  /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__);
120
- /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2);
121
- /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__);
132
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3);
133
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4__);
134
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(4);
135
+ /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__);
122
136
  /*
123
137
  * A toolbar component that often acts as a container header.
124
138
  */
@@ -127,6 +141,25 @@ module.exports = require("@khanacademy/wonder-blocks-typography");
127
141
 
128
142
 
129
143
 
144
+
145
+
146
+ /**
147
+ * The `Toolbar` component is a generic toolbar wrapper that exposes
148
+ * customization options. An optional `title` and `subtitle` property can be
149
+ * used along with left and right content passed as props.
150
+ *
151
+ * ### Usage
152
+ *
153
+ * ```jsx
154
+ * import Toolbar from "@khanacademy/wonder-blocks-toolbar";
155
+ *
156
+ * <Toolbar
157
+ * size="small"
158
+ * leftContent={<IconButton icon={icons.dismiss} kind="tertiary" />}
159
+ * rightContent={<Button>Next Video</Button>}
160
+ * />
161
+ * ```
162
+ */
130
163
  class Toolbar extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
131
164
  render() {
132
165
  const {
@@ -137,26 +170,22 @@ class Toolbar extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
137
170
  subtitle,
138
171
  title
139
172
  } = this.props;
140
- const TitleComponent = subtitle ? _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelLarge"] : _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["HeadingSmall"];
173
+ const TitleComponent = subtitle ? _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__["LabelLarge"] : _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__["HeadingSmall"];
141
174
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
142
175
  style: [sharedStyles.container, color === "dark" && sharedStyles.dark, size === "small" && sharedStyles.small]
143
176
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
144
- style: sharedStyles.column
145
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
146
- style: sharedStyles.leftColumn
147
- }, leftContent)), title && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
177
+ style: [sharedStyles.column, sharedStyles.leftColumn, title ? sharedStyles.withTitle : null]
178
+ }, leftContent), title && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
148
179
  style: [sharedStyles.column, sharedStyles.wideColumn]
149
180
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
150
- style: [sharedStyles.titles, sharedStyles.verticalAlign, sharedStyles.center]
181
+ style: [sharedStyles.titles, sharedStyles.center]
151
182
  }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](TitleComponent, {
152
183
  id: "wb-toolbar-title"
153
- }, title), subtitle && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"], {
184
+ }, title), subtitle && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_5__["LabelSmall"], {
154
185
  style: color === "light" && sharedStyles.subtitle
155
186
  }, subtitle))), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
156
- style: sharedStyles.column
157
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_3__["View"], {
158
- style: sharedStyles.rightColumn
159
- }, rightContent)));
187
+ style: [sharedStyles.column, sharedStyles.rightColumn, title ? sharedStyles.withTitle : null]
188
+ }, rightContent));
160
189
  }
161
190
 
162
191
  }
@@ -168,13 +197,13 @@ Toolbar.defaultProps = {
168
197
  };
169
198
  const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
170
199
  container: {
171
- border: "1px solid rgba(33, 36, 44, 0.16)",
172
- display: "flex",
200
+ border: `1px solid ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack16}`,
201
+ flex: 1,
173
202
  flexDirection: "row",
203
+ justifyContent: "space-between",
174
204
  minHeight: 66,
175
- paddingLeft: 16,
176
- paddingRight: 16,
177
- position: "relative",
205
+ paddingLeft: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16,
206
+ paddingRight: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.medium_16,
178
207
  width: "100%"
179
208
  },
180
209
  small: {
@@ -182,22 +211,25 @@ const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create
182
211
  },
183
212
  dark: {
184
213
  backgroundColor: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.darkBlue,
185
- boxShadow: "0 1px 0 0 rgba(255, 255, 255, 0.64)",
214
+ boxShadow: `0 1px 0 0 ${_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.white64}`,
186
215
  color: "white"
187
216
  },
188
- verticalAlign: {
189
- justifyContent: "center"
190
- },
191
217
  column: {
192
- flex: 1,
193
218
  justifyContent: "center"
194
219
  },
220
+ withTitle: {
221
+ flex: 1
222
+ },
195
223
  wideColumn: {
224
+ flex: 1,
196
225
  flexBasis: "50%"
197
226
  },
198
227
  leftColumn: {
199
228
  alignItems: "center",
200
229
  flexDirection: "row",
230
+ // TODO(WB-1445): Find a way to replicate this behavior with
231
+ // rightContent.
232
+ flexShrink: 0,
201
233
  justifyContent: "flex-start"
202
234
  },
203
235
  rightColumn: {
@@ -209,32 +241,26 @@ const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create
209
241
  textAlign: "center"
210
242
  },
211
243
  subtitle: {
212
- color: "rgba(33, 36, 44, 0.64)"
244
+ color: _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_2___default.a.offBlack64
213
245
  },
214
246
  titles: {
215
- padding: 12
247
+ padding: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_4___default.a.small_12
216
248
  }
217
249
  });
218
250
 
219
251
  /***/ }),
220
- /* 4 */
252
+ /* 6 */
221
253
  /***/ (function(module, exports) {
222
254
 
223
255
  module.exports = require("aphrodite");
224
256
 
225
257
  /***/ }),
226
- /* 5 */
227
- /***/ (function(module, exports) {
228
-
229
- module.exports = require("@khanacademy/wonder-blocks-color");
230
-
231
- /***/ }),
232
- /* 6 */
258
+ /* 7 */
233
259
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
234
260
 
235
261
  "use strict";
236
262
  __webpack_require__.r(__webpack_exports__);
237
- /* harmony import */ var _components_toolbar_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
263
+ /* harmony import */ var _components_toolbar_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
238
264
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "default", function() { return _components_toolbar_js__WEBPACK_IMPORTED_MODULE_0__["a"]; });
239
265
 
240
266
 
package/docs.md CHANGED
@@ -1 +1,5 @@
1
- The Toolbar component is a generic toolbar wrapper that exposes customization options. An optional title and subtitle property can be used along with left and right content passed as props.
1
+ Documentation for `@khanacademy/wonder-blocks-toolbar` is now in Storybook.
2
+
3
+ Visit the [Storybook
4
+ Toolbar](https://khan.github.io/wonder-blocks/?path=/docs/toolbar) docs on GitHub
5
+ Pages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-toolbar",
3
- "version": "2.1.35",
3
+ "version": "2.1.36",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,6 +18,7 @@
18
18
  "@babel/runtime": "^7.18.6",
19
19
  "@khanacademy/wonder-blocks-color": "^1.2.0",
20
20
  "@khanacademy/wonder-blocks-core": "^4.5.0",
21
+ "@khanacademy/wonder-blocks-spacing": "^3.0.5",
21
22
  "@khanacademy/wonder-blocks-typography": "^1.1.34"
22
23
  },
23
24
  "peerDependencies": {
@@ -0,0 +1,94 @@
1
+ // @flow
2
+ import * as React from "react";
3
+ import {StyleSheet} from "aphrodite";
4
+
5
+ import Button from "@khanacademy/wonder-blocks-button";
6
+ import {icons} from "@khanacademy/wonder-blocks-icon";
7
+ import IconButton from "@khanacademy/wonder-blocks-icon-button";
8
+ import {Strut} from "@khanacademy/wonder-blocks-layout";
9
+ import Link from "@khanacademy/wonder-blocks-link";
10
+ import Spacing from "@khanacademy/wonder-blocks-spacing";
11
+ import {LabelLarge} from "@khanacademy/wonder-blocks-typography";
12
+
13
+ const mobile = "@media (max-width: 1023px)";
14
+
15
+ const styles = StyleSheet.create({
16
+ fillContent: {
17
+ marginLeft: Spacing.small_12,
18
+ [mobile]: {
19
+ width: "100vw",
20
+ },
21
+ },
22
+ onlyDesktop: {
23
+ [mobile]: {
24
+ display: "none",
25
+ },
26
+ },
27
+ });
28
+
29
+ type Mappings = {[key: string]: React.Node};
30
+
31
+ export const leftContentMappings: Mappings = {
32
+ none: null,
33
+ dismissButton: <IconButton icon={icons.dismiss} kind="tertiary" />,
34
+ lightButton: <IconButton icon={icons.dismiss} light={true} />,
35
+ hintButton: <IconButton icon={icons.hint} kind="primary" />,
36
+ multipleContent: (
37
+ <>
38
+ <IconButton icon={icons.zoomOut} kind="primary" />
39
+ <Strut size={Spacing.medium_16} />
40
+ <IconButton icon={icons.zoomIn} kind="primary" />
41
+ </>
42
+ ),
43
+ };
44
+
45
+ const buttonStyle = {width: 160};
46
+
47
+ export const rightContentMappings: Mappings = {
48
+ none: null,
49
+ primaryButton: <Button>Submit</Button>,
50
+ tertiaryButton: <Button kind="tertiary">Import...</Button>,
51
+ nextVideoButton: <Button>Next Video</Button>,
52
+ lightButton: (
53
+ <Button kind="secondary" light={true}>
54
+ Go to Article
55
+ </Button>
56
+ ),
57
+ link: (
58
+ <Link href="#">
59
+ <LabelLarge>Go to exercise</LabelLarge>
60
+ </Link>
61
+ ),
62
+ multipleContent: (
63
+ <>
64
+ <LabelLarge>7 questions</LabelLarge>
65
+ <Strut size={Spacing.medium_16} />
66
+ <Button style={buttonStyle} kind="secondary">
67
+ Try again
68
+ </Button>
69
+ <Strut size={Spacing.medium_16} />
70
+ <Button style={buttonStyle}>Next exercise</Button>
71
+ </>
72
+ ),
73
+ responsive: (
74
+ <>
75
+ <Button style={styles.onlyDesktop} kind="secondary">
76
+ Continue
77
+ </Button>
78
+ <Button style={styles.fillContent}>Up next: video</Button>
79
+ </>
80
+ ),
81
+ };
82
+
83
+ export default {
84
+ leftContent: {
85
+ control: {type: "select"},
86
+ options: (Object.keys(leftContentMappings): Array<string>),
87
+ mapping: leftContentMappings,
88
+ },
89
+ rightContent: {
90
+ control: {type: "select"},
91
+ options: (Object.keys(rightContentMappings): Array<string>),
92
+ mapping: rightContentMappings,
93
+ },
94
+ };
@@ -0,0 +1,210 @@
1
+ // @flow
2
+ import * as React from "react";
3
+ import {StyleSheet} from "aphrodite";
4
+
5
+ import {View} from "@khanacademy/wonder-blocks-core";
6
+ import Spacing from "@khanacademy/wonder-blocks-spacing";
7
+ import Toolbar from "@khanacademy/wonder-blocks-toolbar";
8
+
9
+ import type {StoryComponentType} from "@storybook/react";
10
+ import ComponentInfo from "../../../../../.storybook/components/component-info.js";
11
+ import {name, version} from "../../../package.json";
12
+ import ToolbarArgtypes, {
13
+ leftContentMappings,
14
+ rightContentMappings,
15
+ } from "./toolbar.argtypes.js";
16
+
17
+ export default {
18
+ title: "Toolbar / Toolbar",
19
+ component: Toolbar,
20
+ argTypes: ToolbarArgtypes,
21
+ parameters: {
22
+ componentSubtitle: ((
23
+ <ComponentInfo name={name} version={version} />
24
+ ): any),
25
+ docs: {
26
+ description: {
27
+ component: null,
28
+ },
29
+ source: {
30
+ // See https://github.com/storybookjs/storybook/issues/12596
31
+ excludeDecorators: true,
32
+ },
33
+ },
34
+ },
35
+ decorators: [
36
+ (Story: any): React.Element<typeof View> => (
37
+ <View style={styles.example}>{Story()}</View>
38
+ ),
39
+ ],
40
+ };
41
+
42
+ const styles = StyleSheet.create({
43
+ example: {
44
+ padding: Spacing.large_24,
45
+ alignItems: "center",
46
+ justifyContent: "center",
47
+ },
48
+ });
49
+
50
+ const Template = (args) => <Toolbar {...args} />;
51
+
52
+ /**
53
+ * Default example (interactive).
54
+ *
55
+ * A toolbar with left and right content.
56
+ */
57
+ export const Default: StoryComponentType = Template.bind({});
58
+
59
+ Default.args = {
60
+ title: "Counting with small numbers",
61
+ leftContent: leftContentMappings.dismissButton,
62
+ rightContent: rightContentMappings.nextVideoButton,
63
+ };
64
+
65
+ /**
66
+ * Small toolbar with multiple left side buttons.
67
+ */
68
+ export const Small: StoryComponentType = Template.bind({});
69
+
70
+ Small.args = {
71
+ size: "small",
72
+ leftContent: leftContentMappings.multipleContent,
73
+ rightContent: rightContentMappings.tertiaryButton,
74
+ };
75
+
76
+ Small.parameters = {
77
+ docs: {
78
+ description: {
79
+ story:
80
+ "A small toolbar with content on both sides.\n\n" +
81
+ "**Note:** The `IconButton`s are nudged to the left by 1px to match designs.",
82
+ },
83
+ },
84
+ };
85
+
86
+ /**
87
+ * Toolbar with left icon button and right primary button.
88
+ */
89
+ export const Medium: StoryComponentType = Template.bind({});
90
+
91
+ Medium.args = {
92
+ leftContent: leftContentMappings.hintButton,
93
+ rightContent: rightContentMappings.primaryButton,
94
+ };
95
+
96
+ Medium.parameters = {
97
+ docs: {
98
+ description: {
99
+ story:
100
+ "A toolbar with content on both sides. Note that for this example, we are using the default size (`medium`).\n\n" +
101
+ "**Note:** The `IconButton` is nudged to the left by 6px to match designs.",
102
+ },
103
+ },
104
+ };
105
+
106
+ /**
107
+ * Toolbar with title.
108
+ */
109
+ export const WithTitle: StoryComponentType = Template.bind({});
110
+
111
+ WithTitle.args = {
112
+ leftContent: leftContentMappings.dismissButton,
113
+ title: "Counting with small numbers",
114
+ };
115
+
116
+ WithTitle.parameters = {
117
+ docs: {
118
+ description: {
119
+ story:
120
+ "A toolbar that shows how we can combine a title and a dismiss button on the left side.\n\n" +
121
+ "**Note:** The `IconButton` is nudged to the left by 6px to match designs.",
122
+ },
123
+ },
124
+ };
125
+
126
+ /**
127
+ * Toolbar with multiple elements on the right.
128
+ */
129
+ export const WithMultipleElements: StoryComponentType = Template.bind({});
130
+
131
+ WithMultipleElements.args = {
132
+ rightContent: rightContentMappings.multipleContent,
133
+ };
134
+
135
+ WithMultipleElements.parameters = {
136
+ docs: {
137
+ description: {
138
+ story: "This toolbar includes multiple elements on the right.",
139
+ },
140
+ },
141
+ };
142
+
143
+ /**
144
+ * Header overflow text.
145
+ */
146
+ export const HeaderOverflowText: StoryComponentType = Template.bind({});
147
+
148
+ HeaderOverflowText.args = {
149
+ leftContent: leftContentMappings.dismissButton,
150
+ subtitle: "1 of 14 questions answered",
151
+ title: "Patterns of migration and communal bird-feeding given the serious situation of things that will make this string long and obnoxious",
152
+ rightContent: rightContentMappings.link,
153
+ };
154
+
155
+ HeaderOverflowText.parameters = {
156
+ docs: {
157
+ description: {
158
+ story:
159
+ "This example illustrates how the toolbar can work in situations where we include multiple lines of text.\n\n" +
160
+ "**Note:** The `IconButton` is nudged to the left by 6px to match designs.",
161
+ },
162
+ },
163
+ };
164
+
165
+ /**
166
+ * Flexible toolbars.
167
+ */
168
+ export const Responsive: StoryComponentType = Template.bind({});
169
+
170
+ Responsive.args = {
171
+ leftContent: leftContentMappings.hintButton,
172
+ rightContent: rightContentMappings.responsive,
173
+ };
174
+
175
+ Responsive.parameters = {
176
+ docs: {
177
+ description: {
178
+ story: "Sometimes there will be cases where we want to fill the content of one of the sides of the toolbar. This example demonstrates how toolbars can be used flexibly without breaking your layouts.",
179
+ },
180
+ },
181
+ chromatic: {
182
+ // Test responsiveness of the toolbar.
183
+ viewports: [320, 768, 1024],
184
+ },
185
+ };
186
+
187
+ /**
188
+ * Inverted dark-color scheme
189
+ */
190
+ export const Dark: StoryComponentType = Template.bind({});
191
+
192
+ Dark.args = {
193
+ color: "dark",
194
+ title: "Title",
195
+ leftContent: leftContentMappings.lightButton,
196
+ rightContent: rightContentMappings.lightButton,
197
+ };
198
+
199
+ Dark.parameters = {
200
+ backgrounds: {
201
+ default: "darkBlue",
202
+ },
203
+ docs: {
204
+ description: {
205
+ story:
206
+ "A toolbar can be also used in a dark color scheme.\n\n" +
207
+ "**Note:** Notice that there's a white hairline in this case, and that the background is transparent (to allow the Dark Blue or illustrated background to come through).",
208
+ },
209
+ },
210
+ };