@spaced-out/ui-design-system 0.0.61 → 0.0.63

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,20 @@
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.63](https://github.com/spaced-out/ui-design-system/compare/v0.0.62...v0.0.63) (2023-03-28)
6
+
7
+
8
+ ### Features
9
+
10
+ * optional close button for submenu header ([#85](https://github.com/spaced-out/ui-design-system/issues/85)) ([24cfbdb](https://github.com/spaced-out/ui-design-system/commit/24cfbdb0f8c985fee3ecf8de6771f07eacae26ff))
11
+
12
+ ### [0.0.62](https://github.com/spaced-out/ui-design-system/compare/v0.0.61...v0.0.62) (2023-03-28)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * sub menu focus and avatar border ([#84](https://github.com/spaced-out/ui-design-system/issues/84)) ([151807a](https://github.com/spaced-out/ui-design-system/commit/151807a18c429670702f3504b9d4a61e4ea5da46))
18
+
5
19
  ### [0.0.61](https://github.com/spaced-out/ui-design-system/compare/v0.0.60...v0.0.61) (2023-03-27)
6
20
 
7
21
 
@@ -22,6 +22,7 @@
22
22
  .avatarInGroup {
23
23
  display: flex;
24
24
  border: borderWidthTertiary solid colorBackgroundTertiary;
25
+ position: relative;
25
26
  }
26
27
 
27
28
  .nameList {
@@ -48,13 +48,29 @@ exports.Card = Card;
48
48
  const ClickableCard = _ref2 => {
49
49
  let {
50
50
  classNames,
51
+ onClick,
52
+ disabled = false,
51
53
  ...props
52
54
  } = _ref2;
55
+ const onClickHandler = e => {
56
+ if (!disabled) {
57
+ onClick && onClick(e);
58
+ }
59
+ };
60
+ const onKeyDownHandler = e => {
61
+ if (e.key === 'Enter') {
62
+ onClickHandler(e);
63
+ }
64
+ };
53
65
  return /*#__PURE__*/React.createElement(Card, _extends({}, props, {
54
66
  classNames: {
55
- wrapper: (0, _classify.default)(_CardModule.default.clickableCard, classNames?.wrapper)
67
+ wrapper: (0, _classify.default)(_CardModule.default.clickableCard, {
68
+ [_CardModule.default.disabled]: disabled
69
+ }, classNames?.wrapper)
56
70
  },
57
- tabIndex: "0"
71
+ tabIndex: "0",
72
+ onClick: onClickHandler,
73
+ onKeyDown: onKeyDownHandler
58
74
  }));
59
75
  };
60
76
  exports.ClickableCard = ClickableCard;
@@ -32,6 +32,7 @@ export type CardProps = {
32
32
  export type ClickableCardProps = {
33
33
  ...CardProps,
34
34
  onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
35
+ disabled?: boolean,
35
36
  ...
36
37
  };
37
38
 
@@ -66,11 +67,33 @@ export const Card = ({
66
67
 
67
68
  export const ClickableCard = ({
68
69
  classNames,
70
+ onClick,
71
+ disabled = false,
69
72
  ...props
70
- }: ClickableCardProps): React.Node => (
71
- <Card
72
- {...props}
73
- classNames={{wrapper: classify(css.clickableCard, classNames?.wrapper)}}
74
- tabIndex="0"
75
- />
76
- );
73
+ }: ClickableCardProps): React.Node => {
74
+ const onClickHandler = (e) => {
75
+ if (!disabled) {
76
+ onClick && onClick(e);
77
+ }
78
+ };
79
+ const onKeyDownHandler = (e) => {
80
+ if (e.key === 'Enter') {
81
+ onClickHandler(e);
82
+ }
83
+ };
84
+ return (
85
+ <Card
86
+ {...props}
87
+ classNames={{
88
+ wrapper: classify(
89
+ css.clickableCard,
90
+ {[css.disabled]: disabled},
91
+ classNames?.wrapper,
92
+ ),
93
+ }}
94
+ tabIndex="0"
95
+ onClick={onClickHandler}
96
+ onKeyDown={onKeyDownHandler}
97
+ />
98
+ );
99
+ };
@@ -21,6 +21,9 @@
21
21
  cursor: pointer;
22
22
  outline: none;
23
23
  }
24
+ .clickableCard.disabled {
25
+ pointer-events: none;
26
+ }
24
27
 
25
28
  .clickableCard:hover {
26
29
  border-color: colorBorderSecondary;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.SubMenuItemText = exports.SubMenuItemIcon = exports.SubMenuItemAction = exports.SubMenuItem = exports.SubMenuGroup = exports.SubMenu = void 0;
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _classify = _interopRequireDefault(require("../../utils/classify"));
9
+ var _Button = require("../Button");
9
10
  var _Icon = require("../Icon");
10
11
  var _Text = require("../Text");
11
12
  var _SubMenuModule = _interopRequireDefault(require("./SubMenu.module.css"));
@@ -66,6 +67,11 @@ const SubMenuItem = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
66
67
  onChange && onChange(menuKey);
67
68
  }
68
69
  };
70
+ const onKeyDownHandler = e => {
71
+ if (e.key === 'Enter') {
72
+ onChangeHandler();
73
+ }
74
+ };
69
75
  const selected = selectedMenuKey === menuKey;
70
76
  const getNamedComp = comp => {
71
77
  const childrenArray = React.Children.toArray(children);
@@ -88,8 +94,10 @@ const SubMenuItem = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
88
94
  [_SubMenuModule.default.selected]: selected,
89
95
  [_SubMenuModule.default.disabled]: disabled
90
96
  }, classNames?.wrapper),
97
+ onKeyDown: onKeyDownHandler,
91
98
  onClick: onChangeHandler,
92
- ref: ref
99
+ ref: ref,
100
+ tabIndex: disabled ? '-1' : 0
93
101
  }), /*#__PURE__*/React.createElement("div", {
94
102
  className: _SubMenuModule.default.menuIconName
95
103
  }, getNamedComp('SubMenuItemIcon'), getNamedComp('SubMenuItemText')), getNamedComp('SubMenuItemAction'));
@@ -114,6 +122,11 @@ const SubMenuGroup = _ref5 => {
114
122
  onChange(value);
115
123
  }
116
124
  };
125
+ const onKeyDownHandlerHeader = e => {
126
+ if (e.key === 'Enter') {
127
+ collapseHandler();
128
+ }
129
+ };
117
130
  const childrenWithProps = React.Children.map(children, child => {
118
131
  if ( /*#__PURE__*/React.isValidElement(child)) {
119
132
  const {
@@ -131,7 +144,9 @@ const SubMenuGroup = _ref5 => {
131
144
  className: (0, _classify.default)(_SubMenuModule.default.subMenuGroupWrapper, classNames?.wrapper)
132
145
  }, /*#__PURE__*/React.createElement("div", {
133
146
  className: (0, _classify.default)(_SubMenuModule.default.subMenuGroupHeader, classNames?.groupHeader),
134
- onClick: collapseHandler
147
+ onClick: collapseHandler,
148
+ onKeyDown: onKeyDownHandlerHeader,
149
+ tabindex: "0"
135
150
  }, /*#__PURE__*/React.createElement(_Text.SubTitleExtraSmall, {
136
151
  color: _Text.TEXT_COLORS.inverseSecondary,
137
152
  className: _SubMenuModule.default.groupTitle
@@ -150,7 +165,9 @@ const SubMenu = _ref6 => {
150
165
  let {
151
166
  classNames,
152
167
  children,
153
- title
168
+ title,
169
+ onClose,
170
+ showClose = false
154
171
  } = _ref6;
155
172
  const childrenWithProps = React.Children.map(children, child => {
156
173
  if ( /*#__PURE__*/React.isValidElement(child)) {
@@ -161,10 +178,23 @@ const SubMenu = _ref6 => {
161
178
  });
162
179
  return /*#__PURE__*/React.createElement("div", {
163
180
  className: (0, _classify.default)(_SubMenuModule.default.subMenuWrapper, classNames?.wrapper)
181
+ }, /*#__PURE__*/React.createElement("div", {
182
+ className: _SubMenuModule.default.subMenuTitleAndButton
164
183
  }, /*#__PURE__*/React.createElement(_Text.SubTitleMedium, {
165
184
  className: _SubMenuModule.default.subMenuHeader,
166
185
  color: _Text.TEXT_COLORS.inversePrimary
167
- }, title), childrenWithProps);
186
+ }, title), showClose && /*#__PURE__*/React.createElement(_Button.Button, {
187
+ ariaLabel: "Icon Button",
188
+ iconRightName: "close",
189
+ onClick: onClose,
190
+ size: "small",
191
+ type: "ghost",
192
+ actionType: "button",
193
+ classNames: {
194
+ wrapper: _SubMenuModule.default.subMenuCloseButton,
195
+ icon: _SubMenuModule.default.subMenuCloseIcon
196
+ }
197
+ })), childrenWithProps);
168
198
  };
169
199
  exports.SubMenu = SubMenu;
170
200
  SubMenu.displayName = 'SubMenu';
@@ -4,6 +4,7 @@ import * as React from 'react';
4
4
 
5
5
  import type {ColorTypes} from '../../types/typography';
6
6
  import classify from '../../utils/classify';
7
+ import {Button} from '../Button';
7
8
  import type {IconProps} from '../Icon';
8
9
  import {Icon} from '../Icon';
9
10
  import type {TextProps} from '../Text';
@@ -97,6 +98,12 @@ export const SubMenuItem: React$AbstractComponent<
97
98
  }
98
99
  };
99
100
 
101
+ const onKeyDownHandler = (e) => {
102
+ if (e.key === 'Enter') {
103
+ onChangeHandler();
104
+ }
105
+ };
106
+
100
107
  const selected = selectedMenuKey === menuKey;
101
108
 
102
109
  const getNamedComp = (comp: string) => {
@@ -129,8 +136,10 @@ export const SubMenuItem: React$AbstractComponent<
129
136
  },
130
137
  classNames?.wrapper,
131
138
  )}
139
+ onKeyDown={onKeyDownHandler}
132
140
  onClick={onChangeHandler}
133
141
  ref={ref}
142
+ tabIndex={disabled ? '-1' : 0}
134
143
  >
135
144
  <div className={css.menuIconName}>
136
145
  {getNamedComp('SubMenuItemIcon')}
@@ -176,6 +185,11 @@ export const SubMenuGroup = ({
176
185
  onChange(value);
177
186
  }
178
187
  };
188
+ const onKeyDownHandlerHeader = (e) => {
189
+ if (e.key === 'Enter') {
190
+ collapseHandler();
191
+ }
192
+ };
179
193
  const childrenWithProps = React.Children.map(children, (child) => {
180
194
  if (React.isValidElement(child)) {
181
195
  const {disabled: disabledChild} = child.props;
@@ -192,6 +206,8 @@ export const SubMenuGroup = ({
192
206
  <div
193
207
  className={classify(css.subMenuGroupHeader, classNames?.groupHeader)}
194
208
  onClick={collapseHandler}
209
+ onKeyDown={onKeyDownHandlerHeader}
210
+ tabindex="0"
195
211
  >
196
212
  <SubTitleExtraSmall
197
213
  color={TEXT_COLORS.inverseSecondary}
@@ -226,12 +242,16 @@ export type SubMenuProps = {
226
242
  classNames?: ClassNames,
227
243
  title: string,
228
244
  children?: React.Node,
245
+ onClose?: () => mixed,
246
+ showClose?: boolean,
229
247
  };
230
248
 
231
249
  export const SubMenu = ({
232
250
  classNames,
233
251
  children,
234
252
  title,
253
+ onClose,
254
+ showClose = false,
235
255
  }: SubMenuProps): React.Node => {
236
256
  const childrenWithProps = React.Children.map(children, (child) => {
237
257
  if (React.isValidElement(child)) {
@@ -241,12 +261,28 @@ export const SubMenu = ({
241
261
 
242
262
  return (
243
263
  <div className={classify(css.subMenuWrapper, classNames?.wrapper)}>
244
- <SubTitleMedium
245
- className={css.subMenuHeader}
246
- color={TEXT_COLORS.inversePrimary}
247
- >
248
- {title}
249
- </SubTitleMedium>
264
+ <div className={css.subMenuTitleAndButton}>
265
+ <SubTitleMedium
266
+ className={css.subMenuHeader}
267
+ color={TEXT_COLORS.inversePrimary}
268
+ >
269
+ {title}
270
+ </SubTitleMedium>
271
+ {showClose && (
272
+ <Button
273
+ ariaLabel="Icon Button"
274
+ iconRightName="close"
275
+ onClick={onClose}
276
+ size="small"
277
+ type="ghost"
278
+ actionType="button"
279
+ classNames={{
280
+ wrapper: css.subMenuCloseButton,
281
+ icon: css.subMenuCloseIcon,
282
+ }}
283
+ />
284
+ )}
285
+ </div>
250
286
  {childrenWithProps}
251
287
  </div>
252
288
  );
@@ -1,14 +1,20 @@
1
1
  @value ( size34, size60, sizeFluid, sizeFullViewportHeight) from '../../styles/variables/_size.css';
2
2
 
3
3
  @value (
4
+ colorFillNone,
5
+ colorFillPrimary,
6
+ colorFocusPrimary,
4
7
  colorNeutralDarkest,
5
8
  colorTextInverseSecondary,
6
9
  colorTextInversePrimary,
7
- colorSubMenuBackgroundDefault
10
+ colorSubMenuBackgroundDefault,
11
+ colorSideMenuIconActive,
12
+ colorSuccess,
13
+ colorFocusDanger
8
14
  ) from '../../styles/variables/_color.css';
9
15
  @value ( spaceNone, spaceXSmall, spaceSmall, spaceMedium ) from '../../styles/variables/_space.css';
10
16
 
11
- @value ( borderRadiusSmall, borderWidthPrimary) from '../../styles/variables/_border.css';
17
+ @value ( borderWidthTertiary, borderRadiusSmall, borderWidthPrimary, borderRadiusMedium, borderWidthNone) from '../../styles/variables/_border.css';
12
18
 
13
19
  .subMenuWrapper {
14
20
  background: colorSubMenuBackgroundDefault;
@@ -20,13 +26,31 @@
20
26
  user-select: none;
21
27
  }
22
28
 
29
+ .subMenuTitleAndButton {
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: space-between;
33
+ border-bottom: borderWidthPrimary solid colorNeutralDarkest;
34
+ }
35
+
36
+ .subMenuCloseButton {
37
+ margin: spaceSmall;
38
+ }
39
+
40
+ .subMenuCloseButton:hover {
41
+ background-color: colorNeutralDarkest;
42
+ }
43
+
44
+ .subMenuCloseIcon {
45
+ color: colorSideMenuIconActive;
46
+ }
47
+
23
48
  .subMenuHeader {
24
49
  height: size60;
25
50
  display: flex;
26
51
  flex-direction: row;
27
52
  align-items: center;
28
53
  padding: spaceMedium;
29
- border-bottom: borderWidthPrimary solid colorNeutralDarkest;
30
54
  }
31
55
 
32
56
  .menuChildWrap {
@@ -50,7 +74,21 @@
50
74
  flex-direction: row;
51
75
  justify-content: space-between;
52
76
  cursor: pointer;
53
- padding: spaceNone spaceXSmall spaceNone spaceXSmall;
77
+ padding: spaceXSmall;
78
+ border-radius: borderRadiusSmall;
79
+ border: borderWidthTertiary solid colorFillNone;
80
+ }
81
+
82
+ .subMenuGroupHeader:focus-within {
83
+ border: borderWidthTertiary solid colorFocusPrimary;
84
+ }
85
+
86
+ .subMenuGroupHeader:focus-visible {
87
+ outline: none;
88
+ }
89
+
90
+ .subMenuGroupHeader:focus {
91
+ border: borderWidthTertiary solid colorFocusPrimary;
54
92
  }
55
93
 
56
94
  .groupTitle {
@@ -60,7 +98,8 @@
60
98
  .subMenuGroup {
61
99
  display: flex;
62
100
  flex-direction: column;
63
- margin-top: spaceXSmall;
101
+ margin-top: spaceMedium;
102
+ gap: spaceMedium;
64
103
  }
65
104
 
66
105
  .subMenuGroup.collapsed {
@@ -83,12 +122,23 @@
83
122
  width: sizeFluid;
84
123
  cursor: pointer;
85
124
  padding: spaceXSmall;
125
+ box-sizing: border-box;
126
+ border: borderWidthTertiary solid colorFillNone;
86
127
  }
87
128
 
88
129
  .menuItem:not(.selected):hover {
89
130
  color: colorTextInversePrimary;
90
131
  }
91
132
 
133
+ .menuItem:focus-visible {
134
+ outline: none;
135
+ }
136
+
137
+ .menuItem:focus {
138
+ background: colorNeutralDarkest;
139
+ border: borderWidthTertiary solid colorFocusPrimary;
140
+ }
141
+
92
142
  .menuIcon {
93
143
  color: inherit;
94
144
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.0.61",
3
+ "version": "0.0.63",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {