@react-ui-org/react-ui 0.44.1 → 0.47.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CONTRIBUTING.md +7 -0
- package/README.md +15 -16
- package/dist/lib.development.js +271 -415
- package/dist/lib.js +1 -1
- package/package.json +11 -13
- package/src/lib/components/Alert/Alert.jsx +45 -44
- package/src/lib/components/Alert/Alert.scss +48 -48
- package/src/lib/components/Alert/README.mdx +2 -5
- package/src/lib/components/Alert/_settings.scss +4 -4
- package/src/lib/components/Alert/_theme.scss +50 -50
- package/src/lib/components/Alert/_tools.scss +6 -6
- package/src/lib/components/Badge/Badge.jsx +9 -11
- package/src/lib/components/Badge/Badge.scss +57 -57
- package/src/lib/components/Button/Button.jsx +14 -13
- package/src/lib/components/Button/Button.scss +2 -2
- package/src/lib/components/Button/README.mdx +11 -6
- package/src/lib/components/Button/_base.scss +69 -69
- package/src/lib/components/Button/_priorities.scss +49 -49
- package/src/lib/components/Button/_settings.scss +10 -10
- package/src/lib/components/Button/_theme.scss +18 -15
- package/src/lib/components/Button/_tools.scss +98 -100
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +41 -25
- package/src/lib/components/ButtonGroup/ButtonGroup.scss +3 -3
- package/src/lib/components/ButtonGroup/README.mdx +1 -1
- package/src/lib/components/Card/Card.jsx +10 -9
- package/src/lib/components/Card/Card.scss +28 -28
- package/src/lib/components/Card/CardBody.jsx +17 -12
- package/src/lib/components/Card/CardFooter.jsx +22 -9
- package/src/lib/components/Card/_theme.scss +50 -50
- package/src/lib/components/Card/_tools.scss +6 -6
- package/src/lib/components/CheckboxField/CheckboxField.jsx +21 -20
- package/src/lib/components/CheckboxField/CheckboxField.scss +20 -20
- package/src/lib/components/CheckboxField/README.mdx +1 -1
- package/src/lib/components/FileInputField/FileInputField.jsx +16 -15
- package/src/lib/components/FileInputField/FileInputField.scss +19 -19
- package/src/lib/components/FileInputField/README.mdx +1 -1
- package/src/lib/components/FormLayout/FormLayout.jsx +19 -17
- package/src/lib/components/FormLayout/FormLayout.scss +17 -17
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +18 -12
- package/src/lib/components/FormLayout/FormLayoutCustomField.scss +18 -18
- package/src/lib/components/FormLayout/README.mdx +26 -49
- package/src/lib/components/Grid/Grid.jsx +25 -24
- package/src/lib/components/Grid/Grid.scss +33 -29
- package/src/lib/components/Grid/GridSpan.jsx +11 -10
- package/src/lib/components/Grid/README.mdx +46 -20
- package/src/lib/components/Grid/{helpers → _helpers}/generateResponsiveCustomProperties.js +0 -2
- package/src/lib/components/Grid/_theme.scss +9 -9
- package/src/lib/components/Grid/_tools.scss +20 -20
- package/src/lib/components/Modal/Modal.jsx +38 -32
- package/src/lib/components/Modal/Modal.scss +73 -73
- package/src/lib/components/Modal/README.mdx +2 -5
- package/src/lib/components/Modal/_settings.scss +5 -5
- package/src/lib/components/Modal/_theme.scss +17 -17
- package/src/lib/components/Paper/Paper.jsx +9 -9
- package/src/lib/components/Paper/Paper.scss +8 -8
- package/src/lib/components/Popover/Popover.jsx +94 -0
- package/src/lib/components/Popover/Popover.scss +235 -0
- package/src/lib/components/Popover/PopoverWrapper.jsx +46 -0
- package/src/lib/components/Popover/README.mdx +333 -0
- package/src/lib/components/Popover/_helpers/getRootAlignmentClassName.js +13 -0
- package/src/lib/components/Popover/_helpers/getRootSideClassName.js +17 -0
- package/src/lib/components/Popover/_theme.scss +16 -0
- package/src/lib/components/Popover/index.js +2 -0
- package/src/lib/components/Radio/README.mdx +1 -1
- package/src/lib/components/Radio/Radio.jsx +15 -14
- package/src/lib/components/Radio/Radio.scss +26 -26
- package/src/lib/components/ScrollView/README.mdx +5 -5
- package/src/lib/components/ScrollView/ScrollView.jsx +22 -22
- package/src/lib/components/ScrollView/ScrollView.scss +113 -113
- package/src/lib/{services/elementPositionService.js → components/ScrollView/_helpers/getElementsPositionDifference.js} +0 -2
- package/src/lib/{hooks → components/ScrollView/_hooks}/useLoadResizeHook.js +1 -1
- package/src/lib/{hooks → components/ScrollView/_hooks}/useScrollPositionHook.js +1 -1
- package/src/lib/components/SelectField/README.mdx +1 -1
- package/src/lib/components/SelectField/SelectField.jsx +17 -16
- package/src/lib/components/SelectField/SelectField.scss +30 -30
- package/src/lib/components/Table/README.mdx +1 -1
- package/src/lib/components/Table/Table.jsx +3 -3
- package/src/lib/components/Table/Table.scss +28 -35
- package/src/lib/components/Table/_settings.scss +5 -5
- package/src/lib/components/Tabs/Tabs.jsx +4 -5
- package/src/lib/components/Tabs/Tabs.scss +21 -21
- package/src/lib/components/Tabs/TabsItem.jsx +7 -6
- package/src/lib/components/Tabs/TabsItem.scss +78 -78
- package/src/lib/components/Text/README.mdx +3 -3
- package/src/lib/components/Text/Text.jsx +16 -9
- package/src/lib/components/Text/Text.scss +23 -13
- package/src/lib/components/Text/_helpers/getRootClampClassName.js +11 -0
- package/src/lib/components/Text/{helpers → _helpers}/getRootHyphensClassName.js +1 -1
- package/src/lib/components/Text/{helpers → _helpers}/getRootWordWrappingClassName.js +1 -1
- package/src/lib/components/TextArea/README.mdx +1 -1
- package/src/lib/components/TextArea/TextArea.jsx +21 -17
- package/src/lib/components/TextArea/TextArea.scss +27 -27
- package/src/lib/components/TextField/README.mdx +1 -1
- package/src/lib/components/TextField/TextField.jsx +19 -18
- package/src/lib/components/TextField/TextField.scss +28 -28
- package/src/lib/components/TextLink/README.mdx +77 -0
- package/src/lib/components/TextLink/TextLink.jsx +44 -0
- package/src/lib/components/TextLink/TextLink.scss +11 -0
- package/src/lib/components/TextLink/_theme.scss +4 -0
- package/src/lib/components/TextLink/index.js +1 -0
- package/src/lib/components/Toggle/README.mdx +1 -1
- package/src/lib/components/Toggle/Toggle.jsx +21 -20
- package/src/lib/components/Toggle/Toggle.scss +20 -20
- package/src/lib/components/Toolbar/README.mdx +33 -5
- package/src/lib/components/Toolbar/Toolbar.jsx +33 -17
- package/src/lib/components/Toolbar/Toolbar.scss +29 -42
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +28 -16
- package/src/lib/components/Toolbar/ToolbarItem.jsx +36 -10
- package/src/lib/{helpers → components/_helpers}/getRootColorClassName.js +1 -1
- package/src/lib/{helpers → components/_helpers}/getRootSizeClassName.js +1 -1
- package/src/lib/{helpers → components/_helpers}/getRootValidationStateClassName.js +1 -1
- package/src/lib/components/_helpers/isChildrenEmpty.js +3 -0
- package/src/lib/{helpers → components/_helpers}/resolveContextOrProp.js +0 -0
- package/src/lib/{utils → components/_helpers}/transferProps.js +1 -1
- package/src/lib/foundation.scss +11 -11
- package/src/lib/helpers.scss +2 -2
- package/src/lib/index.js +8 -17
- package/src/lib/provider/index.js +2 -1
- package/src/lib/provider/withGlobalProps.jsx +21 -0
- package/src/lib/styles/_utilities.scss +13 -13
- package/src/lib/styles/elements/_code.scss +7 -7
- package/src/lib/styles/elements/_links.scss +8 -8
- package/src/lib/styles/elements/_lists.scss +3 -3
- package/src/lib/styles/elements/_page.scss +14 -14
- package/src/lib/styles/elements/_rulers.scss +6 -6
- package/src/lib/styles/elements/_small.scss +2 -2
- package/src/lib/styles/generic/_box-sizing.scss +3 -2
- package/src/lib/styles/generic/_forms.scss +3 -3
- package/src/lib/styles/generic/_reset.scss +6 -6
- package/src/lib/styles/generic/_shared.scss +3 -3
- package/src/lib/styles/helpers/_animation.scss +8 -8
- package/src/lib/styles/settings/_breakpoints.scss +7 -7
- package/src/lib/styles/settings/_escaped-characters.scss +5 -5
- package/src/lib/styles/settings/_form-fields.scss +24 -24
- package/src/lib/styles/settings/_utilities.scss +112 -100
- package/src/lib/styles/theme/_colors.scss +50 -50
- package/src/lib/styles/theme/_form-fields.scss +32 -32
- package/src/lib/styles/theme/_spacing.scss +11 -11
- package/src/lib/styles/theme/_typography.scss +12 -11
- package/src/lib/styles/theme-constants/_breakpoints.scss +4 -4
- package/src/lib/styles/theme-constants/_colors.scss +2 -2
- package/src/lib/styles/theme-constants/_svg.scss +1 -2
- package/src/lib/styles/tools/_accessibility.scss +29 -29
- package/src/lib/styles/tools/_breakpoint.scss +11 -14
- package/src/lib/styles/tools/_caret.scss +8 -8
- package/src/lib/styles/tools/_colors.scss +3 -3
- package/src/lib/styles/tools/_reset.scss +24 -21
- package/src/lib/styles/tools/_scrollbar.scss +4 -4
- package/src/lib/styles/tools/_spacing.scss +14 -22
- package/src/lib/styles/tools/_string.scss +9 -9
- package/src/lib/styles/tools/_svg.scss +13 -16
- package/src/lib/styles/tools/_transition.scss +42 -44
- package/src/lib/styles/tools/_utilities.scss +19 -19
- package/src/lib/styles/tools/form-fields/_box-field-elements.scss +88 -88
- package/src/lib/styles/tools/form-fields/_box-field-layout.scss +147 -147
- package/src/lib/styles/tools/form-fields/_box-field-sizes.scss +13 -15
- package/src/lib/styles/tools/form-fields/_foundation.scss +12 -12
- package/src/lib/styles/tools/form-fields/_inline-field-elements.scss +82 -71
- package/src/lib/styles/tools/form-fields/_inline-field-layout.scss +88 -47
- package/src/lib/styles/tools/form-fields/_variants.scss +104 -106
- package/src/lib/theme.scss +959 -954
- package/src/lib/utils/classNames.js +8 -0
- package/src/lib/components/CTA/CTA.jsx +0 -60
- package/src/lib/components/CTA/CTA.scss +0 -71
- package/src/lib/components/CTA/CTACenter.jsx +0 -27
- package/src/lib/components/CTA/CTAEnd.jsx +0 -27
- package/src/lib/components/CTA/CTAStart.jsx +0 -27
- package/src/lib/components/CTA/README.mdx +0 -119
- package/src/lib/components/CTA/index.js +0 -4
- package/src/lib/components/Center/Center.jsx +0 -27
- package/src/lib/components/Center/Center.scss +0 -7
- package/src/lib/components/Center/README.mdx +0 -52
- package/src/lib/components/Center/index.js +0 -1
- package/src/lib/components/Link/Link.jsx +0 -45
- package/src/lib/components/Link/Link.scss +0 -11
- package/src/lib/components/Link/README.mdx +0 -85
- package/src/lib/components/Link/_theme.scss +0 -4
- package/src/lib/components/Link/index.js +0 -1
- package/src/lib/components/List/List.jsx +0 -71
- package/src/lib/components/List/List.scss +0 -53
- package/src/lib/components/List/ListItem.jsx +0 -31
- package/src/lib/components/List/README.mdx +0 -114
- package/src/lib/components/List/_theme.scss +0 -1
- package/src/lib/components/List/index.js +0 -2
- package/src/lib/components/Media/Media.jsx +0 -29
- package/src/lib/components/Media/Media.scss +0 -16
- package/src/lib/components/Media/MediaBody.jsx +0 -21
- package/src/lib/components/Media/MediaObject.jsx +0 -21
- package/src/lib/components/Media/README.mdx +0 -63
- package/src/lib/components/Media/index.js +0 -3
- package/src/lib/provider/withProviderContext.jsx +0 -32
@@ -1,126 +1,126 @@
|
|
1
|
-
@use
|
2
|
-
@use
|
3
|
-
@use
|
4
|
-
@use
|
5
|
-
@use
|
6
|
-
@use
|
7
|
-
@use
|
8
|
-
@use
|
1
|
+
@use "sass:map";
|
2
|
+
@use "../../styles/theme/typography";
|
3
|
+
@use "../../styles/tools/accessibility";
|
4
|
+
@use "../../styles/tools/breakpoint";
|
5
|
+
@use "../../styles/tools/reset";
|
6
|
+
@use "../../styles/tools/spacing";
|
7
|
+
@use "settings";
|
8
|
+
@use "theme";
|
9
9
|
|
10
10
|
.root {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
11
|
+
--rui-local-outer-spacing: #{theme.$outer-spacing-xs};
|
12
|
+
|
13
|
+
position: fixed;
|
14
|
+
left: 50%;
|
15
|
+
z-index: settings.$z-index;
|
16
|
+
display: flex;
|
17
|
+
flex-direction: column;
|
18
|
+
max-width: calc(100% - (2 * var(--rui-local-outer-spacing)));
|
19
|
+
max-height: calc(100% - (2 * var(--rui-local-outer-spacing)));
|
20
|
+
overflow-y: auto;
|
21
|
+
border-radius: settings.$border-radius;
|
22
|
+
background: theme.$background;
|
23
|
+
box-shadow: theme.$box-shadow;
|
24
|
+
transform: translateX(-50%);
|
25
|
+
|
26
|
+
@include breakpoint.up(sm) {
|
27
|
+
--rui-local-outer-spacing: #{theme.$outer-spacing-sm};
|
28
|
+
}
|
29
29
|
}
|
30
30
|
|
31
31
|
.head {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
display: flex;
|
33
|
+
flex: none;
|
34
|
+
align-items: baseline;
|
35
|
+
justify-content: space-between;
|
36
|
+
padding: settings.$padding-y spacing.of(4) settings.$padding-y settings.$padding-x;
|
37
37
|
}
|
38
38
|
|
39
39
|
.headTitle {
|
40
|
-
|
40
|
+
font-size: settings.$head-title-font-size;
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
&:not(:last-child) {
|
43
|
+
margin-bottom: 0;
|
44
|
+
}
|
45
45
|
}
|
46
46
|
|
47
47
|
.close {
|
48
|
-
|
49
|
-
|
48
|
+
@include reset.button();
|
49
|
+
@include accessibility.min-tap-target();
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
51
|
+
font-size: map.get(typography.$size-values, 3);
|
52
|
+
line-height: 1;
|
53
|
+
color: inherit;
|
54
54
|
}
|
55
55
|
|
56
56
|
.body {
|
57
|
-
|
57
|
+
flex: 1 1 auto;
|
58
58
|
}
|
59
59
|
|
60
60
|
.isBodyScrollable {
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
display: flex;
|
62
|
+
flex-direction: column;
|
63
|
+
min-height: 0;
|
64
64
|
}
|
65
65
|
|
66
66
|
.content {
|
67
|
-
|
67
|
+
padding: settings.$padding-y settings.$padding-x settings.$content-padding-bottom;
|
68
68
|
}
|
69
69
|
|
70
70
|
.footer {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
71
|
+
display: flex;
|
72
|
+
flex: none;
|
73
|
+
flex-wrap: wrap;
|
74
|
+
align-items: center;
|
75
|
+
justify-content: center;
|
76
|
+
padding: settings.$padding-y settings.$padding-x;
|
77
|
+
border-bottom-right-radius: settings.$border-radius;
|
78
|
+
border-bottom-left-radius: settings.$border-radius;
|
79
|
+
background: theme.$footer-background;
|
80
80
|
}
|
81
81
|
|
82
82
|
.backdrop {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
position: fixed;
|
84
|
+
top: 0;
|
85
|
+
left: 0;
|
86
|
+
z-index: settings.$backdrop-z-index;
|
87
|
+
width: 100vw;
|
88
|
+
height: 100vh;
|
89
|
+
background: theme.$backdrop-background;
|
90
90
|
}
|
91
91
|
|
92
92
|
.isRootSizeSmall {
|
93
|
-
|
93
|
+
width: map.get(theme.$sizes, small, width);
|
94
94
|
}
|
95
95
|
|
96
96
|
.isRootSizeMedium {
|
97
|
-
|
97
|
+
width: map.get(theme.$sizes, medium, width);
|
98
98
|
}
|
99
99
|
|
100
100
|
.isRootSizeLarge {
|
101
|
-
|
101
|
+
width: map.get(theme.$sizes, large, width);
|
102
102
|
}
|
103
103
|
|
104
104
|
.isRootSizeFullscreen {
|
105
|
-
|
106
|
-
|
105
|
+
width: map.get(theme.$sizes, fullscreen, width);
|
106
|
+
height: map.get(theme.$sizes, fullscreen, height);
|
107
107
|
}
|
108
108
|
|
109
109
|
.isRootSizeFullscreen .content {
|
110
|
-
|
110
|
+
height: 100%;
|
111
111
|
}
|
112
112
|
|
113
113
|
.isRootSizeAuto {
|
114
|
-
|
115
|
-
|
116
|
-
|
114
|
+
width: auto;
|
115
|
+
min-width: map.get(theme.$sizes, auto, min-width);
|
116
|
+
max-width: map.get(theme.$sizes, auto, max-width);
|
117
117
|
}
|
118
118
|
|
119
119
|
.isRootPositionCenter {
|
120
|
-
|
121
|
-
|
120
|
+
top: 50%;
|
121
|
+
transform: translate(-50%, -50%);
|
122
122
|
}
|
123
123
|
|
124
124
|
.isRootPositionTop {
|
125
|
-
|
125
|
+
top: var(--rui-local-outer-spacing);
|
126
126
|
}
|
@@ -13,10 +13,7 @@ import {
|
|
13
13
|
Props,
|
14
14
|
} from 'docz'
|
15
15
|
import Button from '../Button'
|
16
|
-
import {
|
17
|
-
ModalWithContext as Modal,
|
18
|
-
Modal as ParsableModal,
|
19
|
-
} from './Modal'
|
16
|
+
import { Modal } from './Modal'
|
20
17
|
|
21
18
|
## Basic Usage
|
22
19
|
|
@@ -407,7 +404,7 @@ to prevent interaction. That's where blocking modals may come handy.
|
|
407
404
|
|
408
405
|
## API
|
409
406
|
|
410
|
-
<Props table of={
|
407
|
+
<Props table of={Modal} />
|
411
408
|
|
412
409
|
## Theming
|
413
410
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
@use
|
2
|
-
@use
|
3
|
-
@use
|
4
|
-
@use
|
5
|
-
@use
|
1
|
+
@use "sass:map";
|
2
|
+
@use "../../styles/settings/z-indexes";
|
3
|
+
@use "../../styles/theme/borders";
|
4
|
+
@use "../../styles/theme/typography";
|
5
|
+
@use "../../styles/tools/spacing";
|
6
6
|
|
7
7
|
$padding-x: spacing.of(5);
|
8
8
|
$padding-y: spacing.of(3);
|
@@ -6,21 +6,21 @@ $outer-spacing-xs: var(--rui-Modal__outer-spacing--xs);
|
|
6
6
|
$outer-spacing-sm: var(--rui-Modal__outer-spacing--sm);
|
7
7
|
|
8
8
|
$sizes: (
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
auto: (
|
10
|
+
min-width: var(--rui-Modal--auto__min-width),
|
11
|
+
max-width: var(--rui-Modal--auto__max-width),
|
12
|
+
),
|
13
|
+
small: (
|
14
|
+
width: var(--rui-Modal--small__width),
|
15
|
+
),
|
16
|
+
medium: (
|
17
|
+
width: var(--rui-Modal--medium__width),
|
18
|
+
),
|
19
|
+
large: (
|
20
|
+
width: var(--rui-Modal--large__width),
|
21
|
+
),
|
22
|
+
fullscreen: (
|
23
|
+
width: var(--rui-Modal--fullscreen__width),
|
24
|
+
height: var(--rui-Modal--fullscreen__height),
|
25
|
+
),
|
26
26
|
);
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
|
+
import { classNames } from '../../utils/classNames';
|
4
5
|
import styles from './Paper.scss';
|
5
6
|
|
6
7
|
export const Paper = ({
|
@@ -10,11 +11,11 @@ export const Paper = ({
|
|
10
11
|
raised,
|
11
12
|
}) => (
|
12
13
|
<div
|
13
|
-
className={
|
14
|
+
className={classNames(
|
14
15
|
styles.root,
|
15
|
-
muted
|
16
|
-
raised
|
17
|
-
|
16
|
+
muted && styles.rootMuted,
|
17
|
+
raised && styles.rootRaised,
|
18
|
+
)}
|
18
19
|
id={id}
|
19
20
|
>
|
20
21
|
{children}
|
@@ -22,7 +23,6 @@ export const Paper = ({
|
|
22
23
|
);
|
23
24
|
|
24
25
|
Paper.defaultProps = {
|
25
|
-
children: null,
|
26
26
|
id: undefined,
|
27
27
|
muted: false,
|
28
28
|
raised: false,
|
@@ -32,7 +32,7 @@ Paper.propTypes = {
|
|
32
32
|
/**
|
33
33
|
* Content to be placed onto Paper.
|
34
34
|
*/
|
35
|
-
children: PropTypes.node,
|
35
|
+
children: PropTypes.node.isRequired,
|
36
36
|
/**
|
37
37
|
* ID of the root HTML element.
|
38
38
|
*/
|
@@ -47,6 +47,6 @@ Paper.propTypes = {
|
|
47
47
|
raised: PropTypes.bool,
|
48
48
|
};
|
49
49
|
|
50
|
-
export const
|
50
|
+
export const PaperWithGlobalProps = withGlobalProps(Paper, 'Paper');
|
51
51
|
|
52
|
-
export default
|
52
|
+
export default PaperWithGlobalProps;
|
@@ -1,17 +1,17 @@
|
|
1
|
-
@use
|
1
|
+
@use "theme";
|
2
2
|
|
3
3
|
.root {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
padding: theme.$padding;
|
5
|
+
border: theme.$border-width solid theme.$border-color;
|
6
|
+
border-radius: theme.$border-radius;
|
7
|
+
background-color: theme.$background-color;
|
8
8
|
}
|
9
9
|
|
10
10
|
.rootMuted {
|
11
|
-
|
12
|
-
|
11
|
+
background-color: theme.$muted-background-color;
|
12
|
+
opacity: theme.$muted-opacity;
|
13
13
|
}
|
14
14
|
|
15
15
|
.rootRaised {
|
16
|
-
|
16
|
+
box-shadow: theme.$raised-box-shadow;
|
17
17
|
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
import PropTypes from 'prop-types';
|
2
|
+
import React from 'react';
|
3
|
+
import { createPortal } from 'react-dom';
|
4
|
+
import { withGlobalProps } from '../../provider';
|
5
|
+
import { classNames } from '../../utils/classNames';
|
6
|
+
import { transferProps } from '../_helpers/transferProps';
|
7
|
+
import withForwardedRef from '../withForwardedRef';
|
8
|
+
import getRootSideClassName from './_helpers/getRootSideClassName';
|
9
|
+
import getRootAlignmentClassName from './_helpers/getRootAlignmentClassName';
|
10
|
+
import styles from './Popover.scss';
|
11
|
+
|
12
|
+
export const Popover = ({
|
13
|
+
forwardedRef,
|
14
|
+
placement,
|
15
|
+
children,
|
16
|
+
id,
|
17
|
+
portalId,
|
18
|
+
...restProps
|
19
|
+
}) => {
|
20
|
+
const PopoverEl = (
|
21
|
+
<div
|
22
|
+
className={classNames(
|
23
|
+
styles.root,
|
24
|
+
forwardedRef && styles.isRootControlled,
|
25
|
+
getRootSideClassName(placement, styles),
|
26
|
+
getRootAlignmentClassName(placement, styles),
|
27
|
+
)}
|
28
|
+
id={id}
|
29
|
+
ref={forwardedRef}
|
30
|
+
{...transferProps(restProps)}
|
31
|
+
>
|
32
|
+
{children}
|
33
|
+
<span className={styles.arrow} />
|
34
|
+
</div>
|
35
|
+
);
|
36
|
+
|
37
|
+
if (portalId === null) {
|
38
|
+
return PopoverEl;
|
39
|
+
}
|
40
|
+
|
41
|
+
return createPortal(PopoverEl, document.getElementById(portalId));
|
42
|
+
};
|
43
|
+
|
44
|
+
Popover.defaultProps = {
|
45
|
+
forwardedRef: undefined,
|
46
|
+
id: undefined,
|
47
|
+
placement: 'bottom',
|
48
|
+
portalId: null,
|
49
|
+
};
|
50
|
+
|
51
|
+
Popover.propTypes = {
|
52
|
+
/**
|
53
|
+
* Popover content.
|
54
|
+
*/
|
55
|
+
children: PropTypes.node.isRequired,
|
56
|
+
/**
|
57
|
+
* Reference forwarded to the root `div` element.
|
58
|
+
*/
|
59
|
+
forwardedRef: PropTypes.oneOfType([
|
60
|
+
PropTypes.func,
|
61
|
+
// eslint-disable-next-line react/forbid-prop-types
|
62
|
+
PropTypes.shape({ current: PropTypes.any }),
|
63
|
+
]),
|
64
|
+
/**
|
65
|
+
* ID of the root HTML element.
|
66
|
+
*/
|
67
|
+
id: PropTypes.string,
|
68
|
+
/**
|
69
|
+
* Popover placement affects position of the arrow.
|
70
|
+
* Compatible with [Floating UI API](https://floating-ui.com/docs/computePosition#placement).
|
71
|
+
*/
|
72
|
+
placement: PropTypes.oneOf([
|
73
|
+
'top',
|
74
|
+
'top-start',
|
75
|
+
'top-end',
|
76
|
+
'right',
|
77
|
+
'right-start',
|
78
|
+
'right-end',
|
79
|
+
'bottom',
|
80
|
+
'bottom-start',
|
81
|
+
'bottom-end',
|
82
|
+
'left',
|
83
|
+
'left-start',
|
84
|
+
'left-end',
|
85
|
+
]),
|
86
|
+
/**
|
87
|
+
* If set, popover is rendered in the React Portal with that ID.
|
88
|
+
*/
|
89
|
+
portalId: PropTypes.string,
|
90
|
+
};
|
91
|
+
|
92
|
+
export const PopoverWithContext = withForwardedRef(withGlobalProps(Popover, 'Popover'));
|
93
|
+
|
94
|
+
export default PopoverWithContext;
|
@@ -0,0 +1,235 @@
|
|
1
|
+
// 1. Reset positioning for controlled variant.
|
2
|
+
// 2. Shift Popover so there is space for the arrow between Popover and reference element.
|
3
|
+
// 3. Add top offset in case it's not defined by external library.
|
4
|
+
|
5
|
+
@use "theme";
|
6
|
+
|
7
|
+
.wrapper {
|
8
|
+
position: relative;
|
9
|
+
}
|
10
|
+
|
11
|
+
.root {
|
12
|
+
position: absolute;
|
13
|
+
width: theme.$width;
|
14
|
+
padding: theme.$padding;
|
15
|
+
color: theme.$color;
|
16
|
+
border: theme.$border-width solid theme.$border-color;
|
17
|
+
border-radius: theme.$border-radius;
|
18
|
+
background-color: theme.$background-color;
|
19
|
+
box-shadow: theme.$box-shadow;
|
20
|
+
}
|
21
|
+
|
22
|
+
.arrow {
|
23
|
+
position: absolute;
|
24
|
+
width: theme.$arrow-width;
|
25
|
+
height: theme.$arrow-height;
|
26
|
+
transform-origin: center bottom;
|
27
|
+
|
28
|
+
&::before,
|
29
|
+
&::after {
|
30
|
+
content: "";
|
31
|
+
position: absolute;
|
32
|
+
display: block;
|
33
|
+
border-style: solid;
|
34
|
+
border-color: transparent;
|
35
|
+
}
|
36
|
+
|
37
|
+
&::before {
|
38
|
+
bottom: 0;
|
39
|
+
border-width: theme.$arrow-height theme.$arrow-height 0;
|
40
|
+
border-top-color: theme.$border-color;
|
41
|
+
}
|
42
|
+
|
43
|
+
&::after {
|
44
|
+
bottom: theme.$border-width;
|
45
|
+
border-width: theme.$arrow-height theme.$arrow-height 0;
|
46
|
+
border-top-color: theme.$background-color;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
// Sides
|
51
|
+
.isRootAtTop {
|
52
|
+
bottom: 100%;
|
53
|
+
}
|
54
|
+
|
55
|
+
.isRootAtBottom {
|
56
|
+
top: 100%;
|
57
|
+
}
|
58
|
+
|
59
|
+
.isRootAtLeft {
|
60
|
+
right: 100%;
|
61
|
+
}
|
62
|
+
|
63
|
+
.isRootAtRight {
|
64
|
+
left: 100%;
|
65
|
+
}
|
66
|
+
|
67
|
+
// Arrows
|
68
|
+
.isRootAtTop > .arrow {
|
69
|
+
top: 100%;
|
70
|
+
}
|
71
|
+
|
72
|
+
.isRootAtBottom > .arrow {
|
73
|
+
bottom: 100%;
|
74
|
+
}
|
75
|
+
|
76
|
+
.isRootAtLeft > .arrow {
|
77
|
+
left: 100%;
|
78
|
+
}
|
79
|
+
|
80
|
+
.isRootAtRight > .arrow {
|
81
|
+
right: 100%;
|
82
|
+
}
|
83
|
+
|
84
|
+
// Side alignments: top
|
85
|
+
.isRootAtTop.isRootAtCenter {
|
86
|
+
left: 50%;
|
87
|
+
transform: translate(-50%, #{-1 * theme.$arrow-height});
|
88
|
+
}
|
89
|
+
|
90
|
+
.isRootAtTop.isRootAtStart {
|
91
|
+
left: 0;
|
92
|
+
transform: translate(0, #{-1 * theme.$arrow-height});
|
93
|
+
}
|
94
|
+
|
95
|
+
.isRootAtTop.isRootAtEnd {
|
96
|
+
right: 0;
|
97
|
+
transform: translate(0, #{-1 * theme.$arrow-height});
|
98
|
+
}
|
99
|
+
|
100
|
+
.isRootAtTop.isRootAtCenter > .arrow {
|
101
|
+
left: 50%;
|
102
|
+
transform: translate(-50%, 0) rotateZ(0);
|
103
|
+
}
|
104
|
+
|
105
|
+
.isRootAtTop.isRootAtStart > .arrow {
|
106
|
+
left: theme.$arrow-corner-offset;
|
107
|
+
transform: translate(0, 0) rotateZ(0);
|
108
|
+
}
|
109
|
+
|
110
|
+
.isRootAtTop.isRootAtEnd > .arrow {
|
111
|
+
right: theme.$arrow-corner-offset;
|
112
|
+
transform: translate(0, 0) rotateZ(0);
|
113
|
+
}
|
114
|
+
|
115
|
+
// Side alignments: bottom
|
116
|
+
.isRootAtBottom.isRootAtCenter {
|
117
|
+
left: 50%;
|
118
|
+
transform: translate(-50%, #{theme.$arrow-height});
|
119
|
+
}
|
120
|
+
|
121
|
+
.isRootAtBottom.isRootAtStart {
|
122
|
+
left: 0;
|
123
|
+
transform: translate(0, #{theme.$arrow-height});
|
124
|
+
}
|
125
|
+
|
126
|
+
.isRootAtBottom.isRootAtEnd {
|
127
|
+
right: 0;
|
128
|
+
transform: translate(0, #{theme.$arrow-height});
|
129
|
+
}
|
130
|
+
|
131
|
+
.isRootAtBottom.isRootAtCenter > .arrow {
|
132
|
+
left: 50%;
|
133
|
+
transform: translate(-50%, -100%) rotateZ(180deg);
|
134
|
+
}
|
135
|
+
|
136
|
+
.isRootAtBottom.isRootAtStart > .arrow {
|
137
|
+
left: theme.$arrow-corner-offset;
|
138
|
+
transform: translate(0, -100%) rotateZ(180deg);
|
139
|
+
}
|
140
|
+
|
141
|
+
.isRootAtBottom.isRootAtEnd > .arrow {
|
142
|
+
right: theme.$arrow-corner-offset;
|
143
|
+
transform: translate(0, -100%) rotateZ(180deg);
|
144
|
+
}
|
145
|
+
|
146
|
+
// Side alignments: left
|
147
|
+
.isRootAtLeft.isRootAtCenter {
|
148
|
+
top: 50%;
|
149
|
+
transform: translate(#{-1 * theme.$arrow-height}, -50%);
|
150
|
+
}
|
151
|
+
|
152
|
+
.isRootAtLeft.isRootAtStart {
|
153
|
+
top: 0;
|
154
|
+
transform: translate(#{-1 * theme.$arrow-height}, 0);
|
155
|
+
}
|
156
|
+
|
157
|
+
.isRootAtLeft.isRootAtEnd {
|
158
|
+
bottom: 0;
|
159
|
+
transform: translate(#{-1 * theme.$arrow-height}, 0);
|
160
|
+
}
|
161
|
+
|
162
|
+
.isRootAtLeft.isRootAtCenter > .arrow {
|
163
|
+
top: 50%;
|
164
|
+
transform: translate(0, -100%) rotateZ(-90deg);
|
165
|
+
}
|
166
|
+
|
167
|
+
.isRootAtLeft.isRootAtStart > .arrow {
|
168
|
+
top: theme.$arrow-corner-offset;
|
169
|
+
transform: translate(0, 0) rotateZ(-90deg);
|
170
|
+
}
|
171
|
+
|
172
|
+
.isRootAtLeft.isRootAtEnd > .arrow {
|
173
|
+
bottom: theme.$arrow-corner-offset;
|
174
|
+
transform: translate(0, -100%) rotateZ(-90deg);
|
175
|
+
}
|
176
|
+
|
177
|
+
// Side alignments: right
|
178
|
+
.isRootAtRight.isRootAtCenter {
|
179
|
+
top: 50%;
|
180
|
+
transform: translate(#{theme.$arrow-height}, -50%);
|
181
|
+
}
|
182
|
+
|
183
|
+
.isRootAtRight.isRootAtStart {
|
184
|
+
top: 0;
|
185
|
+
transform: translate(#{theme.$arrow-height}, 0);
|
186
|
+
}
|
187
|
+
|
188
|
+
.isRootAtRight.isRootAtEnd {
|
189
|
+
bottom: 0;
|
190
|
+
transform: translate(#{theme.$arrow-height}, 0);
|
191
|
+
}
|
192
|
+
|
193
|
+
.isRootAtRight.isRootAtCenter > .arrow {
|
194
|
+
top: 50%;
|
195
|
+
transform: translate(0, -100%) rotateZ(90deg);
|
196
|
+
}
|
197
|
+
|
198
|
+
.isRootAtRight.isRootAtStart > .arrow {
|
199
|
+
top: theme.$arrow-corner-offset;
|
200
|
+
transform: translate(0, 0) rotateZ(90deg);
|
201
|
+
}
|
202
|
+
|
203
|
+
.isRootAtRight.isRootAtEnd > .arrow {
|
204
|
+
bottom: theme.$arrow-corner-offset;
|
205
|
+
transform: translate(0, -100%) rotateZ(90deg);
|
206
|
+
}
|
207
|
+
|
208
|
+
// Controlled
|
209
|
+
.isRootControlled.isRootAtTop,
|
210
|
+
.isRootControlled.isRootAtBottom,
|
211
|
+
.isRootControlled.isRootAtLeft,
|
212
|
+
.isRootControlled.isRootAtRight {
|
213
|
+
inset: unset; // 1.
|
214
|
+
}
|
215
|
+
|
216
|
+
.isRootControlled.isRootAtTop {
|
217
|
+
transform: translate(0, #{-1 * theme.$arrow-height}); // 2.
|
218
|
+
}
|
219
|
+
|
220
|
+
.isRootControlled.isRootAtBottom {
|
221
|
+
transform: translate(0, #{theme.$arrow-height}); // 2.
|
222
|
+
}
|
223
|
+
|
224
|
+
.isRootControlled.isRootAtLeft {
|
225
|
+
transform: translate(#{-1 * theme.$arrow-height}, 0); // 2.
|
226
|
+
}
|
227
|
+
|
228
|
+
.isRootControlled.isRootAtRight {
|
229
|
+
transform: translate(#{theme.$arrow-height}, 0); // 2.
|
230
|
+
}
|
231
|
+
|
232
|
+
.isRootControlled.isRootAtLeft.isRootAtStart,
|
233
|
+
.isRootControlled.isRootAtRight.isRootAtStart {
|
234
|
+
top: 0; // 3.
|
235
|
+
}
|