@spaced-out/ui-design-system 0.0.61 → 0.0.62
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 +7 -0
- package/lib/components/AvatarGroup/AvatarGroup.module.css +1 -0
- package/lib/components/Card/Card.js +18 -2
- package/lib/components/Card/Card.js.flow +30 -7
- package/lib/components/Card/Card.module.css +3 -0
- package/lib/components/SubMenu/SubMenu.js +16 -2
- package/lib/components/SubMenu/SubMenu.js.flow +15 -0
- package/lib/components/SubMenu/SubMenu.module.css +35 -4
- package/package.json +1 -1
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.62](https://github.com/spaced-out/ui-design-system/compare/v0.0.61...v0.0.62) (2023-03-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* 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))
|
|
11
|
+
|
|
5
12
|
### [0.0.61](https://github.com/spaced-out/ui-design-system/compare/v0.0.60...v0.0.61) (2023-03-27)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -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,
|
|
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
|
-
|
|
72
|
-
{
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
};
|
|
@@ -66,6 +66,11 @@ const SubMenuItem = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
|
66
66
|
onChange && onChange(menuKey);
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
|
+
const onKeyDownHandler = e => {
|
|
70
|
+
if (e.key === 'Enter') {
|
|
71
|
+
onChangeHandler();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
69
74
|
const selected = selectedMenuKey === menuKey;
|
|
70
75
|
const getNamedComp = comp => {
|
|
71
76
|
const childrenArray = React.Children.toArray(children);
|
|
@@ -88,8 +93,10 @@ const SubMenuItem = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
|
88
93
|
[_SubMenuModule.default.selected]: selected,
|
|
89
94
|
[_SubMenuModule.default.disabled]: disabled
|
|
90
95
|
}, classNames?.wrapper),
|
|
96
|
+
onKeyDown: onKeyDownHandler,
|
|
91
97
|
onClick: onChangeHandler,
|
|
92
|
-
ref: ref
|
|
98
|
+
ref: ref,
|
|
99
|
+
tabIndex: disabled ? '-1' : 0
|
|
93
100
|
}), /*#__PURE__*/React.createElement("div", {
|
|
94
101
|
className: _SubMenuModule.default.menuIconName
|
|
95
102
|
}, getNamedComp('SubMenuItemIcon'), getNamedComp('SubMenuItemText')), getNamedComp('SubMenuItemAction'));
|
|
@@ -114,6 +121,11 @@ const SubMenuGroup = _ref5 => {
|
|
|
114
121
|
onChange(value);
|
|
115
122
|
}
|
|
116
123
|
};
|
|
124
|
+
const onKeyDownHandlerHeader = e => {
|
|
125
|
+
if (e.key === 'Enter') {
|
|
126
|
+
collapseHandler();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
117
129
|
const childrenWithProps = React.Children.map(children, child => {
|
|
118
130
|
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
119
131
|
const {
|
|
@@ -131,7 +143,9 @@ const SubMenuGroup = _ref5 => {
|
|
|
131
143
|
className: (0, _classify.default)(_SubMenuModule.default.subMenuGroupWrapper, classNames?.wrapper)
|
|
132
144
|
}, /*#__PURE__*/React.createElement("div", {
|
|
133
145
|
className: (0, _classify.default)(_SubMenuModule.default.subMenuGroupHeader, classNames?.groupHeader),
|
|
134
|
-
onClick: collapseHandler
|
|
146
|
+
onClick: collapseHandler,
|
|
147
|
+
onKeyDown: onKeyDownHandlerHeader,
|
|
148
|
+
tabindex: "0"
|
|
135
149
|
}, /*#__PURE__*/React.createElement(_Text.SubTitleExtraSmall, {
|
|
136
150
|
color: _Text.TEXT_COLORS.inverseSecondary,
|
|
137
151
|
className: _SubMenuModule.default.groupTitle
|
|
@@ -97,6 +97,12 @@ export const SubMenuItem: React$AbstractComponent<
|
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
+
const onKeyDownHandler = (e) => {
|
|
101
|
+
if (e.key === 'Enter') {
|
|
102
|
+
onChangeHandler();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
100
106
|
const selected = selectedMenuKey === menuKey;
|
|
101
107
|
|
|
102
108
|
const getNamedComp = (comp: string) => {
|
|
@@ -129,8 +135,10 @@ export const SubMenuItem: React$AbstractComponent<
|
|
|
129
135
|
},
|
|
130
136
|
classNames?.wrapper,
|
|
131
137
|
)}
|
|
138
|
+
onKeyDown={onKeyDownHandler}
|
|
132
139
|
onClick={onChangeHandler}
|
|
133
140
|
ref={ref}
|
|
141
|
+
tabIndex={disabled ? '-1' : 0}
|
|
134
142
|
>
|
|
135
143
|
<div className={css.menuIconName}>
|
|
136
144
|
{getNamedComp('SubMenuItemIcon')}
|
|
@@ -176,6 +184,11 @@ export const SubMenuGroup = ({
|
|
|
176
184
|
onChange(value);
|
|
177
185
|
}
|
|
178
186
|
};
|
|
187
|
+
const onKeyDownHandlerHeader = (e) => {
|
|
188
|
+
if (e.key === 'Enter') {
|
|
189
|
+
collapseHandler();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
179
192
|
const childrenWithProps = React.Children.map(children, (child) => {
|
|
180
193
|
if (React.isValidElement(child)) {
|
|
181
194
|
const {disabled: disabledChild} = child.props;
|
|
@@ -192,6 +205,8 @@ export const SubMenuGroup = ({
|
|
|
192
205
|
<div
|
|
193
206
|
className={classify(css.subMenuGroupHeader, classNames?.groupHeader)}
|
|
194
207
|
onClick={collapseHandler}
|
|
208
|
+
onKeyDown={onKeyDownHandlerHeader}
|
|
209
|
+
tabindex="0"
|
|
195
210
|
>
|
|
196
211
|
<SubTitleExtraSmall
|
|
197
212
|
color={TEXT_COLORS.inverseSecondary}
|
|
@@ -1,14 +1,19 @@
|
|
|
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
|
+
colorSuccess,
|
|
12
|
+
colorFocusDanger
|
|
8
13
|
) from '../../styles/variables/_color.css';
|
|
9
14
|
@value ( spaceNone, spaceXSmall, spaceSmall, spaceMedium ) from '../../styles/variables/_space.css';
|
|
10
15
|
|
|
11
|
-
@value ( borderRadiusSmall, borderWidthPrimary) from '../../styles/variables/_border.css';
|
|
16
|
+
@value ( borderWidthTertiary, borderRadiusSmall, borderWidthPrimary, borderRadiusMedium, borderWidthNone) from '../../styles/variables/_border.css';
|
|
12
17
|
|
|
13
18
|
.subMenuWrapper {
|
|
14
19
|
background: colorSubMenuBackgroundDefault;
|
|
@@ -50,7 +55,21 @@
|
|
|
50
55
|
flex-direction: row;
|
|
51
56
|
justify-content: space-between;
|
|
52
57
|
cursor: pointer;
|
|
53
|
-
padding:
|
|
58
|
+
padding: spaceXSmall;
|
|
59
|
+
border-radius: borderRadiusSmall;
|
|
60
|
+
border: borderWidthTertiary solid colorFillNone;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.subMenuGroupHeader:focus-within {
|
|
64
|
+
border: borderWidthTertiary solid colorFocusPrimary;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.subMenuGroupHeader:focus-visible {
|
|
68
|
+
outline: none;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.subMenuGroupHeader:focus {
|
|
72
|
+
border: borderWidthTertiary solid colorFocusPrimary;
|
|
54
73
|
}
|
|
55
74
|
|
|
56
75
|
.groupTitle {
|
|
@@ -60,7 +79,8 @@
|
|
|
60
79
|
.subMenuGroup {
|
|
61
80
|
display: flex;
|
|
62
81
|
flex-direction: column;
|
|
63
|
-
margin-top:
|
|
82
|
+
margin-top: spaceMedium;
|
|
83
|
+
gap: spaceMedium;
|
|
64
84
|
}
|
|
65
85
|
|
|
66
86
|
.subMenuGroup.collapsed {
|
|
@@ -83,12 +103,23 @@
|
|
|
83
103
|
width: sizeFluid;
|
|
84
104
|
cursor: pointer;
|
|
85
105
|
padding: spaceXSmall;
|
|
106
|
+
box-sizing: border-box;
|
|
107
|
+
border: borderWidthTertiary solid colorFillNone;
|
|
86
108
|
}
|
|
87
109
|
|
|
88
110
|
.menuItem:not(.selected):hover {
|
|
89
111
|
color: colorTextInversePrimary;
|
|
90
112
|
}
|
|
91
113
|
|
|
114
|
+
.menuItem:focus-visible {
|
|
115
|
+
outline: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.menuItem:focus {
|
|
119
|
+
background: colorNeutralDarkest;
|
|
120
|
+
border: borderWidthTertiary solid colorFocusPrimary;
|
|
121
|
+
}
|
|
122
|
+
|
|
92
123
|
.menuIcon {
|
|
93
124
|
color: inherit;
|
|
94
125
|
}
|