@khanacademy/wonder-blocks-banner 1.2.7 → 1.2.9

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,49 @@
1
1
  # @khanacademy/wonder-blocks-banner
2
2
 
3
+ ## 1.2.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [779b031d]
8
+ - Updated dependencies [2c0ad5ca]
9
+ - @khanacademy/wonder-blocks-core@4.9.0
10
+ - @khanacademy/wonder-blocks-link@3.9.3
11
+ - @khanacademy/wonder-blocks-button@3.0.16
12
+ - @khanacademy/wonder-blocks-icon@1.2.39
13
+ - @khanacademy/wonder-blocks-icon-button@3.4.23
14
+ - @khanacademy/wonder-blocks-typography@1.1.40
15
+
16
+ ## 1.2.8
17
+
18
+ ### Patch Changes
19
+
20
+ - d816af08: Update build and test configs use TypeScript
21
+ - 3891f544: Update babel config to include plugins that Storybook needed
22
+ - 0d28bb1c: Configured TypeScript
23
+ - 3d05f764: Fix HOCs and other type errors
24
+ - c2ec4902: Update eslint configuration, fix lint
25
+ - 2983c05b: Include 'types' field in package.json
26
+ - 77ff6a66: Generate Flow types from TypeScript types
27
+ - ec8d4b7f: Fix miscellaneous TypeScript errors
28
+ - Updated dependencies [d816af08]
29
+ - Updated dependencies [3891f544]
30
+ - Updated dependencies [3813715d]
31
+ - Updated dependencies [0d28bb1c]
32
+ - Updated dependencies [873f4a14]
33
+ - Updated dependencies [3d05f764]
34
+ - Updated dependencies [c2ec4902]
35
+ - Updated dependencies [2983c05b]
36
+ - Updated dependencies [77ff6a66]
37
+ - Updated dependencies [ec8d4b7f]
38
+ - @khanacademy/wonder-blocks-button@3.0.15
39
+ - @khanacademy/wonder-blocks-color@1.2.2
40
+ - @khanacademy/wonder-blocks-core@4.8.0
41
+ - @khanacademy/wonder-blocks-icon@1.2.38
42
+ - @khanacademy/wonder-blocks-icon-button@3.4.22
43
+ - @khanacademy/wonder-blocks-link@3.9.2
44
+ - @khanacademy/wonder-blocks-spacing@3.0.6
45
+ - @khanacademy/wonder-blocks-typography@1.1.39
46
+
3
47
  ## 1.2.7
4
48
 
5
49
  ### Patch Changes
@@ -0,0 +1,5 @@
1
+ import { IconAsset } from "@khanacademy/wonder-blocks-icon";
2
+ export declare const info: IconAsset;
3
+ export declare const success: IconAsset;
4
+ export declare const warning: IconAsset;
5
+ export declare const critical: IconAsset;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Flowtype definitions for banner-icons
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import { IconAsset } from "@khanacademy/wonder-blocks-icon";
9
+ declare export var info: IconAsset;
10
+ declare export var success: IconAsset;
11
+ declare export var warning: IconAsset;
12
+ declare export var critical: IconAsset;
@@ -0,0 +1,111 @@
1
+ import * as React from "react";
2
+ type ActionTriggerBase = {
3
+ title: string;
4
+ ariaLabel?: string;
5
+ };
6
+ type ActionTriggerWithButton = ActionTriggerBase & {
7
+ onClick: () => void;
8
+ };
9
+ type ActionTriggerWithLink = ActionTriggerBase & {
10
+ href: string;
11
+ onClick?: () => void;
12
+ };
13
+ type ActionTriggerCustom = {
14
+ type: "custom";
15
+ node: React.ReactNode;
16
+ };
17
+ type ActionTrigger = ActionTriggerWithButton | ActionTriggerWithLink | ActionTriggerCustom;
18
+ type BannerKind =
19
+ /**
20
+ * Color blue, circle 'i' icon. This is the default.
21
+ */
22
+ "info"
23
+ /**
24
+ * Color green, smiley icon
25
+ */
26
+ | "success"
27
+ /**
28
+ * Color gold, triangle exclamation-point icon
29
+ */
30
+ | "warning"
31
+ /**
32
+ * Color red, circle exclamation-point icon
33
+ */
34
+ | "critical";
35
+ type BannerLayout =
36
+ /**
37
+ * Renders a rounded rectangle, usually for when banner is used as an inset
38
+ * element on a screen (e.g., the SOT card) that appears to be floating
39
+ */
40
+ "floating"
41
+ /**
42
+ * Renders a full-width banner, with no rounded corners.
43
+ * This is the default.
44
+ */
45
+ | "full-width";
46
+ type Props = {
47
+ /**
48
+ * Accessible label for the banner.
49
+ * This is read out before the other contents of the banner.
50
+ */
51
+ ["aria-label"]?: string;
52
+ /**
53
+ * Determines the color and icon of the banner.
54
+ */
55
+ kind?: BannerKind;
56
+ /**
57
+ * Determines the edge style of the Banner.
58
+ */
59
+ layout: BannerLayout;
60
+ /**
61
+ * Text on the banner (LabelSmall) or a node if you want something different.
62
+ */
63
+ text: string | React.ReactNode;
64
+ /**
65
+ * Links or tertiary Buttons that appear to the right of the text.
66
+ *
67
+ * The ActionTrigger must have either an onClick or an href field, or both.
68
+ */
69
+ actions?: Array<ActionTrigger>;
70
+ /**
71
+ * If present, dismiss button is on right side. If not, no button appears.
72
+ */
73
+ onDismiss?: () => void | null | undefined;
74
+ /**
75
+ * The accessible label for the dismiss button.
76
+ * Please pass in a translated string.
77
+ */
78
+ dismissAriaLabel?: string;
79
+ /**
80
+ * Test ID used for e2e testing.
81
+ */
82
+ testId?: string;
83
+ };
84
+ /**
85
+ * Banner. A banner displays a prominent message and related optional actions.
86
+ * It can be used as a way of informing the user of important changes.
87
+ * Typically, it is displayed toward the top of the screen.
88
+ *
89
+ * There are two possible layouts for banners - floating and full-width.
90
+ * The `floating` layout is intended to be used when there is whitespace
91
+ * around the banner. The `full-width` layout is intended to be used when
92
+ * the banner needs to be flush with surrounding elements.
93
+ *
94
+ * ### Usage
95
+ * ```jsx
96
+ * import Banner from "@khanacademy/wonder-blocks-banner";
97
+ *
98
+ * <Banner
99
+ * text="Here is some example text."
100
+ * kind="success"
101
+ * layout="floating"
102
+ * actions={[
103
+ * {title: "Button 1", onClick: () => {}},
104
+ * {title: "Button 2", onClick: () => {}},
105
+ * ]}
106
+ * onDismiss={() => {console.log("Has been dismissed.")}}
107
+ * />
108
+ * ```
109
+ */
110
+ declare const Banner: React.FC<Props>;
111
+ export default Banner;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Flowtype definitions for banner
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ declare type ActionTriggerBase = {
10
+ title: string,
11
+ ariaLabel?: string,
12
+ ...
13
+ };
14
+ declare type ActionTriggerWithButton = {
15
+ ...ActionTriggerBase,
16
+ ...{
17
+ onClick: () => void,
18
+ ...
19
+ },
20
+ };
21
+ declare type ActionTriggerWithLink = {
22
+ ...ActionTriggerBase,
23
+ ...{
24
+ href: string,
25
+ onClick?: () => void,
26
+ ...
27
+ },
28
+ };
29
+ declare type ActionTriggerCustom = {
30
+ type: "custom",
31
+ node: React.Node,
32
+ ...
33
+ };
34
+ declare type ActionTrigger =
35
+ | ActionTriggerWithButton
36
+ | ActionTriggerWithLink
37
+ | ActionTriggerCustom;
38
+ declare type BannerKind = "info" | "success" | "warning" | "critical";
39
+ declare type BannerLayout = "floating" | "full-width";
40
+ declare type Props = {
41
+ /**
42
+ * Accessible label for the banner.
43
+ * This is read out before the other contents of the banner.
44
+ */
45
+ "aria-label": string | void,
46
+
47
+ /**
48
+ * Determines the color and icon of the banner.
49
+ */
50
+ kind?: BannerKind,
51
+
52
+ /**
53
+ * Determines the edge style of the Banner.
54
+ */
55
+ layout: BannerLayout,
56
+
57
+ /**
58
+ * Text on the banner (LabelSmall) or a node if you want something different.
59
+ */
60
+ text: string | React.Node,
61
+
62
+ /**
63
+ * Links or tertiary Buttons that appear to the right of the text.
64
+ *
65
+ * The ActionTrigger must have either an onClick or an href field, or both.
66
+ */
67
+ actions?: Array<ActionTrigger>,
68
+
69
+ /**
70
+ * If present, dismiss button is on right side. If not, no button appears.
71
+ */
72
+ onDismiss?: () => void | null | void,
73
+
74
+ /**
75
+ * The accessible label for the dismiss button.
76
+ * Please pass in a translated string.
77
+ */
78
+ dismissAriaLabel?: string,
79
+
80
+ /**
81
+ * Test ID used for e2e testing.
82
+ */
83
+ testId?: string,
84
+ ...
85
+ };
86
+ /**
87
+ * Banner. A banner displays a prominent message and related optional actions.
88
+ * It can be used as a way of informing the user of important changes.
89
+ * Typically, it is displayed toward the top of the screen.
90
+ *
91
+ * There are two possible layouts for banners - floating and full-width.
92
+ * The `floating` layout is intended to be used when there is whitespace
93
+ * around the banner. The `full-width` layout is intended to be used when
94
+ * the banner needs to be flush with surrounding elements.
95
+ *
96
+ * ### Usage
97
+ * ```jsx
98
+ * import Banner from "@khanacademy/wonder-blocks-banner";
99
+ *
100
+ * <Banner
101
+ * text="Here is some example text."
102
+ * kind="success"
103
+ * layout="floating"
104
+ * actions={[
105
+ * {title: "Button 1", onClick: () => {}},
106
+ * {title: "Button 2", onClick: () => {}},
107
+ * ]}
108
+ * onDismiss={() => {console.log("Has been dismissed.")}}
109
+ * />
110
+ * ```
111
+ */
112
+ declare var Banner: React.FC<Props>;
113
+ declare export default typeof Banner;
package/dist/es/index.js CHANGED
@@ -37,20 +37,17 @@ const valuesForKind = kind => {
37
37
  color: Color.green,
38
38
  role: "status"
39
39
  };
