@spaced-out/ui-design-system 0.1.16 → 0.1.17
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/.cspell/custom-words.txt +3 -0
- package/.flowconfig +1 -1
- package/CHANGELOG.md +7 -0
- package/CONTRIBUTING.md +52 -6
- package/README.md +144 -8
- package/gulpfile.js +1 -0
- package/lib/components/AvatarGroup/AvatarGroup.js +4 -3
- package/lib/components/AvatarGroup/AvatarGroup.js.flow +119 -110
- package/lib/components/Badge/Badge.js +4 -3
- package/lib/components/Badge/Badge.js.flow +21 -21
- package/lib/components/Badge/index.js +11 -7
- package/lib/components/Badge/index.js.flow +1 -2
- package/lib/components/Banner/Banner.js +3 -2
- package/lib/components/Banner/Banner.js.flow +42 -35
- package/lib/components/Button/Button.js +50 -10
- package/lib/components/Button/Button.js.flow +87 -23
- package/lib/components/Button/Button.module.css +14 -0
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js +3 -2
- package/lib/components/ButtonTabs/ButtonTab/ButtonTab.js.flow +48 -38
- package/lib/components/ButtonTabs/ButtonTabs.js +3 -2
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +50 -41
- package/lib/components/Card/Card.js +16 -7
- package/lib/components/Card/Card.js.flow +73 -55
- package/lib/components/Chip/Chip.js +3 -2
- package/lib/components/Chip/Chip.js.flow +66 -59
- package/lib/components/CircularLoader/CircularLoader.js +9 -4
- package/lib/components/CircularLoader/CircularLoader.js.flow +38 -24
- package/lib/components/CollapsibleCard/CollapsibleCard.js +4 -3
- package/lib/components/CollapsibleCard/CollapsibleCard.js.flow +68 -59
- package/lib/components/Dropdown/Dropdown.js +4 -3
- package/lib/components/Dropdown/Dropdown.js.flow +83 -74
- package/lib/components/EmptyState/EmptyState.js +4 -3
- package/lib/components/EmptyState/EmptyState.js.flow +53 -44
- package/lib/components/ErrorMessage/ErrorMessage.js +4 -3
- package/lib/components/ErrorMessage/ErrorMessage.js.flow +58 -49
- package/lib/components/InContextAlert/InContextAlert.js +4 -3
- package/lib/components/InContextAlert/InContextAlert.js.flow +79 -73
- package/lib/components/InlineDropdown/InlineDropdown.js +4 -3
- package/lib/components/InlineDropdown/InlineDropdown.js.flow +94 -85
- package/lib/components/LinearLoader/LinearLoader.js +4 -3
- package/lib/components/LinearLoader/LinearLoader.js.flow +20 -18
- package/lib/components/Link/Link.js +8 -1
- package/lib/components/Link/Link.js.flow +44 -36
- package/lib/components/Notification/Notification.js +8 -6
- package/lib/components/Notification/Notification.js.flow +96 -84
- package/lib/components/OptionButton/OptionButton.js +7 -4
- package/lib/components/OptionButton/OptionButton.js.flow +69 -59
- package/lib/components/PageTitle/PageTitle.js +4 -3
- package/lib/components/PageTitle/PageTitle.js.flow +46 -44
- package/lib/components/Pagination/PaginationItem.js +2 -2
- package/lib/components/Pagination/PaginationItem.js.flow +2 -2
- package/lib/components/SearchInput/SearchInput.js +3 -2
- package/lib/components/SearchInput/SearchInput.js.flow +59 -50
- package/lib/components/SideMenuLink/SideMenuLink.js +4 -3
- package/lib/components/SideMenuLink/SideMenuLink.js.flow +54 -45
- package/lib/components/StatusIndicator/StatusIndicator.js +3 -2
- package/lib/components/StatusIndicator/StatusIndicator.js.flow +32 -23
- package/lib/components/SubMenu/SubMenu.js +4 -3
- package/lib/components/SubMenu/SubMenu.js.flow +41 -38
- package/lib/components/Table/StaticTable.js +3 -0
- package/lib/components/Table/StaticTable.js.flow +3 -0
- package/lib/components/Table/Table.js +10 -0
- package/lib/components/Table/Table.js.flow +10 -0
- package/lib/components/Table/hooks.js +1 -0
- package/lib/components/Table/hooks.js.flow +1 -0
- package/lib/components/Tabs/TabList/TabList.js +3 -2
- package/lib/components/Tabs/TabList/TabList.js.flow +127 -117
- package/lib/components/Toggle/index.js +11 -7
- package/lib/components/Toggle/index.js.flow +1 -1
- package/lib/components/Tooltip/Tooltip.js.flow +2 -2
- package/lib/components/index.js +511 -0
- package/lib/components/index.js.flow +48 -0
- package/lib/index.js +60 -0
- package/lib/index.js.flow +7 -0
- package/lib/styles/index.css +15 -0
- package/lib/styles/index.js +104 -0
- package/lib/styles/index.js.flow +12 -0
- package/lib/styles/typography.module.css +0 -1
- package/lib/styles/utils.module.css +26 -0
- package/lib/types/index.js +38 -0
- package/lib/types/index.js.flow +5 -0
- package/lib/utils/index.js +93 -0
- package/lib/utils/index.js.flow +10 -0
- package/package.json +2 -1
package/.cspell/custom-words.txt
CHANGED
|
@@ -9,6 +9,7 @@ datetime
|
|
|
9
9
|
DEFAULTTEXT
|
|
10
10
|
dismissable
|
|
11
11
|
eqeqeq
|
|
12
|
+
fbjs
|
|
12
13
|
Fennimore
|
|
13
14
|
flowtype
|
|
14
15
|
fontawesome
|
|
@@ -32,6 +33,7 @@ rgba
|
|
|
32
33
|
sbdocs
|
|
33
34
|
Stapleton
|
|
34
35
|
superrover
|
|
36
|
+
systemjs
|
|
35
37
|
testid
|
|
36
38
|
tnum
|
|
37
39
|
transclude
|
|
@@ -39,4 +41,5 @@ Typeahead
|
|
|
39
41
|
typeof
|
|
40
42
|
Verda
|
|
41
43
|
xmark
|
|
44
|
+
yourcomponentname
|
|
42
45
|
yxxx
|
package/.flowconfig
CHANGED
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.1.17](https://github.com/spaced-out/ui-design-system/compare/v0.1.16...v0.1.17) (2023-04-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* button loading - focus management - forwardref - simple imports ([#105](https://github.com/spaced-out/ui-design-system/issues/105)) ([29d4b4f](https://github.com/spaced-out/ui-design-system/commit/29d4b4fe3c65ad752b97c59acc947380ad996280))
|
|
11
|
+
|
|
5
12
|
### [0.1.16](https://github.com/spaced-out/ui-design-system/compare/v0.1.15...v0.1.16) (2023-04-19)
|
|
6
13
|
|
|
7
14
|
|
package/CONTRIBUTING.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
# Contribution Guidelines
|
|
4
4
|
|
|
5
|
+
- [Intro](#intro)
|
|
6
|
+
- [Development](#development)
|
|
7
|
+
- [Environment Setup](#environment-setup)
|
|
8
|
+
- [Generating New Component](#generating-new-component)
|
|
9
|
+
- [Generating New Hook](#generating-new-hook)
|
|
10
|
+
- [Exports](#exports)
|
|
11
|
+
- [Imports](#imports)
|
|
12
|
+
- [Adding Stories](#adding-stories)
|
|
13
|
+
- [Using Design Tokens](#using-design-tokens)
|
|
14
|
+
- [Testing Genesis Design System Locally](#testing-genesis-design-system-locally)
|
|
15
|
+
- [Troubleshooting local development](#troubleshooting-local-development)
|
|
16
|
+
- [Commits](#commits)
|
|
17
|
+
- [Add yourself to the contributor list ✨](#add-yourself-to-the-contributor-list)
|
|
18
|
+
|
|
19
|
+
## Intro
|
|
20
|
+
|
|
5
21
|
Genesis Design System is created using:
|
|
6
22
|
|
|
7
23
|
- [Gulp](https://gulpjs.com/)
|
|
@@ -16,7 +32,7 @@ It also features:
|
|
|
16
32
|
|
|
17
33
|
## Development
|
|
18
34
|
|
|
19
|
-
|
|
35
|
+
Follow the below mentioned steps to setup a dev environment locally:
|
|
20
36
|
|
|
21
37
|
### Environment Setup
|
|
22
38
|
|
|
@@ -43,10 +59,10 @@ yarn storybook
|
|
|
43
59
|
|
|
44
60
|
> The `storybook` server runs on port **6006** and url is opened automatically on successful dev build.
|
|
45
61
|
|
|
46
|
-
### Generating New
|
|
62
|
+
### Generating New Component
|
|
47
63
|
|
|
48
64
|
We've included a handy NodeJS util file under `scripts` called `create-component.js`. Instead of copy pasting components to create a new component,
|
|
49
|
-
you can instead run this command to generate all the files you need to start building out a new component. To use it:
|
|
65
|
+
you can instead run this command to generate all the files you need to start building out a new component. This also has a story boilerplate to help you kickstart component dev testing. To use it:
|
|
50
66
|
|
|
51
67
|
```bash
|
|
52
68
|
yarn generate YourComponentName
|
|
@@ -62,13 +78,39 @@ yarn generate YourComponentName
|
|
|
62
78
|
YourComponentName.stories.jsx
|
|
63
79
|
YourComponentName.module.css
|
|
64
80
|
YourComponentName.stories.module.css
|
|
81
|
+
index.js
|
|
65
82
|
```
|
|
66
83
|
|
|
67
84
|
> The default templates for each file can be modified under `scripts/templates`.
|
|
68
85
|
|
|
86
|
+
> This script also appends YourComponentName exports in **`src/components/index.js`**.
|
|
87
|
+
|
|
88
|
+
> After component creation your component story would be visible at `/?path=/docs/components-yourcomponentname`.
|
|
89
|
+
|
|
90
|
+
### Generating New Hook
|
|
91
|
+
|
|
92
|
+
There is also a handy NodeJS util file under `scripts` called `create-hook.js`. This generates a new hook that you need and appends exports in the `index.js`. To use it:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
yarn generateHook yourHook
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
> This will generate:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
/src
|
|
102
|
+
/hooks
|
|
103
|
+
yourHook.js
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
> This script also appends YourComponentName exports in **`src/hooks/index.js`**.
|
|
107
|
+
|
|
69
108
|
### Exports
|
|
70
109
|
|
|
71
|
-
|
|
110
|
+
Each component folder should have an index.js which exports all required component(s) | types.
|
|
111
|
+
Export hook | style | util | type as named export and add these exports to the index.js of respective folder root.
|
|
112
|
+
|
|
113
|
+
**Note:** Make sure you have all your exports listed in `src/index.js`. Consumers use this as an entry point to do all imports.
|
|
72
114
|
|
|
73
115
|
### Imports
|
|
74
116
|
|
|
@@ -126,6 +168,10 @@ For every change in `ui_design_system` that you want to propagate to `consumer`
|
|
|
126
168
|
yarn upgrade @spaced-out/ui-design-system@file:../../ui-design-system
|
|
127
169
|
```
|
|
128
170
|
|
|
171
|
+
## Troubleshooting local development
|
|
172
|
+
|
|
173
|
+
- Because we are using react hooks and having react as a peerDependency - if you want to develop locally and encounter issues with "invalid hook call" [See this github thread](https://github.com/facebook/react/issues/13991). The quick fix is in your webpack config file alias react to resolve the node_modules path
|
|
174
|
+
|
|
129
175
|
## Commits
|
|
130
176
|
|
|
131
177
|
Each commit should follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) guidelines
|
|
@@ -144,9 +190,9 @@ Most commonly used commit prefixes:
|
|
|
144
190
|
|
|
145
191
|
> `build:` Commits, that affect build components like build tool, ci pipeline, dependencies, project version, etc.
|
|
146
192
|
|
|
147
|
-
## Add yourself to the
|
|
193
|
+
## Add yourself to the contributor list
|
|
148
194
|
|
|
149
|
-
To add yourself to the `
|
|
195
|
+
To add yourself to the `contributors` table in the README and INTRODUCTION stories:
|
|
150
196
|
|
|
151
197
|
> Run the following commands from the root of the repo:
|
|
152
198
|
|
package/README.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
# Genesis Design System
|
|
4
4
|
|
|
5
|
+
- [Intro](#intro)
|
|
6
|
+
- [Usage](#usage)
|
|
7
|
+
- [Installation](#installation)
|
|
8
|
+
- [Component Usage](#component-usage)
|
|
9
|
+
- [Using Components](#using-components)
|
|
10
|
+
- [Setting Up Component Aliases](#setting-up-component-aliases)
|
|
11
|
+
- [Setting Up Fonts](#setting-up-fonts)
|
|
12
|
+
- [Using Genesis Design Tokens](#using-genesis-design-tokens)
|
|
13
|
+
- [CSS Tokens](#css-tokens)
|
|
14
|
+
- [JS Tokens](#js-tokens)
|
|
15
|
+
- [Setting Up Design Token Aliases](#setting-up-design-token-aliases)
|
|
16
|
+
- [Documentation](#documentation)
|
|
17
|
+
- [Contributions](#contributions)
|
|
18
|
+
- [Changelog](#changelog)
|
|
19
|
+
- [Contributors ✨](#contributors)
|
|
20
|
+
|
|
21
|
+
## Intro
|
|
22
|
+
|
|
5
23
|
Genesis design system consists of a set of tools and protocols that unify design and development across surfaces (platforms) to deliver consistent
|
|
6
24
|
user experiences. The system utilizes workflow automation to streamline the design and development process. It's comprised of a number of React
|
|
7
25
|
web components that each play a unique role within the product development cycle.
|
|
@@ -11,6 +29,10 @@ development lifecycle.
|
|
|
11
29
|
|
|
12
30
|
## Usage
|
|
13
31
|
|
|
32
|
+
Follow the below mentioned guide for installation and usage instructions
|
|
33
|
+
|
|
34
|
+
### Installation
|
|
35
|
+
|
|
14
36
|
To install `@spaced-out/ui-design-system` in your project, you will need to run the
|
|
15
37
|
following command using [yarn](https://yarnpkg.com/):
|
|
16
38
|
|
|
@@ -18,25 +40,75 @@ following command using [yarn](https://yarnpkg.com/):
|
|
|
18
40
|
yarn add @spaced-out/ui-design-system
|
|
19
41
|
```
|
|
20
42
|
|
|
43
|
+
### Component Usage
|
|
44
|
+
|
|
21
45
|
Usage of the component (after the library installed as a dependency in project) will be:
|
|
22
46
|
|
|
47
|
+
#### Using Components
|
|
48
|
+
|
|
23
49
|
```js
|
|
24
50
|
import React from 'react';
|
|
51
|
+
|
|
52
|
+
// There are multiple ways of importing a component
|
|
53
|
+
|
|
25
54
|
import {Button} from '@spaced-out/ui-design-system/lib/components/Button';
|
|
26
55
|
|
|
56
|
+
/** We also export all components | hooks | styles | utils | types from a common
|
|
57
|
+
* index file located at @spaced-out/ui-design-system/lib.
|
|
58
|
+
*
|
|
59
|
+
* For multiple imports this can be used
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
import {
|
|
63
|
+
Button,
|
|
64
|
+
BodyMedium,
|
|
65
|
+
TEXT_COLORS,
|
|
66
|
+
Toast,
|
|
67
|
+
Dropdown,
|
|
68
|
+
} from '@spaced-out/ui-design-system/lib';
|
|
69
|
+
|
|
27
70
|
const App = () => (
|
|
28
|
-
<div className=
|
|
71
|
+
<div className={css.container}>
|
|
29
72
|
<Button>Hello world</Button>
|
|
73
|
+
<BodyMedium color={TEXT_COLORS.neutral}>Some text</BodyMedium>
|
|
30
74
|
</div>
|
|
31
75
|
);
|
|
32
76
|
|
|
33
77
|
export default App;
|
|
34
78
|
```
|
|
35
79
|
|
|
80
|
+
#### Setting Up Component Aliases
|
|
81
|
+
|
|
82
|
+
You can also set up aliases in your build tool to further simplify imports if you want.
|
|
83
|
+
eg. This webpack config set up an alias for `@spaced-out/ui-design-system/lib` to `ui-design-system`
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
const {MODE, DEVELOPMENT, RESOLVE_MODULES_DIRS} = require('./constants');
|
|
87
|
+
|
|
88
|
+
exports.default = {
|
|
89
|
+
mode: MODE,
|
|
90
|
+
|
|
91
|
+
devtool: DEVELOPMENT ? 'eval-cheap-module-source-map' : 'source-map',
|
|
92
|
+
|
|
93
|
+
resolve: {
|
|
94
|
+
symlinks: false,
|
|
95
|
+
modules: RESOLVE_MODULES_DIRS,
|
|
96
|
+
alias: {
|
|
97
|
+
common: 'src/styles/common.css',
|
|
98
|
+
designSystem2021: 'src/styles/design-system-2021.css',
|
|
99
|
+
sentry: '@sentry/browser',
|
|
100
|
+
'react-router': '@spaced-out/react-router',
|
|
101
|
+
sculpt: '@spaced-out/sculpt',
|
|
102
|
+
'ui-design-system': '@spaced-out/ui-design-system/lib',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
```
|
|
107
|
+
|
|
36
108
|
For more information about each component, check out
|
|
37
109
|
[Storybook](https://spaced-out.github.io/ui-design-system).
|
|
38
110
|
|
|
39
|
-
|
|
111
|
+
#### Setting Up Fonts
|
|
40
112
|
|
|
41
113
|
By default Genesis uses `'Centra No 2'` font. To add this font in your project you need to load this font. The recommended way to do it is by adding the following in your global css.
|
|
42
114
|
|
|
@@ -72,25 +144,89 @@ By default Genesis uses `'Centra No 2'` font. To add this font in your project y
|
|
|
72
144
|
}
|
|
73
145
|
```
|
|
74
146
|
|
|
75
|
-
|
|
147
|
+
#### Using Genesis Design Tokens
|
|
76
148
|
|
|
77
149
|
Design tokens are exported as `.css` and `.js`. You can consume them easily by
|
|
78
150
|
|
|
151
|
+
##### CSS Tokens
|
|
152
|
+
|
|
79
153
|
CSS use:
|
|
80
154
|
|
|
81
|
-
```
|
|
155
|
+
```css
|
|
82
156
|
@value (size2) from '@spaced-out/ui-design-system/lib/styles/variables/_size.css';
|
|
83
157
|
|
|
158
|
+
/* We also export all style variable(design tokens) and common classes from a common index
|
|
159
|
+
file located at @spaced-out/ui-design-system/lib/styles/index.css */
|
|
160
|
+
|
|
161
|
+
/* For @value from Multiple css files use this */
|
|
162
|
+
|
|
163
|
+
@value (
|
|
164
|
+
colorFillPrimary,
|
|
165
|
+
colorTextSecondary,
|
|
166
|
+
colorTextDisabled,
|
|
167
|
+
spaceXXSmall,
|
|
168
|
+
spaceNone,
|
|
169
|
+
spaceSmall,
|
|
170
|
+
spaceXSmall,
|
|
171
|
+
size34,
|
|
172
|
+
sizeFluid,
|
|
173
|
+
size40
|
|
174
|
+
) from '@spaced-out/ui-design-system/lib/styles/index.css';
|
|
175
|
+
|
|
84
176
|
.example-container {
|
|
85
|
-
|
|
177
|
+
height: size2;
|
|
178
|
+
composes: motionEaseInEaseOut from '@spaced-out/ui-design-system/lib/styles/index.css';
|
|
86
179
|
}
|
|
87
180
|
```
|
|
88
181
|
|
|
182
|
+
##### JS Tokens
|
|
183
|
+
|
|
89
184
|
JS use:
|
|
90
185
|
|
|
91
186
|
```js
|
|
92
|
-
import {size2} from
|
|
93
|
-
|
|
187
|
+
import {size2} from '@spaced-out/ui-design-system/lib/styles/variables/_size.js';
|
|
188
|
+
|
|
189
|
+
/* We also export all style variable(design tokens) from a common index
|
|
190
|
+
file located at @spaced-out/ui-design-system/lib */
|
|
191
|
+
|
|
192
|
+
/* For multiple design token impoets use this */
|
|
193
|
+
|
|
194
|
+
import {
|
|
195
|
+
sizeFluid,
|
|
196
|
+
size2,
|
|
197
|
+
spaceNone,
|
|
198
|
+
colorTextNeutral,
|
|
199
|
+
borderRadiusSmall,
|
|
200
|
+
} from '@spaced-out/ui-design-system/lib';
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### Setting Up Design Token Aliases
|
|
204
|
+
|
|
205
|
+
You can also set up aliases in your build tool to further simplify imports if you want.
|
|
206
|
+
eg. This webpack config set up an alias for `@spaced-out/ui-design-system/lib/styles/index.css` to `uiDesignSystem`
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
const {MODE, DEVELOPMENT, RESOLVE_MODULES_DIRS} = require('./constants');
|
|
210
|
+
|
|
211
|
+
exports.default = {
|
|
212
|
+
mode: MODE,
|
|
213
|
+
|
|
214
|
+
devtool: DEVELOPMENT ? 'eval-cheap-module-source-map' : 'source-map',
|
|
215
|
+
|
|
216
|
+
resolve: {
|
|
217
|
+
symlinks: false,
|
|
218
|
+
modules: RESOLVE_MODULES_DIRS,
|
|
219
|
+
alias: {
|
|
220
|
+
common: 'src/styles/common.css',
|
|
221
|
+
designSystem2021: 'src/styles/design-system-2021.css',
|
|
222
|
+
uiDesignSystem: '@spaced-out/ui-design-system/lib/styles/index.css',
|
|
223
|
+
sentry: '@sentry/browser',
|
|
224
|
+
'react-router': '@spaced-out/react-router',
|
|
225
|
+
sculpt: '@spaced-out/sculpt',
|
|
226
|
+
'ui-design-system': '@spaced-out/ui-design-system/lib',
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
};
|
|
94
230
|
```
|
|
95
231
|
|
|
96
232
|
## Documentation
|
|
@@ -105,7 +241,7 @@ Check out our [**Contribution Guide**](https://spaced-out.github.io/ui-design-sy
|
|
|
105
241
|
|
|
106
242
|
Check out our [**Changelog here**](https://spaced-out.github.io/ui-design-system/?path=/docs/changelog--page)
|
|
107
243
|
|
|
108
|
-
##
|
|
244
|
+
## Contributors
|
|
109
245
|
|
|
110
246
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
111
247
|
<!-- prettier-ignore-start -->
|
package/gulpfile.js
CHANGED
|
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
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; }
|
|
17
17
|
|
|
18
18
|
const COLOR_SEQUENCE = ['blue', 'green', 'orange', 'red', 'gray'];
|
|
19
|
-
const AvatarGroup = _ref => {
|
|
19
|
+
const AvatarGroup = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
20
20
|
let {
|
|
21
21
|
children,
|
|
22
22
|
size = 'medium',
|
|
@@ -116,7 +116,8 @@ const AvatarGroup = _ref => {
|
|
|
116
116
|
[_AvatarGroupModule.default.largeSize]: size === 'large',
|
|
117
117
|
[_AvatarGroupModule.default.mediumSize]: size === 'medium',
|
|
118
118
|
[_AvatarGroupModule.default.smallSize]: size === 'small'
|
|
119
|
-
})
|
|
119
|
+
}),
|
|
120
|
+
ref: ref
|
|
120
121
|
}, childrenWithProps);
|
|
121
|
-
};
|
|
122
|
+
});
|
|
122
123
|
exports.AvatarGroup = AvatarGroup;
|
|
@@ -29,118 +29,127 @@ export type AvatarGroupProps = {
|
|
|
29
29
|
tooltipElevation?: string,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
export const AvatarGroup
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
32
|
+
export const AvatarGroup: React$AbstractComponent<
|
|
33
|
+
AvatarGroupProps,
|
|
34
|
+
HTMLDivElement,
|
|
35
|
+
> = React.forwardRef<AvatarGroupProps, HTMLDivElement>(
|
|
36
|
+
(
|
|
37
|
+
{
|
|
38
|
+
children,
|
|
39
|
+
size = 'medium',
|
|
40
|
+
borderColor = colorBackgroundTertiary,
|
|
41
|
+
maxTooltipLines = 7,
|
|
42
|
+
placement = 'top',
|
|
43
|
+
maxAvatars = 5,
|
|
44
|
+
tooltipElevation,
|
|
45
|
+
}: AvatarGroupProps,
|
|
46
|
+
ref,
|
|
47
|
+
): React.Node => {
|
|
48
|
+
const childAvatarCount = React.Children.count(children);
|
|
49
|
+
|
|
50
|
+
const leftOverlap = {
|
|
51
|
+
small: spaceXXSmall,
|
|
52
|
+
medium: `${parseInt(spaceSmall) / 2}px`,
|
|
53
|
+
large: spaceXSmall,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
let colorIndex = -1;
|
|
57
|
+
|
|
58
|
+
const avatarInGroup = (child, index, color) => {
|
|
59
|
+
const {classNames} = child.props;
|
|
60
|
+
const {wrapper, ...restClassNames} = classNames || {};
|
|
61
|
+
return React.cloneElement(child, {
|
|
62
|
+
size,
|
|
63
|
+
classNames: {
|
|
64
|
+
wrapper: classify(css.avatarInGroup, wrapper),
|
|
65
|
+
...restClassNames,
|
|
66
|
+
},
|
|
67
|
+
style: {
|
|
68
|
+
borderColor,
|
|
69
|
+
marginLeft: `-${index !== 0 ? leftOverlap[size] : 0}`,
|
|
70
|
+
},
|
|
71
|
+
color,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const childrenArray = React.Children.toArray(children);
|
|
76
|
+
const totalAvatarCount = childrenArray.length;
|
|
77
|
+
const plusAvatar = () => {
|
|
78
|
+
const nameList = [];
|
|
79
|
+
|
|
80
|
+
for (let i = maxAvatars - 1; i < totalAvatarCount; i++) {
|
|
81
|
+
const child = childrenArray[i];
|
|
82
|
+
const {text} = child.props;
|
|
83
|
+
if (text) {
|
|
84
|
+
nameList.push(text);
|
|
85
|
+
}
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
</
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
87
|
+
|
|
88
|
+
const NameListNode = () => (
|
|
89
|
+
<span>
|
|
90
|
+
{nameList.map((name) => (
|
|
91
|
+
<React.Fragment key={name}>
|
|
92
|
+
{name}
|
|
93
|
+
<br />
|
|
94
|
+
</React.Fragment>
|
|
95
|
+
))}
|
|
96
|
+
</span>
|
|
97
|
+
);
|
|
98
|
+
return (
|
|
99
|
+
<Tooltip
|
|
100
|
+
body={<NameListNode />}
|
|
101
|
+
bodyMaxLines={maxTooltipLines}
|
|
102
|
+
placement={placement}
|
|
103
|
+
elevation={tooltipElevation}
|
|
104
|
+
>
|
|
105
|
+
<div className={css.plusAvatar}>
|
|
106
|
+
<BaseAvatar
|
|
107
|
+
size={size}
|
|
108
|
+
color="gray"
|
|
109
|
+
text={`+${childAvatarCount - maxAvatars + 1}`}
|
|
110
|
+
classNames={{wrapper: css.avatarInGroup}}
|
|
111
|
+
style={{
|
|
112
|
+
borderColor,
|
|
113
|
+
marginLeft: `-${leftOverlap[size]}`,
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
</div>
|
|
117
|
+
</Tooltip>
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const childrenWithProps = React.Children.map(children, (child, index) => {
|
|
122
|
+
const {imageSrc} = child.props;
|
|
123
|
+
if (!imageSrc) {
|
|
124
|
+
colorIndex++;
|
|
125
|
+
if (colorIndex === COLOR_SEQUENCE.length) {
|
|
126
|
+
colorIndex = 0;
|
|
127
|
+
}
|
|
120
128
|
}
|
|
121
|
-
}
|
|
122
129
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return avatarInGroup(child, index, color);
|
|
126
|
-
} else {
|
|
127
|
-
if (index < maxAvatars - 1) {
|
|
130
|
+
const color = COLOR_SEQUENCE[colorIndex];
|
|
131
|
+
if (childAvatarCount <= maxAvatars) {
|
|
128
132
|
return avatarInGroup(child, index, color);
|
|
129
|
-
} else
|
|
130
|
-
|
|
133
|
+
} else {
|
|
134
|
+
if (index < maxAvatars - 1) {
|
|
135
|
+
return avatarInGroup(child, index, color);
|
|
136
|
+
} else if (index === maxAvatars) {
|
|
137
|
+
return plusAvatar();
|
|
138
|
+
}
|
|
131
139
|
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div
|
|
144
|
+
className={classify(css.avatarGroupContainer, {
|
|
145
|
+
[css.largeSize]: size === 'large',
|
|
146
|
+
[css.mediumSize]: size === 'medium',
|
|
147
|
+
[css.smallSize]: size === 'small',
|
|
148
|
+
})}
|
|
149
|
+
ref={ref}
|
|
150
|
+
>
|
|
151
|
+
{childrenWithProps}
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
);
|
|
@@ -22,7 +22,7 @@ const BADGE_COLOR = Object.freeze({
|
|
|
22
22
|
indigo: _color.colorNeutralLightest
|
|
23
23
|
});
|
|
24
24
|
exports.BADGE_COLOR = BADGE_COLOR;
|
|
25
|
-
const Badge = _ref => {
|
|
25
|
+
const Badge = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
26
26
|
let {
|
|
27
27
|
classNames,
|
|
28
28
|
text,
|
|
@@ -35,7 +35,8 @@ const Badge = _ref => {
|
|
|
35
35
|
}, classNames?.wrapper),
|
|
36
36
|
style: {
|
|
37
37
|
backgroundColor: BADGE_COLOR[fill]
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
|
+
ref: ref
|
|
39
40
|
}, /*#__PURE__*/React.createElement(_Text.ButtonTextSmall, null, text));
|
|
40
|
-
};
|
|
41
|
+
});
|
|
41
42
|
exports.Badge = Badge;
|