@spaced-out/ui-design-system 0.0.46 → 0.0.47

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
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.47](https://github.com/spaced-out/ui-design-system/compare/v0.0.46...v0.0.47) (2023-03-13)
6
+
7
+
8
+ ### Features
9
+
10
+ * banner component ([bbf4420](https://github.com/spaced-out/ui-design-system/commit/bbf4420b9ed333c902a56442d9a64b8558c820a1))
11
+
5
12
  ### [0.0.46](https://github.com/spaced-out/ui-design-system/compare/v0.0.45...v0.0.46) (2023-03-10)
6
13
 
7
14
 
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Banner = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
9
+ var _InContextAlert = require("../InContextAlert");
10
+ var _BannerModule = _interopRequireDefault(require("./Banner.module.css"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
+ const Banner = _ref => {
16
+ let {
17
+ classNames,
18
+ semantic,
19
+ leftIconType = 'solid',
20
+ alignment = 'top',
21
+ ...props
22
+ } = _ref;
23
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_InContextAlert.InContextAlert, _extends({}, props, {
24
+ leftIconType: leftIconType,
25
+ semantic: semantic,
26
+ classNames: {
27
+ wrapper: (0, _classify.default)(_BannerModule.default.bannerContainer, {
28
+ [_BannerModule.default.neutral]: semantic === _InContextAlert.ALERT_SEMANTIC.neutral,
29
+ [_BannerModule.default.success]: semantic === _InContextAlert.ALERT_SEMANTIC.success,
30
+ [_BannerModule.default.information]: semantic === _InContextAlert.ALERT_SEMANTIC.information,
31
+ [_BannerModule.default.warning]: semantic === _InContextAlert.ALERT_SEMANTIC.warning,
32
+ [_BannerModule.default.danger]: semantic === _InContextAlert.ALERT_SEMANTIC.danger,
33
+ [_BannerModule.default.topAligned]: alignment === 'top',
34
+ [_BannerModule.default.bottomAligned]: alignment === 'bottom'
35
+ }, classNames?.wrapper),
36
+ alertText: (0, _classify.default)(classNames?.alertText),
37
+ actionContainer: (0, _classify.default)(_BannerModule.default.alertContainer, classNames?.actionContainer)
38
+ }
39
+ })));
40
+ };
41
+ exports.Banner = Banner;
@@ -0,0 +1,51 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import classify from '../../utils/classify';
6
+ import type {InContextAlertProps} from '../InContextAlert';
7
+ import {ALERT_SEMANTIC, InContextAlert} from '../InContextAlert';
8
+
9
+ import css from './Banner.module.css';
10
+
11
+
12
+ export type BannerProps = {
13
+ ...InContextAlertProps,
14
+ alignment?: 'top' | 'bottom',
15
+ };
16
+
17
+ export const Banner = ({
18
+ classNames,
19
+ semantic,
20
+ leftIconType = 'solid',
21
+ alignment = 'top',
22
+ ...props
23
+ }: BannerProps): React.Node => (
24
+ <>
25
+ <InContextAlert
26
+ {...props}
27
+ leftIconType={leftIconType}
28
+ semantic={semantic}
29
+ classNames={{
30
+ wrapper: classify(
31
+ css.bannerContainer,
32
+ {
33
+ [css.neutral]: semantic === ALERT_SEMANTIC.neutral,
34
+ [css.success]: semantic === ALERT_SEMANTIC.success,
35
+ [css.information]: semantic === ALERT_SEMANTIC.information,
36
+ [css.warning]: semantic === ALERT_SEMANTIC.warning,
37
+ [css.danger]: semantic === ALERT_SEMANTIC.danger,
38
+ [css.topAligned]: alignment === 'top',
39
+ [css.bottomAligned]: alignment === 'bottom',
40
+ },
41
+ classNames?.wrapper,
42
+ ),
43
+ alertText: classify(classNames?.alertText),
44
+ actionContainer: classify(
45
+ css.alertContainer,
46
+ classNames?.actionContainer,
47
+ ),
48
+ }}
49
+ />
50
+ </>
51
+ );
@@ -0,0 +1,56 @@
1
+ @value (
2
+ colorNeutralLight,
3
+ colorSuccessLight,
4
+ colorInformationLight,
5
+ colorWarningLight,
6
+ colorDangerLight
7
+ ) from '../../styles/variables/_color.css';
8
+
9
+ @value (
10
+ spaceMedium,
11
+ spaceSmall
12
+ ) from '../../styles/variables/_space.css';
13
+
14
+ @value (
15
+ borderWidthPrimary
16
+ ) from '../../styles/variables/_border.css';
17
+
18
+ .bannerContainer {
19
+ border: none;
20
+ border-radius: initial;
21
+ padding: spaceSmall spaceMedium;
22
+ }
23
+
24
+ .neutral {
25
+ border-color: colorNeutralLight;
26
+ }
27
+
28
+ .success {
29
+ border-color: colorSuccessLight;
30
+ }
31
+
32
+ .information {
33
+ border-color: colorInformationLight;
34
+ }
35
+
36
+ .warning {
37
+ border-color: colorWarningLight;
38
+ }
39
+
40
+ .danger {
41
+ border-color: colorDangerLight;
42
+ }
43
+
44
+ .topAligned {
45
+ border-bottom-width: borderWidthPrimary;
46
+ border-bottom-style: solid;
47
+ }
48
+
49
+ .bottomAligned {
50
+ border-top-width: borderWidthPrimary;
51
+ border-top-style: solid;
52
+ }
53
+
54
+ .alertContainer {
55
+ padding-left: calc(spaceSmall * 2);
56
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Banner = require("./Banner");
7
+ Object.keys(_Banner).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Banner[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Banner[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './Banner';
@@ -26,7 +26,8 @@ exports.ALERT_SEMANTIC = ALERT_SEMANTIC;
26
26
  const AlertIcon = _ref => {
27
27
  let {
28
28
  semantic,
29
- leftIconName
29
+ leftIconName,
30
+ leftIconType
30
31
  } = _ref;
31
32
  switch (semantic) {
32
33
  case ALERT_SEMANTIC.neutral:
@@ -34,42 +35,42 @@ const AlertIcon = _ref => {
34
35
  color: _typography.TEXT_COLORS.neutral,
35
36
  name: leftIconName ? leftIconName : 'face-smile',
36
37
  size: "small",
37
- type: "regular"
38
+ type: leftIconType
38
39
  });
39
40
  case ALERT_SEMANTIC.success:
40
41
  return /*#__PURE__*/React.createElement(_Icon.Icon, {
41
42
  name: leftIconName ? leftIconName : 'circle-check',
42
43
  size: "small",
43
44
  color: _typography.TEXT_COLORS.success,
44
- type: "regular"
45
+ type: leftIconType
45
46
  });
46
47
  case ALERT_SEMANTIC.information:
47
48
  return /*#__PURE__*/React.createElement(_Icon.Icon, {
48
49
  name: leftIconName ? leftIconName : 'circle-info',
49
50
  size: "small",
50
51
  color: _typography.TEXT_COLORS.information,
51
- type: "regular"
52
+ type: leftIconType
52
53
  });
53
54
  case ALERT_SEMANTIC.warning:
54
55
  return /*#__PURE__*/React.createElement(_Icon.Icon, {
55
56
  name: leftIconName ? leftIconName : 'circle-exclamation',
56
57
  size: "small",
57
58
  color: _typography.TEXT_COLORS.warning,
58
- type: "regular"
59
+ type: leftIconType
59
60
  });
60
61
  case ALERT_SEMANTIC.danger:
61
62
  return /*#__PURE__*/React.createElement(_Icon.Icon, {
62
63
  name: leftIconName ? leftIconName : 'shield-exclamation',
63
64
  size: "small",
64
65
  color: _typography.TEXT_COLORS.danger,
65
- type: "regular"
66
+ type: leftIconType
66
67
  });
67
68
  default:
68
69
  return /*#__PURE__*/React.createElement(_Icon.Icon, {
69
70
  color: _typography.TEXT_COLORS.neutral,
70
71
  name: leftIconName ? leftIconName : 'face-smile',
71
72
  size: "small",
72
- type: "regular"
73
+ type: leftIconType
73
74
  });
74
75
  }
75
76
  };
@@ -83,7 +84,8 @@ const InContextAlert = props => {
83
84
  leftIconName = '',
84
85
  onCloseClick,
85
86
  actionText = '',
86
- onAction
87
+ onAction,
88
+ leftIconType
87
89
  } = props;
88
90
  const [dismissed, setDismissed] = React.useState(false);
89
91
  const closeClickHandler = e => {
@@ -100,21 +102,24 @@ const InContextAlert = props => {
100
102
  }, classNames?.wrapper)
101
103
  }, /*#__PURE__*/React.createElement(AlertIcon, {
102
104
  semantic: semantic,
103
- leftIconName: leftIconName
105
+ leftIconName: leftIconName,
106
+ leftIconType: leftIconType
104
107
  }), React.Children.count(children) > 0 && /*#__PURE__*/React.createElement(_Text.SubTitleExtraSmall, {
105
108
  className: (0, _classify.classify)(classNames?.alertText)
106
109
  }, /*#__PURE__*/React.createElement(_Truncate.Truncate, {
107
110
  line: 2
108
- }, children)), actionText ? /*#__PURE__*/React.createElement(_Text.ButtonTextExtraSmall, {
111
+ }, children)), !!(actionText || dismissable) && /*#__PURE__*/React.createElement("div", {
112
+ className: (0, _classify.classify)(_InContextAlertModule.default.actionContainer, classNames?.actionContainer)
113
+ }, !!actionText && /*#__PURE__*/React.createElement(_Text.ButtonTextExtraSmall, {
109
114
  className: _InContextAlertModule.default.actionText,
110
115
  onClick: onAction
111
- }, actionText) : dismissable && /*#__PURE__*/React.createElement(_Icon.Icon, {
116
+ }, actionText), !!dismissable && /*#__PURE__*/React.createElement(_Icon.Icon, {
112
117
  color: _typography.TEXT_COLORS.primary,
113
118
  name: "close",
114
119
  size: "small",
115
120
  type: "regular",
116
121
  onClick: closeClickHandler,
117
122
  className: _InContextAlertModule.default.closeIcon
118
- })));
123
+ }))));
119
124
  };
