@khanacademy/wonder-blocks-banner 4.1.12 → 4.1.14
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 +30 -0
- package/dist/es/index.js +3 -187
- package/dist/index.js +3 -206
- package/package.json +9 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-banner
|
|
2
2
|
|
|
3
|
+
## 4.1.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [28fa0c0]
|
|
8
|
+
- Updated dependencies [28fa0c0]
|
|
9
|
+
- Updated dependencies [38042e2]
|
|
10
|
+
- Updated dependencies [c9a0147]
|
|
11
|
+
- @khanacademy/wonder-blocks-core@12.3.0
|
|
12
|
+
- @khanacademy/wonder-blocks-link@9.1.0
|
|
13
|
+
- @khanacademy/wonder-blocks-icon-button@9.0.6
|
|
14
|
+
- @khanacademy/wonder-blocks-button@9.0.2
|
|
15
|
+
- @khanacademy/wonder-blocks-icon@5.1.4
|
|
16
|
+
- @khanacademy/wonder-blocks-typography@3.2.1
|
|
17
|
+
|
|
18
|
+
## 4.1.13
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [b9e4946]
|
|
23
|
+
- Updated dependencies [b9e4946]
|
|
24
|
+
- Updated dependencies [b9e4946]
|
|
25
|
+
- @khanacademy/wonder-blocks-tokens@10.0.0
|
|
26
|
+
- @khanacademy/wonder-blocks-typography@3.2.0
|
|
27
|
+
- @khanacademy/wonder-blocks-button@9.0.1
|
|
28
|
+
- @khanacademy/wonder-blocks-icon-button@9.0.5
|
|
29
|
+
- @khanacademy/wonder-blocks-link@9.0.4
|
|
30
|
+
- @khanacademy/wonder-blocks-core@12.2.1
|
|
31
|
+
- @khanacademy/wonder-blocks-icon@5.1.3
|
|
32
|
+
|
|
3
33
|
## 4.1.12
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/es/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
2
3
|
import { StyleSheet } from 'aphrodite';
|
|
3
4
|
import xIcon from '@phosphor-icons/core/regular/x.svg';
|
|
4
5
|
import Button from '@khanacademy/wonder-blocks-button';
|
|
@@ -13,191 +14,6 @@ import successIcon from '@phosphor-icons/core/regular/smiley.svg';
|
|
|
13
14
|
import warningIcon from '@phosphor-icons/core/regular/warning.svg';
|
|
14
15
|
import criticalIcon from '@phosphor-icons/core/regular/warning-circle.svg';
|
|
15
16
|
|
|
16
|
-
const getValuesForKind = kind => {
|
|
17
|
-
switch (kind) {
|
|
18
|
-
case "success":
|
|
19
|
-
return {
|
|
20
|
-
color: semanticColor.status.success.foreground,
|
|
21
|
-
icon: successIcon,
|
|
22
|
-
role: "status"
|
|
23
|
-
};
|
|
24
|
-
case "warning":
|
|
25
|
-
return {
|
|
26
|
-
color: semanticColor.status.warning.foreground,
|
|
27
|
-
icon: warningIcon,
|
|
28
|
-
role: "alert",
|
|
29
|
-
ariaLive: "polite"
|
|
30
|
-
};
|
|
31
|
-
case "critical":
|
|
32
|
-
return {
|
|
33
|
-
color: semanticColor.status.critical.foreground,
|
|
34
|
-
icon: criticalIcon,
|
|
35
|
-
role: "alert"
|
|
36
|
-
};
|
|
37
|
-
default:
|
|
38
|
-
return {
|
|
39
|
-
color: semanticColor.status.notice.foreground,
|
|
40
|
-
icon: infoIcon,
|
|
41
|
-
role: "status"
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const Banner = props => {
|
|
46
|
-
const {
|
|
47
|
-
actions,
|
|
48
|
-
"aria-label": ariaLabel,
|
|
49
|
-
dismissAriaLabel = "Dismiss banner.",
|
|
50
|
-
onDismiss,
|
|
51
|
-
kind = "info",
|
|
52
|
-
layout,
|
|
53
|
-
text,
|
|
54
|
-
testId,
|
|
55
|
-
icon
|
|
56
|
-
} = props;
|
|
57
|
-
const renderActions = () => {
|
|
58
|
-
return actions == null ? void 0 : actions.filter(Boolean).map((action, i) => {
|
|
59
|
-
if (action.type === "custom") {
|
|
60
|
-
return React.createElement(View, {
|
|
61
|
-
style: styles.action,
|
|
62
|
-
key: `custom-action-${i}`
|
|
63
|
-
}, action.node);
|
|
64
|
-
}
|
|
65
|
-
const handleClick = action.onClick;
|
|
66
|
-
if (action.type === "link") {
|
|
67
|
-
var _action$ariaLabel;
|
|
68
|
-
return React.createElement(View, {
|
|
69
|
-
style: styles.action,
|
|
70
|
-
key: action.title
|
|
71
|
-
}, React.createElement(Link, {
|
|
72
|
-
href: action.href,
|
|
73
|
-
onClick: handleClick,
|
|
74
|
-
"aria-label": (_action$ariaLabel = action.ariaLabel) != null ? _action$ariaLabel : action.title,
|
|
75
|
-
style: styles.link
|
|
76
|
-
}, action.title));
|
|
77
|
-
} else {
|
|
78
|
-
var _action$ariaLabel2;
|
|
79
|
-
return React.createElement(View, {
|
|
80
|
-
style: styles.action,
|
|
81
|
-
key: action.title
|
|
82
|
-
}, React.createElement(Button, {
|
|
83
|
-
kind: "tertiary",
|
|
84
|
-
size: "small",
|
|
85
|
-
"aria-label": (_action$ariaLabel2 = action.ariaLabel) != null ? _action$ariaLabel2 : action.title,
|
|
86
|
-
onClick: handleClick
|
|
87
|
-
}, action.title));
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
const valuesForKind = getValuesForKind(kind);
|
|
92
|
-
return React.createElement(View, {
|
|
93
|
-
style: [styles.containerOuter, layout === "floating" && styles.floatingBorder, {
|
|
94
|
-
borderInlineStartColor: valuesForKind.color
|
|
95
|
-
}],
|
|
96
|
-
role: valuesForKind.role,
|
|
97
|
-
"aria-label": ariaLabel,
|
|
98
|
-
"aria-live": valuesForKind.ariaLive,
|
|
99
|
-
testId: testId
|
|
100
|
-
}, React.createElement(View, {
|
|
101
|
-
style: [styles.backgroundColor, {
|
|
102
|
-
backgroundColor: valuesForKind.color
|
|
103
|
-
}]
|
|
104
|
-
}), React.createElement(View, {
|
|
105
|
-
style: styles.containerInner
|
|
106
|
-
}, React.createElement(PhosphorIcon, {
|
|
107
|
-
icon: icon || valuesForKind.icon,
|
|
108
|
-
size: "medium",
|
|
109
|
-
style: styles.icon,
|
|
110
|
-
"aria-label": kind,
|
|
111
|
-
testId: "banner-kind-icon",
|
|
112
|
-
role: "img"
|
|
113
|
-
}), React.createElement(View, {
|
|
114
|
-
style: styles.labelAndButtonsContainer
|
|
115
|
-
}, React.createElement(View, {
|
|
116
|
-
style: styles.labelContainer
|
|
117
|
-
}, React.createElement(LabelSmall, null, text)), actions && React.createElement(View, {
|
|
118
|
-
style: styles.actionsContainer
|
|
119
|
-
}, renderActions())), onDismiss ? React.createElement(View, {
|
|
120
|
-
style: styles.dismissContainer
|
|
121
|
-
}, React.createElement(IconButton, {
|
|
122
|
-
icon: xIcon,
|
|
123
|
-
kind: "tertiary",
|
|
124
|
-
actionType: "neutral",
|
|
125
|
-
onClick: onDismiss,
|
|
126
|
-
style: styles.dismiss,
|
|
127
|
-
"aria-label": dismissAriaLabel
|
|
128
|
-
})) : null));
|
|
129
|
-
};
|
|
130
|
-
const styles = StyleSheet.create({
|
|
131
|
-
backgroundColor: {
|
|
132
|
-
position: "absolute",
|
|
133
|
-
top: 0,
|
|
134
|
-
bottom: 0,
|
|
135
|
-
left: 0,
|
|
136
|
-
right: 0,
|
|
137
|
-
opacity: 0.08
|
|
138
|
-
},
|
|
139
|
-
containerOuter: {
|
|
140
|
-
borderInlineStartWidth: spacing.xxSmall_6,
|
|
141
|
-
width: "100%",
|
|
142
|
-
backgroundColor: semanticColor.surface.primary
|
|
143
|
-
},
|
|
144
|
-
containerInner: {
|
|
145
|
-
flexDirection: "row",
|
|
146
|
-
padding: spacing.xSmall_8
|
|
147
|
-
},
|
|
148
|
-
icon: {
|
|
149
|
-
marginTop: spacing.xSmall_8,
|
|
150
|
-
marginBottom: spacing.xSmall_8,
|
|
151
|
-
marginInlineStart: spacing.xxxxSmall_2,
|
|
152
|
-
marginInlineEnd: spacing.xSmall_8,
|
|
153
|
-
alignSelf: "flex-start",
|
|
154
|
-
color: semanticColor.icon.primary
|
|
155
|
-
},
|
|
156
|
-
labelAndButtonsContainer: {
|
|
157
|
-
flex: 1,
|
|
158
|
-
flexDirection: "row",
|
|
159
|
-
alignItems: "center",
|
|
160
|
-
alignContent: "center",
|
|
161
|
-
flexWrap: "wrap",
|
|
162
|
-
justifyContent: "space-between"
|
|
163
|
-
},
|
|
164
|
-
labelContainer: {
|
|
165
|
-
flexShrink: 1,
|
|
166
|
-
margin: spacing.xSmall_8,
|
|
167
|
-
textAlign: "start",
|
|
168
|
-
overflowWrap: "break-word"
|
|
169
|
-
},
|
|
170
|
-
actionsContainer: {
|
|
171
|
-
flexDirection: "row",
|
|
172
|
-
justifyContent: "flex-start",
|
|
173
|
-
marginTop: spacing.xSmall_8,
|
|
174
|
-
marginBottom: spacing.xSmall_8,
|
|
175
|
-
height: 18,
|
|
176
|
-
alignItems: "center"
|
|
177
|
-
},
|
|
178
|
-
action: {
|
|
179
|
-
marginLeft: spacing.xSmall_8,
|
|
180
|
-
marginRight: spacing.xSmall_8,
|
|
181
|
-
justifyContent: "center"
|
|
182
|
-
},
|
|
183
|
-
link: {
|
|
184
|
-
fontSize: font.size.small
|
|
185
|
-
},
|
|
186
|
-
dismiss: {
|
|
187
|
-
flexShrink: 1
|
|
188
|
-
},
|
|
189
|
-
dismissContainer: {
|
|
190
|
-
height: 40,
|
|
191
|
-
width: 40,
|
|
192
|
-
justifyContent: "center",
|
|
193
|
-
alignItems: "center",
|
|
194
|
-
marginLeft: spacing.xSmall_8,
|
|
195
|
-
marginRight: spacing.xSmall_8
|
|
196
|
-
},
|
|
197
|
-
floatingBorder: {
|
|
198
|
-
borderRadius: border.radius.radius_040,
|
|
199
|
-
overflow: "hidden"
|
|
200
|
-
}
|
|
201
|
-
});
|
|
17
|
+
const getValuesForKind=kind=>{switch(kind){case"success":return {color:semanticColor.status.success.foreground,icon:successIcon,role:"status"};case"warning":return {color:semanticColor.status.warning.foreground,icon:warningIcon,role:"alert",ariaLive:"polite"};case"critical":return {color:semanticColor.status.critical.foreground,icon:criticalIcon,role:"alert"};default:return {color:semanticColor.status.notice.foreground,icon:infoIcon,role:"status"}}};const Banner=props=>{const{actions,"aria-label":ariaLabel,dismissAriaLabel="Dismiss banner.",onDismiss,kind="info",layout,text,testId,icon}=props;const renderActions=()=>{return actions?.filter(Boolean).map((action,i)=>{if(action.type==="custom"){return jsx(View,{style:styles.action,children:action.node},`custom-action-${i}`)}const handleClick=action.onClick;if(action.type==="link"){return jsx(View,{style:styles.action,children:jsx(Link,{href:action.href,onClick:handleClick,"aria-label":action.ariaLabel??action.title,style:styles.link,children:action.title})},action.title)}else {return jsx(View,{style:styles.action,children:jsx(Button,{kind:"tertiary",size:"small","aria-label":action.ariaLabel??action.title,onClick:handleClick,children:action.title})},action.title)}})};const valuesForKind=getValuesForKind(kind);return jsxs(View,{style:[styles.containerOuter,layout==="floating"&&styles.floatingBorder,{borderInlineStartColor:valuesForKind.color}],role:valuesForKind.role,"aria-label":ariaLabel,"aria-live":valuesForKind.ariaLive,testId:testId,children:[jsx(View,{style:[styles.backgroundColor,{backgroundColor:valuesForKind.color}]}),jsxs(View,{style:styles.containerInner,children:[jsx(PhosphorIcon,{icon:icon||valuesForKind.icon,size:"medium",style:styles.icon,"aria-label":kind,testId:"banner-kind-icon",role:"img"}),jsxs(View,{style:styles.labelAndButtonsContainer,children:[jsx(View,{style:styles.labelContainer,children:jsx(LabelSmall,{children:text})}),actions&&jsx(View,{style:styles.actionsContainer,children:renderActions()})]}),onDismiss?jsx(View,{style:styles.dismissContainer,children:jsx(IconButton,{icon:xIcon,kind:"tertiary",actionType:"neutral",onClick:onDismiss,style:styles.dismiss,"aria-label":dismissAriaLabel})}):null]})]})};const styles=StyleSheet.create({backgroundColor:{position:"absolute",top:0,bottom:0,left:0,right:0,opacity:.08},containerOuter:{borderInlineStartWidth:spacing.xxSmall_6,width:"100%",backgroundColor:semanticColor.surface.primary},containerInner:{flexDirection:"row",padding:spacing.xSmall_8},icon:{marginTop:spacing.xSmall_8,marginBottom:spacing.xSmall_8,marginInlineStart:spacing.xxxxSmall_2,marginInlineEnd:spacing.xSmall_8,alignSelf:"flex-start",color:semanticColor.icon.primary},labelAndButtonsContainer:{flex:1,flexDirection:"row",alignItems:"center",alignContent:"center",flexWrap:"wrap",justifyContent:"space-between"},labelContainer:{flexShrink:1,margin:spacing.xSmall_8,textAlign:"start",overflowWrap:"break-word"},actionsContainer:{flexDirection:"row",justifyContent:"flex-start",marginTop:spacing.xSmall_8,marginBottom:spacing.xSmall_8,height:18,alignItems:"center"},action:{marginLeft:spacing.xSmall_8,marginRight:spacing.xSmall_8,justifyContent:"center"},link:{fontSize:font.size.small},dismiss:{flexShrink:1},dismissContainer:{height:40,width:40,justifyContent:"center",alignItems:"center",marginLeft:spacing.xSmall_8,marginRight:spacing.xSmall_8},floatingBorder:{borderRadius:border.radius.radius_040,overflow:"hidden"}});
|
|
202
18
|
|
|
203
19
|
export { Banner as default };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
require('react');
|
|
4
5
|
var aphrodite = require('aphrodite');
|
|
5
6
|
var xIcon = require('@phosphor-icons/core/regular/x.svg');
|
|
6
7
|
var Button = require('@khanacademy/wonder-blocks-button');
|
|
@@ -17,25 +18,6 @@ var criticalIcon = require('@phosphor-icons/core/regular/warning-circle.svg');
|
|
|
17
18
|
|
|
18
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
20
|
|
|
20
|
-
function _interopNamespace(e) {
|
|
21
|
-
if (e && e.__esModule) return e;
|
|
22
|
-
var n = Object.create(null);
|
|
23
|
-
if (e) {
|
|
24
|
-
Object.keys(e).forEach(function (k) {
|
|
25
|
-
if (k !== 'default') {
|
|
26
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return e[k]; }
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
n["default"] = e;
|
|
35
|
-
return Object.freeze(n);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
39
21
|
var xIcon__default = /*#__PURE__*/_interopDefaultLegacy(xIcon);
|
|
40
22
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
41
23
|
var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
|
|
@@ -45,191 +27,6 @@ var successIcon__default = /*#__PURE__*/_interopDefaultLegacy(successIcon);
|
|
|
45
27
|
var warningIcon__default = /*#__PURE__*/_interopDefaultLegacy(warningIcon);
|
|
46
28
|
var criticalIcon__default = /*#__PURE__*/_interopDefaultLegacy(criticalIcon);
|
|
47
29
|
|
|
48
|
-
const getValuesForKind = kind => {
|
|
49
|
-
switch (kind) {
|
|
50
|
-
case "success":
|
|
51
|
-
return {
|
|
52
|
-
color: wonderBlocksTokens.semanticColor.status.success.foreground,
|
|
53
|
-
icon: successIcon__default["default"],
|
|
54
|
-
role: "status"
|
|
55
|
-
};
|
|
56
|
-
case "warning":
|
|
57
|
-
return {
|
|
58
|
-
color: wonderBlocksTokens.semanticColor.status.warning.foreground,
|
|
59
|
-
icon: warningIcon__default["default"],
|
|
60
|
-
role: "alert",
|
|
61
|
-
ariaLive: "polite"
|
|
62
|
-
};
|
|
63
|
-
case "critical":
|
|
64
|
-
return {
|
|
65
|
-
color: wonderBlocksTokens.semanticColor.status.critical.foreground,
|
|
66
|
-
icon: criticalIcon__default["default"],
|
|
67
|
-
role: "alert"
|
|
68
|
-
};
|
|
69
|
-
default:
|
|
70
|
-
return {
|
|
71
|
-
color: wonderBlocksTokens.semanticColor.status.notice.foreground,
|
|
72
|
-
icon: infoIcon__default["default"],
|
|
73
|
-
role: "status"
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const Banner = props => {
|
|
78
|
-
const {
|
|
79
|
-
actions,
|
|
80
|
-
"aria-label": ariaLabel,
|
|
81
|
-
dismissAriaLabel = "Dismiss banner.",
|
|
82
|
-
onDismiss,
|
|
83
|
-
kind = "info",
|
|
84
|
-
layout,
|
|
85
|
-
text,
|
|
86
|
-
testId,
|
|
87
|
-
icon
|
|
88
|
-
} = props;
|
|
89
|
-
const renderActions = () => {
|
|
90
|
-
return actions == null ? void 0 : actions.filter(Boolean).map((action, i) => {
|
|
91
|
-
if (action.type === "custom") {
|
|
92
|
-
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
93
|
-
style: styles.action,
|
|
94
|
-
key: `custom-action-${i}`
|
|
95
|
-
}, action.node);
|
|
96
|
-
}
|
|
97
|
-
const handleClick = action.onClick;
|
|
98
|
-
if (action.type === "link") {
|
|
99
|
-
var _action$ariaLabel;
|
|
100
|
-
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
101
|
-
style: styles.action,
|
|
102
|
-
key: action.title
|
|
103
|
-
}, React__namespace.createElement(Link__default["default"], {
|
|
104
|
-
href: action.href,
|
|
105
|
-
onClick: handleClick,
|
|
106
|
-
"aria-label": (_action$ariaLabel = action.ariaLabel) != null ? _action$ariaLabel : action.title,
|
|
107
|
-
style: styles.link
|
|
108
|
-
}, action.title));
|
|
109
|
-
} else {
|
|
110
|
-
var _action$ariaLabel2;
|
|
111
|
-
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
112
|
-
style: styles.action,
|
|
113
|
-
key: action.title
|
|
114
|
-
}, React__namespace.createElement(Button__default["default"], {
|
|
115
|
-
kind: "tertiary",
|
|
116
|
-
size: "small",
|
|
117
|
-
"aria-label": (_action$ariaLabel2 = action.ariaLabel) != null ? _action$ariaLabel2 : action.title,
|
|
118
|
-
onClick: handleClick
|
|
119
|
-
}, action.title));
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
const valuesForKind = getValuesForKind(kind);
|
|
124
|
-
return React__namespace.createElement(wonderBlocksCore.View, {
|
|
125
|
-
style: [styles.containerOuter, layout === "floating" && styles.floatingBorder, {
|
|
126
|
-
borderInlineStartColor: valuesForKind.color
|
|
127
|
-
}],
|
|
128
|
-
role: valuesForKind.role,
|
|
129
|
-
"aria-label": ariaLabel,
|
|
130
|
-
"aria-live": valuesForKind.ariaLive,
|
|
131
|
-
testId: testId
|
|
132
|
-
}, React__namespace.createElement(wonderBlocksCore.View, {
|
|
133
|
-
style: [styles.backgroundColor, {
|
|
134
|
-
backgroundColor: valuesForKind.color
|
|
135
|
-
}]
|
|
136
|
-
}), React__namespace.createElement(wonderBlocksCore.View, {
|
|
137
|
-
style: styles.containerInner
|
|
138
|
-
}, React__namespace.createElement(wonderBlocksIcon.PhosphorIcon, {
|
|
139
|
-
icon: icon || valuesForKind.icon,
|
|
140
|
-
size: "medium",
|
|
141
|
-
style: styles.icon,
|
|
142
|
-
"aria-label": kind,
|
|
143
|
-
testId: "banner-kind-icon",
|
|
144
|
-
role: "img"
|
|
145
|
-
}), React__namespace.createElement(wonderBlocksCore.View, {
|
|
146
|
-
style: styles.labelAndButtonsContainer
|
|
147
|
-
}, React__namespace.createElement(wonderBlocksCore.View, {
|
|
148
|
-
style: styles.labelContainer
|
|
149
|
-
}, React__namespace.createElement(wonderBlocksTypography.LabelSmall, null, text)), actions && React__namespace.createElement(wonderBlocksCore.View, {
|
|
150
|
-
style: styles.actionsContainer
|
|
151
|
-
}, renderActions())), onDismiss ? React__namespace.createElement(wonderBlocksCore.View, {
|
|
152
|
-
style: styles.dismissContainer
|
|
153
|
-
}, React__namespace.createElement(IconButton__default["default"], {
|
|
154
|
-
icon: xIcon__default["default"],
|
|
155
|
-
kind: "tertiary",
|
|
156
|
-
actionType: "neutral",
|
|
157
|
-
onClick: onDismiss,
|
|
158
|
-
style: styles.dismiss,
|
|
159
|
-
"aria-label": dismissAriaLabel
|
|
160
|
-
})) : null));
|
|
161
|
-
};
|
|
162
|
-
const styles = aphrodite.StyleSheet.create({
|
|
163
|
-
backgroundColor: {
|
|
164
|
-
position: "absolute",
|
|
165
|
-
top: 0,
|
|
166
|
-
bottom: 0,
|
|
167
|
-
left: 0,
|
|
168
|
-
right: 0,
|
|
169
|
-
opacity: 0.08
|
|
170
|
-
},
|
|
171
|
-
containerOuter: {
|
|
172
|
-
borderInlineStartWidth: wonderBlocksTokens.spacing.xxSmall_6,
|
|
173
|
-
width: "100%",
|
|
174
|
-
backgroundColor: wonderBlocksTokens.semanticColor.surface.primary
|
|
175
|
-
},
|
|
176
|
-
containerInner: {
|
|
177
|
-
flexDirection: "row",
|
|
178
|
-
padding: wonderBlocksTokens.spacing.xSmall_8
|
|
179
|
-
},
|
|
180
|
-
icon: {
|
|
181
|
-
marginTop: wonderBlocksTokens.spacing.xSmall_8,
|
|
182
|
-
marginBottom: wonderBlocksTokens.spacing.xSmall_8,
|
|
183
|
-
marginInlineStart: wonderBlocksTokens.spacing.xxxxSmall_2,
|
|
184
|
-
marginInlineEnd: wonderBlocksTokens.spacing.xSmall_8,
|
|
185
|
-
alignSelf: "flex-start",
|
|
186
|
-
color: wonderBlocksTokens.semanticColor.icon.primary
|
|
187
|
-
},
|
|
188
|
-
labelAndButtonsContainer: {
|
|
189
|
-
flex: 1,
|
|
190
|
-
flexDirection: "row",
|
|
191
|
-
alignItems: "center",
|
|
192
|
-
alignContent: "center",
|
|
193
|
-
flexWrap: "wrap",
|
|
194
|
-
justifyContent: "space-between"
|
|
195
|
-
},
|
|
196
|
-
labelContainer: {
|
|
197
|
-
flexShrink: 1,
|
|
198
|
-
margin: wonderBlocksTokens.spacing.xSmall_8,
|
|
199
|
-
textAlign: "start",
|
|
200
|
-
overflowWrap: "break-word"
|
|
201
|
-
},
|
|
202
|
-
actionsContainer: {
|
|
203
|
-
flexDirection: "row",
|
|
204
|
-
justifyContent: "flex-start",
|
|
205
|
-
marginTop: wonderBlocksTokens.spacing.xSmall_8,
|
|
206
|
-
marginBottom: wonderBlocksTokens.spacing.xSmall_8,
|
|
207
|
-
height: 18,
|
|
208
|
-
alignItems: "center"
|
|
209
|
-
},
|
|
210
|
-
action: {
|
|
211
|
-
marginLeft: wonderBlocksTokens.spacing.xSmall_8,
|
|
212
|
-
marginRight: wonderBlocksTokens.spacing.xSmall_8,
|
|
213
|
-
justifyContent: "center"
|
|
214
|
-
},
|
|
215
|
-
link: {
|
|
216
|
-
fontSize: wonderBlocksTokens.font.size.small
|
|
217
|
-
},
|
|
218
|
-
dismiss: {
|
|
219
|
-
flexShrink: 1
|
|
220
|
-
},
|
|
221
|
-
dismissContainer: {
|
|
222
|
-
height: 40,
|
|
223
|
-
width: 40,
|
|
224
|
-
justifyContent: "center",
|
|
225
|
-
alignItems: "center",
|
|
226
|
-
marginLeft: wonderBlocksTokens.spacing.xSmall_8,
|
|
227
|
-
marginRight: wonderBlocksTokens.spacing.xSmall_8
|
|
228
|
-
},
|
|
229
|
-
floatingBorder: {
|
|
230
|
-
borderRadius: wonderBlocksTokens.border.radius.radius_040,
|
|
231
|
-
overflow: "hidden"
|
|
232
|
-
}
|
|
233
|
-
});
|
|
30
|
+
const getValuesForKind=kind=>{switch(kind){case"success":return {color:wonderBlocksTokens.semanticColor.status.success.foreground,icon:successIcon__default["default"],role:"status"};case"warning":return {color:wonderBlocksTokens.semanticColor.status.warning.foreground,icon:warningIcon__default["default"],role:"alert",ariaLive:"polite"};case"critical":return {color:wonderBlocksTokens.semanticColor.status.critical.foreground,icon:criticalIcon__default["default"],role:"alert"};default:return {color:wonderBlocksTokens.semanticColor.status.notice.foreground,icon:infoIcon__default["default"],role:"status"}}};const Banner=props=>{const{actions,"aria-label":ariaLabel,dismissAriaLabel="Dismiss banner.",onDismiss,kind="info",layout,text,testId,icon}=props;const renderActions=()=>{return actions?.filter(Boolean).map((action,i)=>{if(action.type==="custom"){return jsxRuntime.jsx(wonderBlocksCore.View,{style:styles.action,children:action.node},`custom-action-${i}`)}const handleClick=action.onClick;if(action.type==="link"){return jsxRuntime.jsx(wonderBlocksCore.View,{style:styles.action,children:jsxRuntime.jsx(Link__default["default"],{href:action.href,onClick:handleClick,"aria-label":action.ariaLabel??action.title,style:styles.link,children:action.title})},action.title)}else {return jsxRuntime.jsx(wonderBlocksCore.View,{style:styles.action,children:jsxRuntime.jsx(Button__default["default"],{kind:"tertiary",size:"small","aria-label":action.ariaLabel??action.title,onClick:handleClick,children:action.title})},action.title)}})};const valuesForKind=getValuesForKind(kind);return jsxRuntime.jsxs(wonderBlocksCore.View,{style:[styles.containerOuter,layout==="floating"&&styles.floatingBorder,{borderInlineStartColor:valuesForKind.color}],role:valuesForKind.role,"aria-label":ariaLabel,"aria-live":valuesForKind.ariaLive,testId:testId,children:[jsxRuntime.jsx(wonderBlocksCore.View,{style:[styles.backgroundColor,{backgroundColor:valuesForKind.color}]}),jsxRuntime.jsxs(wonderBlocksCore.View,{style:styles.containerInner,children:[jsxRuntime.jsx(wonderBlocksIcon.PhosphorIcon,{icon:icon||valuesForKind.icon,size:"medium",style:styles.icon,"aria-label":kind,testId:"banner-kind-icon",role:"img"}),jsxRuntime.jsxs(wonderBlocksCore.View,{style:styles.labelAndButtonsContainer,children:[jsxRuntime.jsx(wonderBlocksCore.View,{style:styles.labelContainer,children:jsxRuntime.jsx(wonderBlocksTypography.LabelSmall,{children:text})}),actions&&jsxRuntime.jsx(wonderBlocksCore.View,{style:styles.actionsContainer,children:renderActions()})]}),onDismiss?jsxRuntime.jsx(wonderBlocksCore.View,{style:styles.dismissContainer,children:jsxRuntime.jsx(IconButton__default["default"],{icon:xIcon__default["default"],kind:"tertiary",actionType:"neutral",onClick:onDismiss,style:styles.dismiss,"aria-label":dismissAriaLabel})}):null]})]})};const styles=aphrodite.StyleSheet.create({backgroundColor:{position:"absolute",top:0,bottom:0,left:0,right:0,opacity:.08},containerOuter:{borderInlineStartWidth:wonderBlocksTokens.spacing.xxSmall_6,width:"100%",backgroundColor:wonderBlocksTokens.semanticColor.surface.primary},containerInner:{flexDirection:"row",padding:wonderBlocksTokens.spacing.xSmall_8},icon:{marginTop:wonderBlocksTokens.spacing.xSmall_8,marginBottom:wonderBlocksTokens.spacing.xSmall_8,marginInlineStart:wonderBlocksTokens.spacing.xxxxSmall_2,marginInlineEnd:wonderBlocksTokens.spacing.xSmall_8,alignSelf:"flex-start",color:wonderBlocksTokens.semanticColor.icon.primary},labelAndButtonsContainer:{flex:1,flexDirection:"row",alignItems:"center",alignContent:"center",flexWrap:"wrap",justifyContent:"space-between"},labelContainer:{flexShrink:1,margin:wonderBlocksTokens.spacing.xSmall_8,textAlign:"start",overflowWrap:"break-word"},actionsContainer:{flexDirection:"row",justifyContent:"flex-start",marginTop:wonderBlocksTokens.spacing.xSmall_8,marginBottom:wonderBlocksTokens.spacing.xSmall_8,height:18,alignItems:"center"},action:{marginLeft:wonderBlocksTokens.spacing.xSmall_8,marginRight:wonderBlocksTokens.spacing.xSmall_8,justifyContent:"center"},link:{fontSize:wonderBlocksTokens.font.size.small},dismiss:{flexShrink:1},dismissContainer:{height:40,width:40,justifyContent:"center",alignItems:"center",marginLeft:wonderBlocksTokens.spacing.xSmall_8,marginRight:wonderBlocksTokens.spacing.xSmall_8},floatingBorder:{borderRadius:wonderBlocksTokens.border.radius.radius_040,overflow:"hidden"}});
|
|
234
31
|
|
|
235
32
|
module.exports = Banner;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-banner",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.14",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"description": "Banner components for Wonder Blocks.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,14 +12,13 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"@khanacademy/wonder-blocks-
|
|
17
|
-
"@khanacademy/wonder-blocks-
|
|
18
|
-
"@khanacademy/wonder-blocks-icon": "
|
|
19
|
-
"@khanacademy/wonder-blocks-
|
|
20
|
-
"@khanacademy/wonder-blocks-
|
|
21
|
-
"@khanacademy/wonder-blocks-
|
|
22
|
-
"@khanacademy/wonder-blocks-typography": "3.1.3"
|
|
15
|
+
"@khanacademy/wonder-blocks-button": "9.0.2",
|
|
16
|
+
"@khanacademy/wonder-blocks-core": "12.3.0",
|
|
17
|
+
"@khanacademy/wonder-blocks-icon": "5.1.4",
|
|
18
|
+
"@khanacademy/wonder-blocks-icon-button": "9.0.6",
|
|
19
|
+
"@khanacademy/wonder-blocks-link": "9.1.0",
|
|
20
|
+
"@khanacademy/wonder-blocks-tokens": "10.0.0",
|
|
21
|
+
"@khanacademy/wonder-blocks-typography": "3.2.1"
|
|
23
22
|
},
|
|
24
23
|
"peerDependencies": {
|
|
25
24
|
"@phosphor-icons/core": "^2.0.2",
|
|
@@ -27,7 +26,7 @@
|
|
|
27
26
|
"react": "18.2.0"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
|
-
"@khanacademy/wb-dev-build-settings": "
|
|
29
|
+
"@khanacademy/wb-dev-build-settings": "3.0.0"
|
|
31
30
|
},
|
|
32
31
|
"scripts": {
|
|
33
32
|
"test": "echo \"Error: no test specified\" && exit 1"
|