40
-
41
40
  case "warning":
42
41
  return {
43
42
  color: Color.gold,
44
43
  role: "alert",
45
44
  ariaLive: "polite"
46
45
  };
47
-
48
46
  case "critical":
49
47
  return {
50
48
  color: Color.red,
51
49
  role: "alert"
52
50
  };
53
-
54
51
  default:
55
52
  return {
56
53
  color: Color.blue,
@@ -58,7 +55,6 @@ const valuesForKind = kind => {
58
55
  };
59
56
  }
60
57
  };
61
-
62
58
  const Banner = props => {
63
59
  const {
64
60
  actions,
@@ -70,7 +66,6 @@ const Banner = props => {
70
66
  text,
71
67
  testId
72
68
  } = props;
73
-
74
69
  const renderActions = () => {
75
70
  return actions == null ? void 0 : actions.filter(Boolean).map((action, i) => {
76
71
  if (action.type === "custom") {
@@ -79,12 +74,9 @@ const Banner = props => {
79
74
  key: `custom-action-${i}`
80
75
  }, action.node);
81
76
  }
82
-
83
77
  const handleClick = action.onClick;
84
-
85
78
  if (action.href) {
86
79
  var _action$ariaLabel;
87
-
88
80
  return React.createElement(View, {
89
81
  style: styles.action,
90
82
  key: action.title
@@ -97,7 +89,6 @@ const Banner = props => {
97
89
  }, action.title));
98
90
  } else {
99
91
  var _action$ariaLabel2;
100
-
101
92
  return React.createElement(View, {
102
93
  style: styles.action,
103
94
  key: action.title
@@ -110,7 +101,6 @@ const Banner = props => {
110
101
  }
111
102
  });
112
103
  };
113
-
114
104
  return React.createElement(View, {
115
105
  style: [styles.containerOuter, layout === "floating" && styles.floatingBorder, {
116
106
  borderInlineStartColor: valuesForKind(kind).color
@@ -147,7 +137,6 @@ const Banner = props => {
147
137
  "aria-label": dismissAriaLabel
148
138
  })) : null));
149
139
  };
150
-
151
140
  const styles = StyleSheet.create({
152
141
  backgroundColor: {
153
142
  position: "absolute",
@@ -0,0 +1,2 @@
1
+ import Banner from "./components/banner";
2
+ export default Banner;
package/dist/index.js CHANGED
@@ -67,20 +67,17 @@ const valuesForKind = kind => {
67
67
  color: Color__default["default"].green,
68
68
  role: "status"
69
69
  };
70
-
71
70
  case "warning":
72
71
  return {
73
72
  color: Color__default["default"].gold,
74
73
  role: "alert",
75
74
  ariaLive: "polite"
76
75
  };
77
-
78
76
  case "critical":
79
77
  return {
80
78
  color: Color__default["default"].red,
81
79
  role: "alert"
82
80
  };
83
-
84
81
  default:
85
82
  return {
86
83
  color: Color__default["default"].blue,
@@ -88,7 +85,6 @@ const valuesForKind = kind => {
88
85
  };
89
86
  }
90
87
  };
91
-
92
88
  const Banner = props => {
93
89
  const {
94
90
  actions,
@@ -100,7 +96,6 @@ const Banner = props => {
100
96
  text,
101
97
  testId
102
98
  } = props;
103
-
104
99
  const renderActions = () => {
105
100
  return actions == null ? void 0 : actions.filter(Boolean).map((action, i) => {
106
101
  if (action.type === "custom") {
@@ -109,12 +104,9 @@ const Banner = props => {
109
104
  key: `custom-action-${i}`
110
105
  }, action.node);
111
106
  }
112
-
113
107
  const handleClick = action.onClick;
114
-
115
108
  if (action.href) {
116
109
  var _action$ariaLabel;
117
-
118
110
  return React__namespace.createElement(wonderBlocksCore.View, {
119
111
  style: styles.action,
120
112
  key: action.title
@@ -127,7 +119,6 @@ const Banner = props => {
127
119
  }, action.title));
128
120
  } else {
129
121
  var _action$ariaLabel2;
130
-
131
122
  return React__namespace.createElement(wonderBlocksCore.View, {
132
123
  style: styles.action,
133
124
  key: action.title
@@ -140,7 +131,6 @@ const Banner = props => {
140
131
  }
141
132
  });
142
133
  };
143
-
144
134
  return React__namespace.createElement(wonderBlocksCore.View, {
145
135
  style: [styles.containerOuter, layout === "floating" && styles.floatingBorder, {
146
136
  borderInlineStartColor: valuesForKind(kind).color
@@ -177,7 +167,6 @@ const Banner = props => {
177
167
  "aria-label": dismissAriaLabel
178
168
  })) : null));
179
169
  };
180
-
181
170
  const styles = aphrodite.StyleSheet.create({
182
171
  backgroundColor: {
183
172
  position: "absolute",
@@ -1,2 +1,9 @@
1
- // @flow
2
- export * from "../src/index";
1
+ /**
2
+ * Flowtype definitions for index
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import Banner from "./components/banner";
9
+ declare export default typeof Banner;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-banner",
3
- "version": "1.2.7",
3
+ "version": "1.2.9",
4
4
  "design": "v1",
5
5
  "description": "Banner components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/es/index.js",
8
- "source": "src/index.js",
8
+ "types": "dist/index.d.ts",
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
@@ -16,20 +16,20 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-button": "^3.0.14",
20
- "@khanacademy/wonder-blocks-color": "^1.2.1",
21
- "@khanacademy/wonder-blocks-core": "^4.7.0",
22
- "@khanacademy/wonder-blocks-icon": "^1.2.37",
23
- "@khanacademy/wonder-blocks-icon-button": "^3.4.21",
24
- "@khanacademy/wonder-blocks-link": "^3.9.1",
25
- "@khanacademy/wonder-blocks-spacing": "^3.0.5",
26
- "@khanacademy/wonder-blocks-typography": "^1.1.38"
19
+ "@khanacademy/wonder-blocks-button": "^3.0.16",
20
+ "@khanacademy/wonder-blocks-color": "^1.2.2",
21
+ "@khanacademy/wonder-blocks-core": "^4.9.0",
22
+ "@khanacademy/wonder-blocks-icon": "^1.2.39",
23
+ "@khanacademy/wonder-blocks-icon-button": "^3.4.23",
24
+ "@khanacademy/wonder-blocks-link": "^3.9.3",
25
+ "@khanacademy/wonder-blocks-spacing": "^3.0.6",
26
+ "@khanacademy/wonder-blocks-typography": "^1.1.40"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "aphrodite": "^1.2.5",
30
30
  "react": "16.14.0"
31
31
  },
32
32
  "devDependencies": {
33
- "wb-dev-build-settings": "^0.7.1"
33
+ "wb-dev-build-settings": "^0.7.3"
34
34
  }
35
35
  }
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import * as React from "react";
3
2
  import {render, screen} from "@testing-library/react";
4
3
 
@@ -222,7 +221,7 @@ describe("Banner", () => {
222
221
 
223
222
  it.each(["info", "success", "warning", "critical"])(
224
223
  "%s kind displays %s icon",
225
- (kind) => {
224
+ (kind: any) => {
226
225
  // Arrange
227
226
 
228
227
  // Act
@@ -361,7 +360,7 @@ describe("Banner", () => {
361
360
  ["success", "status"],
362
361
  ["warning", "alert"],
363
362
  ["critical", "alert"],
364
- ])("%s banners have role: %s", (kind, role) => {
363
+ ])("%s banners have role: %s", (kind: any, role: any) => {
365
364
  // Arrange
366
365
 
367
366
  // Act
@@ -1,7 +1,6 @@
1
- // @flow
2
1
  // TODO(WB-1409): Use Phosphor icons instead of custom svgs. Also, use
3
2
  // Wonder Blocks Icon instead of img in the render function.
4
- import {type IconAsset} from "@khanacademy/wonder-blocks-icon";
3
+ import {IconAsset} from "@khanacademy/wonder-blocks-icon";
5
4
 
6
5
  export const info: IconAsset = {
7
6
  medium: "M12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4ZM2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM10.25 11.25C10.25 10.6977 10.6977 10.25 11.25 10.25H12C12.5523 10.25 13 10.6977 13 11.25V15.5315C13.4313 15.6425 13.75 16.034 13.75 16.5C13.75 17.0523 13.3023 17.5 12.75 17.5H12C11.4477 17.5 11 17.0523 11 16.5V12.2185C10.5687 12.1075 10.25 11.716 10.25 11.25ZM12.9375 7.875C12.9375 8.49632 12.4338 9 11.8125 9C11.1912 9 10.6875 8.49632 10.6875 7.875C10.6875 7.25368 11.1912 6.75 11.8125 6.75C12.4338 6.75 12.9375 7.25368 12.9375 7.875Z",