120
125
  exports.InContextAlert = InContextAlert;
@@ -4,6 +4,7 @@ import * as React from 'react';
4
4
 
5
5
  import {TEXT_COLORS} from '../../types/typography';
6
6
  import {classify} from '../../utils/classify';
7
+ import type {IconType} from '../Icon';
7
8
  import {Icon} from '../Icon';
8
9
  import {ButtonTextExtraSmall, SubTitleExtraSmall} from '../Text';
9
10
  import {Truncate} from '../Truncate';
@@ -19,7 +20,11 @@ export const ALERT_SEMANTIC = Object.freeze({
19
20
  danger: 'danger',
20
21
  });
21
22
 
22
- type ClassNames = $ReadOnly<{wrapper?: string, alertText?: string}>;
23
+ type ClassNames = $ReadOnly<{
24
+ wrapper?: string,
25
+ alertText?: string,
26
+ actionContainer?: string,
27
+ }>;
23
28
  export type AlertSemanticType = $Values<typeof ALERT_SEMANTIC>;
24
29
 
25
30
  type InContextAlertBaseProps = {
@@ -40,14 +45,17 @@ export type InContextAlertProps = {
40
45
  ...InContextAlertBaseProps,
41
46
  semantic: AlertSemanticType,
42
47
  leftIconName?: string,
48
+ leftIconType?: IconType,
43
49
  };
44
50
 
45
51
  const AlertIcon = ({
46
52
  semantic,
47
53
  leftIconName,
54
+ leftIconType,
48
55
  }: {
49
56
  semantic: AlertSemanticType,
50
57
  leftIconName: string,
58
+ leftIconType?: IconType,
51
59
  }) => {
52
60
  switch (semantic) {
53
61
  case ALERT_SEMANTIC.neutral:
@@ -56,7 +64,7 @@ const AlertIcon = ({
56
64
  color={TEXT_COLORS.neutral}
57
65
  name={leftIconName ? leftIconName : 'face-smile'}
58
66
  size="small"
59
- type="regular"
67
+ type={leftIconType}
60
68
  />
61
69
  );
62
70
  case ALERT_SEMANTIC.success:
@@ -65,7 +73,7 @@ const AlertIcon = ({
65
73
  name={leftIconName ? leftIconName : 'circle-check'}
66
74
  size="small"
67
75
  color={TEXT_COLORS.success}
68
- type="regular"
76
+ type={leftIconType}
69
77
  />
70
78
  );
71
79
 
@@ -75,7 +83,7 @@ const AlertIcon = ({
75
83
  name={leftIconName ? leftIconName : 'circle-info'}
76
84
  size="small"
77
85
  color={TEXT_COLORS.information}
78
- type="regular"
86
+ type={leftIconType}
79
87
  />
80
88
  );
81
89
 
@@ -85,7 +93,7 @@ const AlertIcon = ({
85
93
  name={leftIconName ? leftIconName : 'circle-exclamation'}
86
94
  size="small"
87
95
  color={TEXT_COLORS.warning}
88
- type="regular"
96
+ type={leftIconType}
89
97
  />
90
98
  );
91
99
 
@@ -95,7 +103,7 @@ const AlertIcon = ({
95
103
  name={leftIconName ? leftIconName : 'shield-exclamation'}
96
104
  size="small"
97
105
  color={TEXT_COLORS.danger}
98
- type="regular"
106
+ type={leftIconType}
99
107
  />
100
108
  );
101
109
 
@@ -105,7 +113,7 @@ const AlertIcon = ({
105
113
  color={TEXT_COLORS.neutral}
106
114
  name={leftIconName ? leftIconName : 'face-smile'}
107
115
  size="small"
108
- type="regular"
116
+ type={leftIconType}
109
117
  />
110
118
  );
111
119
  }
@@ -122,6 +130,7 @@ export const InContextAlert = (props: InContextAlertProps): React.Node => {
122
130
  onCloseClick,
123
131
  actionText = '',
124
132
  onAction,
133
+ leftIconType,
125
134
  } = props;
126
135
  const [dismissed, setDismissed] = React.useState(false);
127
136
  const closeClickHandler = (e) => {
@@ -145,27 +154,42 @@ export const InContextAlert = (props: InContextAlertProps): React.Node => {
145
154
  classNames?.wrapper,
146
155
  )}
147
156
  >
148
- <AlertIcon semantic={semantic} leftIconName={leftIconName} />
157
+ <AlertIcon
158
+ semantic={semantic}
159
+ leftIconName={leftIconName}
160
+ leftIconType={leftIconType}
161
+ />
149
162
  {React.Children.count(children) > 0 && (
150
163
  <SubTitleExtraSmall className={classify(classNames?.alertText)}>
151
164
  <Truncate line={2}>{children}</Truncate>
152
165
  </SubTitleExtraSmall>
153
166
  )}
154
- {actionText ? (
155
- <ButtonTextExtraSmall className={css.actionText} onClick={onAction}>
156
- {actionText}
157
- </ButtonTextExtraSmall>
158
- ) : (
159
- dismissable && (
160
- <Icon
161
- color={TEXT_COLORS.primary}
162
- name="close"
163
- size="small"
164
- type="regular"
165
- onClick={closeClickHandler}
166
- className={css.closeIcon}
167
- />
168
- )
167
+ {!!(actionText || dismissable) && (
168
+ <div
169
+ className={classify(
170
+ css.actionContainer,
171
+ classNames?.actionContainer,
172
+ )}
173
+ >
174
+ {!!actionText && (
175
+ <ButtonTextExtraSmall
176
+ className={css.actionText}
177
+ onClick={onAction}
178
+ >
179
+ {actionText}
180
+ </ButtonTextExtraSmall>
181
+ )}
182
+ {!!dismissable && (
183
+ <Icon
184
+ color={TEXT_COLORS.primary}
185
+ name="close"
186
+ size="small"
187
+ type="regular"
188
+ onClick={closeClickHandler}
189
+ className={css.closeIcon}
190
+ />
191
+ )}
192
+ </div>
169
193
  )}
170
194
  </div>
171
195
  )}
@@ -14,7 +14,8 @@
14
14
  ) from '../../styles/variables/_color.css';
15
15
 
16
16
  @value (
17
- spaceXSmall
17
+ spaceXSmall,
18
+ spaceSmall
18
19
  ) from '../../styles/variables/_space.css';
19
20
 
20
21
  @value (
@@ -68,8 +69,14 @@
68
69
  margin-left: auto;
69
70
  }
70
71
 
72
+ .actionContainer {
73
+ display: flex;
74
+ margin-left: auto;
75
+ align-items: center;
76
+ gap: spaceSmall;
77
+ }
78
+
71
79
  .actionText {
72
80
  cursor: pointer;
73
- margin-left: auto;
74
81
  text-decoration: underline;
75
82
  }
@@ -3,16 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "ALERT_SEMANTIC", {
7
- enumerable: true,
8
- get: function () {
9
- return _InContextAlert.ALERT_SEMANTIC;
10
- }
11
- });
12
- Object.defineProperty(exports, "InContextAlert", {
13
- enumerable: true,
14
- get: function () {
15
- return _InContextAlert.InContextAlert;
16
- }
17
- });
18
- var _InContextAlert = require("./InContextAlert");
6
+ var _InContextAlert = require("./InContextAlert");
7
+ Object.keys(_InContextAlert).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _InContextAlert[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _InContextAlert[key];
14
+ }
15
+ });
16
+ });
@@ -1,3 +1,3 @@
1
1
  // @flow strict
2
2
 
3
- export {ALERT_SEMANTIC, InContextAlert} from './InContextAlert';
3
+ export * from './InContextAlert';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {