@react-ui-org/react-ui 0.56.0 → 0.58.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.nvmrc +1 -1
- package/dist/react-ui.css +17 -17
- package/dist/react-ui.development.css +2551 -831
- package/dist/react-ui.development.js +106 -66
- package/dist/react-ui.js +1 -1
- package/package.json +13 -2
- package/src/CNAME +1 -0
- package/src/components/Alert/Alert.jsx +5 -6
- package/src/components/Alert/Alert.module.scss +12 -34
- package/src/components/Alert/README.md +28 -15
- package/src/components/Alert/_settings.scss +5 -0
- package/src/components/Alert/_theme.scss +0 -43
- package/src/components/Badge/Badge.jsx +5 -3
- package/src/components/Badge/Badge.module.scss +29 -74
- package/src/components/Badge/README.md +19 -2
- package/src/components/Badge/_settings.scss +8 -0
- package/src/components/Button/Button.jsx +4 -3
- package/src/components/Button/Button.module.scss +183 -2
- package/src/components/Button/README.md +8 -6
- package/src/components/Button/_settings.scss +8 -3
- package/src/components/Button/_theme.scss +0 -3
- package/src/components/Button/_tools.scss +7 -71
- package/src/components/ButtonGroup/ButtonGroup.jsx +2 -2
- package/src/components/Card/Card.jsx +3 -2
- package/src/components/Card/Card.module.scss +13 -33
- package/src/components/Card/CardBody.jsx +1 -1
- package/src/components/Card/CardFooter.jsx +1 -1
- package/src/components/Card/README.md +28 -6
- package/src/components/Card/_settings.scss +5 -0
- package/src/components/Card/_theme.scss +0 -43
- package/src/components/CheckboxField/CheckboxField.jsx +9 -3
- package/src/components/CheckboxField/README.md +110 -5
- package/src/components/FileInputField/FileInputField.jsx +1 -1
- package/src/components/FormLayout/FormLayout.jsx +1 -1
- package/src/components/FormLayout/FormLayoutCustomField.jsx +1 -1
- package/src/components/Grid/Grid.jsx +1 -1
- package/src/components/Grid/Grid.module.scss +9 -2
- package/src/components/Grid/GridSpan.jsx +1 -1
- package/src/components/InputGroup/InputGroup.jsx +2 -2
- package/src/components/InputGroup/InputGroup.module.scss +9 -5
- package/src/components/Modal/Modal.jsx +1 -1
- package/src/components/Modal/ModalBody.jsx +1 -1
- package/src/components/Modal/ModalCloseButton.jsx +3 -5
- package/src/components/Modal/ModalContent.jsx +1 -1
- package/src/components/Modal/ModalFooter.jsx +1 -1
- package/src/components/Modal/ModalHeader.jsx +1 -1
- package/src/components/Modal/ModalTitle.jsx +1 -1
- package/src/components/Modal/README.md +18 -18
- package/src/components/Paper/Paper.jsx +1 -1
- package/src/components/Popover/Popover.jsx +58 -13
- package/src/components/Popover/Popover.module.scss +51 -23
- package/src/components/Popover/PopoverWrapper.jsx +1 -1
- package/src/components/Popover/README.md +60 -3
- package/src/components/Popover/_helpers/cleanPlacementStyle.js +20 -0
- package/src/components/Popover/_theme.scss +4 -2
- package/src/components/Radio/README.md +103 -0
- package/src/components/Radio/Radio.jsx +9 -3
- package/src/components/Radio/Radio.module.scss +4 -0
- package/src/components/ScrollView/ScrollView.jsx +3 -5
- package/src/components/SelectField/README.md +103 -0
- package/src/components/SelectField/SelectField.jsx +9 -3
- package/src/components/Table/Table.jsx +1 -1
- package/src/components/Tabs/Tabs.jsx +1 -1
- package/src/components/Tabs/TabsItem.jsx +1 -1
- package/src/components/Text/Text.jsx +1 -1
- package/src/components/TextArea/TextArea.jsx +1 -1
- package/src/components/TextField/README.md +14 -2
- package/src/components/TextField/TextField.jsx +1 -1
- package/src/components/TextLink/README.md +10 -3
- package/src/components/TextLink/TextLink.jsx +1 -1
- package/src/components/TextLink/_theme.scss +3 -3
- package/src/components/Toggle/README.md +83 -1
- package/src/components/Toggle/Toggle.jsx +9 -3
- package/src/components/Toolbar/Toolbar.jsx +1 -1
- package/src/components/Toolbar/ToolbarGroup.jsx +1 -1
- package/src/components/Toolbar/ToolbarItem.jsx +1 -1
- package/src/components/_helpers/getRootPriorityClassName.js +1 -1
- package/src/components/_helpers/resolveContextOrProp.js +6 -3
- package/src/index.js +3 -2
- package/src/providers/globalProps/GlobalPropsContext.jsx +5 -0
- package/src/providers/globalProps/GlobalPropsProvider.jsx +33 -0
- package/src/providers/globalProps/index.js +3 -0
- package/src/{provider → providers/globalProps}/withGlobalProps.jsx +16 -16
- package/src/providers/translations/TranslationsContext.jsx +6 -0
- package/src/providers/translations/TranslationsProvider.jsx +33 -0
- package/src/providers/translations/index.js +2 -0
- package/src/styles/elements/_links.scss +7 -2
- package/src/styles/settings/_collections.scss +9 -0
- package/src/styles/theme/_form-fields.scss +19 -0
- package/src/styles/theme/_links.scss +4 -3
- package/src/styles/tools/_collections.scss +265 -0
- package/src/styles/tools/_string.scss +5 -2
- package/src/styles/tools/form-fields/_box-field-layout.scss +7 -1
- package/src/styles/tools/form-fields/_foundation.scss +6 -4
- package/src/styles/tools/form-fields/_variants.scss +5 -1
- package/src/theme.scss +66 -1
- package/src/components/Alert/_tools.scss +0 -10
- package/src/components/Button/_base.scss +0 -156
- package/src/components/Button/_priorities.scss +0 -149
- package/src/components/Card/_tools.scss +0 -10
- package/src/provider/RUIContext.jsx +0 -9
- package/src/provider/RUIProvider.jsx +0 -42
- package/src/provider/index.js +0 -3
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-ui-org/react-ui",
|
3
3
|
"description": "React UI is a themeable UI library for React apps.",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.58.0",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
7
7
|
"ui",
|
@@ -31,6 +31,17 @@
|
|
31
31
|
"engines": {
|
32
32
|
"node": ">=20"
|
33
33
|
},
|
34
|
+
"devEngines": {
|
35
|
+
"runtime": {
|
36
|
+
"name": "node",
|
37
|
+
"version": "22.x",
|
38
|
+
"onFail": "error"
|
39
|
+
},
|
40
|
+
"packageManager": {
|
41
|
+
"name": "npm",
|
42
|
+
"onFail": "error"
|
43
|
+
}
|
44
|
+
},
|
34
45
|
"scripts": {
|
35
46
|
"build": "webpack --mode=production && webpack --mode=development",
|
36
47
|
"copy": "npm run copy:css && npm run copy:js",
|
@@ -71,7 +82,7 @@
|
|
71
82
|
"@testing-library/react": "^16.0.0",
|
72
83
|
"@testing-library/user-event": "^14.5.2",
|
73
84
|
"@visionappscz/eslint-config-visionapps": "^1.7.0",
|
74
|
-
"@visionappscz/stylelint-config": "^4.0.0
|
85
|
+
"@visionappscz/stylelint-config": "^4.0.0",
|
75
86
|
"autoprefixer": "^10.4.19",
|
76
87
|
"babel-jest": "^29.7.0",
|
77
88
|
"babel-loader": "^9.1.3",
|
package/src/CNAME
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
react-ui.io
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import {
|
4
|
-
|
5
|
-
withGlobalProps,
|
6
|
-
} from '../../provider';
|
3
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
4
|
+
import { TranslationsContext } from '../../providers/translations';
|
7
5
|
import { classNames } from '../../utils/classNames';
|
8
6
|
import { transferProps } from '../../utils/transferProps';
|
9
7
|
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
|
@@ -17,7 +15,7 @@ export const Alert = ({
|
|
17
15
|
onClose,
|
18
16
|
...restProps
|
19
17
|
}) => {
|
20
|
-
const
|
18
|
+
const translations = useContext(TranslationsContext);
|
21
19
|
|
22
20
|
return (
|
23
21
|
<div
|
@@ -70,7 +68,8 @@ Alert.propTypes = {
|
|
70
68
|
*/
|
71
69
|
children: PropTypes.node.isRequired,
|
72
70
|
/**
|
73
|
-
*
|
71
|
+
* Color variant to clarify importance and meaning of the alert. Implements
|
72
|
+
* [Feedback and Neutral color collections](/docs/foundation/collections#colors).
|
74
73
|
*/
|
75
74
|
color: PropTypes.oneOf(['success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark']),
|
76
75
|
/**
|
@@ -1,10 +1,10 @@
|
|
1
1
|
@use "sass:map";
|
2
2
|
@use "../../styles/theme/typography";
|
3
3
|
@use "../../styles/tools/accessibility";
|
4
|
+
@use "../../styles/tools/collections";
|
4
5
|
@use "../../styles/tools/reset";
|
5
6
|
@use "settings";
|
6
7
|
@use "theme";
|
7
|
-
@use "tools";
|
8
8
|
|
9
9
|
@layer components.alert {
|
10
10
|
.root {
|
@@ -25,8 +25,8 @@
|
|
25
25
|
padding: theme.$padding;
|
26
26
|
}
|
27
27
|
|
28
|
-
.
|
29
|
-
.
|
28
|
+
.icon,
|
29
|
+
.close {
|
30
30
|
height: settings.$min-height;
|
31
31
|
color: var(--rui-local-foreground-color);
|
32
32
|
}
|
@@ -46,7 +46,6 @@
|
|
46
46
|
line-height: settings.$line-height;
|
47
47
|
}
|
48
48
|
|
49
|
-
.message a,
|
50
49
|
.message strong {
|
51
50
|
font-weight: theme.$emphasis-font-weight;
|
52
51
|
color: var(--rui-local-foreground-color);
|
@@ -66,35 +65,14 @@
|
|
66
65
|
top: -0.1em;
|
67
66
|
}
|
68
67
|
|
69
|
-
|
70
|
-
@include
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
@include tools.color(danger);
|
79
|
-
}
|
80
|
-
|
81
|
-
.isRootColorHelp {
|
82
|
-
@include tools.color(help);
|
83
|
-
}
|
84
|
-
|
85
|
-
.isRootColorInfo {
|
86
|
-
@include tools.color(info);
|
87
|
-
}
|
88
|
-
|
89
|
-
.isRootColorNote {
|
90
|
-
@include tools.color(note);
|
91
|
-
}
|
92
|
-
|
93
|
-
.isRootColorLight {
|
94
|
-
@include tools.color(light);
|
95
|
-
}
|
96
|
-
|
97
|
-
.isRootColorDark {
|
98
|
-
@include tools.color(dark);
|
68
|
+
@each $color in settings.$colors {
|
69
|
+
@include collections.generate-class(
|
70
|
+
$prefix: "rui-",
|
71
|
+
$component-name: "Alert",
|
72
|
+
$variant-name: "color",
|
73
|
+
$variant-value: $color,
|
74
|
+
$properties: settings.$themeable-properties,
|
75
|
+
$inherit-link-color: true,
|
76
|
+
);
|
99
77
|
}
|
100
78
|
}
|
@@ -31,8 +31,8 @@ See [API](#api) for all available options.
|
|
31
31
|
|
32
32
|
## Color Variants
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
To cover all possible needs of your project, Alert is available in colors from
|
35
|
+
[Feedback and Neutral color collections](/docs/foundation/collections#colors).
|
36
36
|
|
37
37
|
### Success
|
38
38
|
|
@@ -41,6 +41,8 @@ Success alerts confirm that an operation has been processed successfully.
|
|
41
41
|
```docoff-react-preview
|
42
42
|
<Alert color="success">
|
43
43
|
<strong>Success:</strong> Settings have been successfully saved.
|
44
|
+
{' '}
|
45
|
+
<TextLink href="/" label="Undo" />
|
44
46
|
</Alert>
|
45
47
|
```
|
46
48
|
|
@@ -53,7 +55,7 @@ suggest an action to resolve the problem.
|
|
53
55
|
<Alert color="warning">
|
54
56
|
<strong>Warning:</strong> Your credit card is going to expire soon.
|
55
57
|
{' '}
|
56
|
-
<
|
58
|
+
<TextLink href="/" label="Update my payment options" />
|
57
59
|
</Alert>
|
58
60
|
```
|
59
61
|
|
@@ -68,7 +70,7 @@ problem.
|
|
68
70
|
<strong>Error:</strong> Cannot connect to the server. Is your internet
|
69
71
|
connection working fine?
|
70
72
|
{' '}
|
71
|
-
<
|
73
|
+
<TextLink href="/" label="Try again" />
|
72
74
|
</Alert>
|
73
75
|
```
|
74
76
|
|
@@ -80,6 +82,8 @@ This kind of alert can be used to display helpful information.
|
|
80
82
|
<Alert color="help">
|
81
83
|
<strong>Help:</strong> You should choose a password you don't use
|
82
84
|
anywhere else.
|
85
|
+
{' '}
|
86
|
+
<TextLink href="/" label="Help me choose" />
|
83
87
|
</Alert>
|
84
88
|
```
|
85
89
|
|
@@ -90,6 +94,8 @@ Another common, informative alert.
|
|
90
94
|
```docoff-react-preview
|
91
95
|
<Alert color="info">
|
92
96
|
<strong>Info:</strong> This feature depends on user's OS preferences.
|
97
|
+
{' '}
|
98
|
+
<TextLink href="/" label="Open preferences" />
|
93
99
|
</Alert>
|
94
100
|
```
|
95
101
|
|
@@ -100,6 +106,8 @@ Neutral informative alert.
|
|
100
106
|
```docoff-react-preview
|
101
107
|
<Alert>
|
102
108
|
<strong>Note:</strong> This feature may not be available in all regions.
|
109
|
+
{' '}
|
110
|
+
<TextLink href="/" label="Show list of regions" />
|
103
111
|
</Alert>
|
104
112
|
```
|
105
113
|
|
@@ -111,6 +119,8 @@ Light alert variant.
|
|
111
119
|
<docoff-placeholder dark>
|
112
120
|
<Alert color="light">
|
113
121
|
<strong>Light alert:</strong> Stands out on dark backgrounds.
|
122
|
+
{' '}
|
123
|
+
<TextLink href="/" label="This is a link" />
|
114
124
|
</Alert>
|
115
125
|
</docoff-placeholder>
|
116
126
|
```
|
@@ -122,6 +132,8 @@ Dark alert variant.
|
|
122
132
|
```docoff-react-preview
|
123
133
|
<Alert color="dark">
|
124
134
|
<strong>Dark alert:</strong> Stands out on light backgrounds.
|
135
|
+
{' '}
|
136
|
+
<TextLink href="/" label="This is a link" />
|
125
137
|
</Alert>
|
126
138
|
```
|
127
139
|
|
@@ -190,14 +202,14 @@ helps to improve its accessibility.
|
|
190
202
|
|
191
203
|
### Common Theming Options
|
192
204
|
|
193
|
-
| Custom Property
|
194
|
-
|
195
|
-
| `--rui-Alert__padding`
|
196
|
-
| `--rui-Alert__font-weight`
|
197
|
-
| `--rui-Alert__border-width`
|
198
|
-
| `--rui-Alert__border-radius`
|
199
|
-
| `--rui-Alert__emphasis__font-weight`
|
200
|
-
| `--rui-Alert__stripe__width`
|
205
|
+
| Custom Property | Description |
|
206
|
+
|--------------------------------------|------------------------------------------------|
|
207
|
+
| `--rui-Alert__padding` | Padding between border and message |
|
208
|
+
| `--rui-Alert__font-weight` | Message font weight |
|
209
|
+
| `--rui-Alert__border-width` | Border width |
|
210
|
+
| `--rui-Alert__border-radius` | Corner radius |
|
211
|
+
| `--rui-Alert__emphasis__font-weight` | Font weight of text emphasised with `<strong>` |
|
212
|
+
| `--rui-Alert__stripe__width` | Width of the border at the start of the Alert |
|
201
213
|
|
202
214
|
### Theming Variants
|
203
215
|
|
@@ -208,9 +220,10 @@ convention looks as follows:
|
|
208
220
|
|
209
221
|
Where:
|
210
222
|
|
211
|
-
- `<COLOR>` is
|
212
|
-
[
|
213
|
-
(
|
223
|
+
- `<COLOR>` is a value from supported
|
224
|
+
[color collections](/docs/foundation/collections#colors)
|
225
|
+
(check [color variants](#color-variants) and [API](#api) to see which
|
226
|
+
collections are supported),
|
214
227
|
- `<PROPERTY>` is one of `color` (color of text), `foreground-color` (color of
|
215
228
|
border, icon, links, and emphasis), or `background-color`.
|
216
229
|
|
@@ -1,7 +1,12 @@
|
|
1
|
+
@use "sass:list";
|
1
2
|
@use "sass:map";
|
3
|
+
@use "../../styles/settings/collections";
|
2
4
|
@use "../../styles/theme/typography";
|
3
5
|
@use "theme";
|
4
6
|
|
5
7
|
$font-size: map.get(typography.$font-size-values, 1);
|
6
8
|
$line-height: typography.$line-height-base;
|
7
9
|
$min-height: calc(#{$font-size} * #{$line-height} + 2 * #{theme.$padding});
|
10
|
+
|
11
|
+
$colors: list.join(collections.$feedback-colors, collections.$neutral-colors);
|
12
|
+
$themeable-properties: color, foreground-color, background-color;
|
@@ -4,46 +4,3 @@ $border-width: var(--rui-Alert__border-width);
|
|
4
4
|
$border-radius: var(--rui-Alert__border-radius);
|
5
5
|
$emphasis-font-weight: var(--rui-Alert__emphasis__font-weight);
|
6
6
|
$stripe-width: var(--rui-Alert__stripe__width);
|
7
|
-
|
8
|
-
$colors: (
|
9
|
-
success: (
|
10
|
-
color: var(--rui-Alert--success__color),
|
11
|
-
foreground-color: var(--rui-Alert--success__foreground-color),
|
12
|
-
background-color: var(--rui-Alert--success__background-color),
|
13
|
-
),
|
14
|
-
warning: (
|
15
|
-
color: var(--rui-Alert--warning__color),
|
16
|
-
foreground-color: var(--rui-Alert--warning__foreground-color),
|
17
|
-
background-color: var(--rui-Alert--warning__background-color),
|
18
|
-
),
|
19
|
-
danger: (
|
20
|
-
color: var(--rui-Alert--danger__color),
|
21
|
-
foreground-color: var(--rui-Alert--danger__foreground-color),
|
22
|
-
background-color: var(--rui-Alert--danger__background-color),
|
23
|
-
),
|
24
|
-
info: (
|
25
|
-
color: var(--rui-Alert--info__color),
|
26
|
-
foreground-color: var(--rui-Alert--info__foreground-color),
|
27
|
-
background-color: var(--rui-Alert--info__background-color),
|
28
|
-
),
|
29
|
-
help: (
|
30
|
-
color: var(--rui-Alert--help__color),
|
31
|
-
foreground-color: var(--rui-Alert--help__foreground-color),
|
32
|
-
background-color: var(--rui-Alert--help__background-color),
|
33
|
-
),
|
34
|
-
note: (
|
35
|
-
color: var(--rui-Alert--note__color),
|
36
|
-
foreground-color: var(--rui-Alert--note__foreground-color),
|
37
|
-
background-color: var(--rui-Alert--note__background-color),
|
38
|
-
),
|
39
|
-
light: (
|
40
|
-
color: var(--rui-Alert--light__color),
|
41
|
-
foreground-color: var(--rui-Alert--light__foreground-color),
|
42
|
-
background-color: var(--rui-Alert--light__background-color),
|
43
|
-
),
|
44
|
-
dark: (
|
45
|
-
color: var(--rui-Alert--dark__color),
|
46
|
-
foreground-color: var(--rui-Alert--dark__foreground-color),
|
47
|
-
background-color: var(--rui-Alert--dark__background-color),
|
48
|
-
),
|
49
|
-
);
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import { withGlobalProps } from '../../
|
3
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import { transferProps } from '../../utils/transferProps';
|
6
6
|
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
|
7
|
+
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
|
7
8
|
import styles from './Badge.module.scss';
|
8
9
|
|
9
10
|
export const Badge = ({
|
@@ -16,7 +17,7 @@ export const Badge = ({
|
|
16
17
|
{...transferProps(restProps)}
|
17
18
|
className={classNames(
|
18
19
|
styles.root,
|
19
|
-
priority
|
20
|
+
getRootPriorityClassName(priority, styles),
|
20
21
|
getRootColorClassName(color, styles),
|
21
22
|
)}
|
22
23
|
>
|
@@ -31,7 +32,8 @@ Badge.defaultProps = {
|
|
31
32
|
|
32
33
|
Badge.propTypes = {
|
33
34
|
/**
|
34
|
-
*
|
35
|
+
* Color to clarify importance and meaning of the badge. Implements
|
36
|
+
* [Feedback and Neutral color collections](/docs/foundation/collections#colors).
|
35
37
|
*/
|
36
38
|
color: PropTypes.oneOf(['success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark']),
|
37
39
|
/**
|
@@ -2,14 +2,14 @@
|
|
2
2
|
@use "sass:math";
|
3
3
|
@use "../../styles/theme/borders";
|
4
4
|
@use "../../styles/theme/typography";
|
5
|
-
|
6
|
-
|
5
|
+
@use "../../styles/tools/collections";
|
6
|
+
@use "settings";
|
7
7
|
|
8
8
|
@layer components.badge {
|
9
9
|
.root {
|
10
10
|
display: inline-block;
|
11
|
-
min-width:
|
12
|
-
height:
|
11
|
+
min-width: settings.$badge-size;
|
12
|
+
height: settings.$badge-size;
|
13
13
|
padding: 0.25rem 0.35rem;
|
14
14
|
overflow: hidden;
|
15
15
|
font-weight: map.get(typography.$font-weight-values, bold);
|
@@ -19,91 +19,46 @@ $_badge-size: 1.25rem;
|
|
19
19
|
white-space: nowrap;
|
20
20
|
vertical-align: baseline;
|
21
21
|
color: var(--rui-local-color);
|
22
|
-
border-radius: math.div(
|
23
|
-
background-color: var(--rui-local-background-color);
|
24
|
-
box-shadow: var(--rui-local-box-shadow, #{0 0 0 2px rgb(255 255 255 / 80%)});
|
25
|
-
}
|
26
|
-
|
27
|
-
.isRootColorSuccess {
|
28
|
-
--rui-local-color: var(--rui-color-feedback-on-success);
|
29
|
-
--rui-local-background-color: var(--rui-color-feedback-success);
|
30
|
-
}
|
31
|
-
|
32
|
-
.isRootColorWarning {
|
33
|
-
--rui-local-color: var(--rui-color-feedback-on-warning);
|
34
|
-
--rui-local-background-color: var(--rui-color-feedback-warning);
|
35
|
-
}
|
36
|
-
|
37
|
-
.isRootColorDanger {
|
38
|
-
--rui-local-color: var(--rui-color-feedback-on-danger);
|
39
|
-
--rui-local-background-color: var(--rui-color-feedback-danger);
|
40
|
-
}
|
41
|
-
|
42
|
-
.isRootColorHelp {
|
43
|
-
--rui-local-color: var(--rui-color-feedback-on-help);
|
44
|
-
--rui-local-background-color: var(--rui-color-feedback-help);
|
45
|
-
}
|
46
|
-
|
47
|
-
.isRootColorInfo {
|
48
|
-
--rui-local-color: var(--rui-color-feedback-on-info);
|
49
|
-
--rui-local-background-color: var(--rui-color-feedback-info);
|
22
|
+
border-radius: math.div(settings.$badge-size, 2);
|
50
23
|
}
|
51
24
|
|
52
|
-
.
|
53
|
-
|
54
|
-
|
25
|
+
.isRootPriorityFilled {
|
26
|
+
background-color: var(--rui-local-background-color);
|
27
|
+
box-shadow: var(--rui-local-box-shadow, #{0 0 0 2px rgb(255 255 255 / 80%)});
|
55
28
|
}
|
56
29
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
30
|
+
@each $color in settings.$colors {
|
31
|
+
@include collections.generate-class(
|
32
|
+
$prefix: "rui-",
|
33
|
+
$component-name: "Badge",
|
34
|
+
$modifier-name: "priority",
|
35
|
+
$modifier-value: "filled",
|
36
|
+
$variant-name: "color",
|
37
|
+
$variant-value: $color,
|
38
|
+
$properties: settings.$themeable-properties-filled,
|
39
|
+
);
|
61
40
|
}
|
62
41
|
|
42
|
+
.isRootColorLight,
|
63
43
|
.isRootColorDark {
|
64
|
-
--rui-local-color: var(--rui-color-neutral-on-dark);
|
65
|
-
--rui-local-background-color: var(--rui-color-neutral-dark);
|
66
44
|
--rui-local-box-shadow: none;
|
67
45
|
}
|
68
46
|
|
69
47
|
.isRootPriorityOutline {
|
70
|
-
--rui-local-background-color: transparent;
|
71
|
-
--rui-local-box-shadow: none;
|
72
|
-
|
73
48
|
padding-top: 0.1875rem;
|
74
49
|
padding-bottom: 0.1875rem;
|
75
50
|
border: borders.$width solid currentcolor;
|
76
51
|
}
|
77
52
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
}
|
89
|
-
|
90
|
-
.isRootPriorityOutline.isRootColorHelp {
|
91
|
-
--rui-local-color: var(--rui-color-feedback-help);
|
92
|
-
}
|
93
|
-
|
94
|
-
.isRootPriorityOutline.isRootColorInfo {
|
95
|
-
--rui-local-color: var(--rui-color-feedback-info);
|
96
|
-
}
|
97
|
-
|
98
|
-
.isRootPriorityOutline.isRootColorNote {
|
99
|
-
--rui-local-color: var(--rui-color-feedback-note);
|
100
|
-
}
|
101
|
-
|
102
|
-
.isRootPriorityOutline.isRootColorLight {
|
103
|
-
--rui-local-color: var(--rui-color-neutral-light);
|
104
|
-
}
|
105
|
-
|
106
|
-
.isRootPriorityOutline.isRootColorDark {
|
107
|
-
--rui-local-color: var(--rui-color-neutral-dark);
|
53
|
+
@each $color in settings.$colors {
|
54
|
+
@include collections.generate-class(
|
55
|
+
$prefix: "rui-",
|
56
|
+
$component-name: "Badge",
|
57
|
+
$modifier-name: "priority",
|
58
|
+
$modifier-value: "outline",
|
59
|
+
$variant-name: "color",
|
60
|
+
$variant-value: $color,
|
61
|
+
$properties: settings.$themeable-properties-outline,
|
62
|
+
);
|
108
63
|
}
|
109
64
|
}
|
@@ -29,8 +29,9 @@ lowest:
|
|
29
29
|
1. filled
|
30
30
|
2. outline
|
31
31
|
|
32
|
-
All priorities
|
33
|
-
[
|
32
|
+
All priorities are available in colors from supported
|
33
|
+
[color collections](/docs/foundation/collections#colors).
|
34
|
+
Check [API](#api) to see which collections are supported.
|
34
35
|
|
35
36
|
### Filled
|
36
37
|
|
@@ -102,5 +103,21 @@ helps to improve its accessibility.
|
|
102
103
|
|
103
104
|
<docoff-react-props src="/components/Badge/Badge.jsx" />
|
104
105
|
|
106
|
+
## Theming
|
107
|
+
|
108
|
+
It's possible to adjust the theme of specific badge color variant. Naming
|
109
|
+
convention looks as follows:
|
110
|
+
|
111
|
+
`--rui-Badge--<PRIORITY>--<COLOR>__<PROPERTY>`
|
112
|
+
|
113
|
+
Where:
|
114
|
+
|
115
|
+
- `<PRIORITY>` is one of `filled` or `outline`,
|
116
|
+
- `<COLOR>` is a value from supported
|
117
|
+
[color collections](/docs/foundation/collections#colors)
|
118
|
+
(check [API](#api) to see which collections are supported),
|
119
|
+
- `<PROPERTY>` is one of `color` (color of text) or `background-color` for the
|
120
|
+
filled priority, or just `color` for the outline priority.
|
121
|
+
|
105
122
|
[div-attributes]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|
106
123
|
[React common props]: https://react.dev/reference/react-dom/components/common#common-props
|
@@ -0,0 +1,8 @@
|
|
1
|
+
@use "sass:list";
|
2
|
+
@use "../../styles/settings/collections";
|
3
|
+
|
4
|
+
$badge-size: 1.25rem;
|
5
|
+
|
6
|
+
$colors: list.join(collections.$feedback-colors, collections.$neutral-colors);
|
7
|
+
$themeable-properties-filled: color, background-color;
|
8
|
+
$themeable-properties-outline: color;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React, { useContext } from 'react';
|
3
|
-
import { withGlobalProps } from '../../
|
3
|
+
import { withGlobalProps } from '../../providers/globalProps';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import { transferProps } from '../../utils/transferProps';
|
6
6
|
import { getRootColorClassName } from '../_helpers/getRootColorClassName';
|
7
|
+
import { getRootPriorityClassName } from '../_helpers/getRootPriorityClassName';
|
7
8
|
import { getRootSizeClassName } from '../_helpers/getRootSizeClassName';
|
8
9
|
import { resolveContextOrProp } from '../_helpers/resolveContextOrProp';
|
9
10
|
import { ButtonGroupContext } from '../ButtonGroup';
|
10
11
|
import { InputGroupContext } from '../InputGroup/InputGroupContext';
|
11
|
-
import getRootPriorityClassName from '../_helpers/getRootPriorityClassName';
|
12
12
|
import getRootLabelVisibilityClassName from './helpers/getRootLabelVisibilityClassName';
|
13
13
|
import styles from './Button.module.scss';
|
14
14
|
|
@@ -133,7 +133,8 @@ Button.propTypes = {
|
|
133
133
|
*/
|
134
134
|
block: PropTypes.bool,
|
135
135
|
/**
|
136
|
-
*
|
136
|
+
* Color variant to clarify importance and meaning of the alert. Implements
|
137
|
+
* [Action, Feedback and Neutral color collections](/docs/foundation/collections#colors).
|
137
138
|
*/
|
138
139
|
color: PropTypes.oneOf(
|
139
140
|
['primary', 'secondary', 'selected', 'success', 'warning', 'danger', 'help', 'info', 'note', 'light', 'dark'],
|