@react-ui-org/react-ui 0.46.0 → 0.47.0
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/README.md +15 -16
- package/dist/lib.development.js +106 -154
- package/dist/lib.js +1 -1
- package/package.json +2 -1
- package/src/lib/components/Alert/Alert.jsx +43 -43
- package/src/lib/components/Alert/README.mdx +2 -5
- package/src/lib/components/Badge/Badge.jsx +3 -3
- package/src/lib/components/Button/Button.jsx +4 -4
- package/src/lib/components/Button/README.mdx +4 -4
- package/src/lib/components/Button/_base.scss +6 -6
- package/src/lib/components/Button/helpers/getRootLabelVisibilityClassName.js +4 -4
- package/src/lib/components/ButtonGroup/ButtonGroup.jsx +10 -3
- package/src/lib/components/ButtonGroup/README.mdx +1 -1
- package/src/lib/components/Card/Card.jsx +3 -3
- package/src/lib/components/Card/CardBody.jsx +16 -5
- package/src/lib/components/Card/CardFooter.jsx +13 -5
- package/src/lib/components/CheckboxField/CheckboxField.jsx +3 -3
- package/src/lib/components/FileInputField/FileInputField.jsx +3 -3
- package/src/lib/components/FormLayout/FormLayout.jsx +3 -3
- package/src/lib/components/FormLayout/FormLayoutCustomField.jsx +3 -3
- package/src/lib/components/FormLayout/README.mdx +4 -5
- package/src/lib/components/Grid/Grid.jsx +21 -21
- package/src/lib/components/Grid/Grid.scss +6 -0
- package/src/lib/components/Grid/GridSpan.jsx +7 -7
- package/src/lib/components/Grid/README.mdx +46 -20
- package/src/lib/components/Grid/_theme.scss +7 -7
- package/src/lib/components/Modal/Modal.jsx +30 -26
- package/src/lib/components/Modal/README.mdx +2 -5
- package/src/lib/components/Paper/Paper.jsx +3 -3
- 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/Radio.jsx +3 -3
- package/src/lib/components/ScrollView/README.mdx +2 -5
- package/src/lib/components/ScrollView/ScrollView.jsx +11 -13
- package/src/lib/components/SelectField/SelectField.jsx +3 -3
- package/src/lib/components/Table/README.mdx +1 -1
- package/src/lib/components/Table/Table.jsx +3 -3
- package/src/lib/components/Tabs/Tabs.jsx +3 -3
- package/src/lib/components/Tabs/TabsItem.jsx +3 -3
- package/src/lib/components/Text/README.mdx +2 -2
- package/src/lib/components/Text/Text.jsx +3 -3
- package/src/lib/components/TextArea/TextArea.jsx +3 -3
- package/src/lib/components/TextField/TextField.jsx +3 -3
- package/src/lib/components/TextLink/TextLink.jsx +3 -3
- package/src/lib/components/Toggle/Toggle.jsx +3 -3
- package/src/lib/components/Toolbar/README.mdx +18 -6
- package/src/lib/components/Toolbar/Toolbar.jsx +10 -3
- package/src/lib/components/Toolbar/Toolbar.scss +5 -23
- package/src/lib/components/Toolbar/ToolbarGroup.jsx +10 -3
- package/src/lib/components/Toolbar/ToolbarItem.jsx +10 -3
- package/src/lib/index.js +4 -9
- package/src/lib/provider/index.js +2 -1
- package/src/lib/provider/withGlobalProps.jsx +21 -0
- package/src/lib/styles/settings/_breakpoints.scss +2 -2
- package/src/lib/styles/theme-constants/_breakpoints.scss +2 -2
- package/src/lib/styles/tools/_spacing.scss +2 -6
- package/src/lib/theme.scss +19 -18
- package/src/lib/components/List/List.jsx +0 -73
- package/src/lib/components/List/List.scss +0 -53
- package/src/lib/components/List/ListItem.jsx +0 -32
- 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 -36
- package/src/lib/components/Media/Media.scss +0 -16
- package/src/lib/components/Media/MediaBody.jsx +0 -32
- package/src/lib/components/Media/MediaObject.jsx +0 -32
- 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,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import { isChildrenEmpty } from '../_helpers/isChildrenEmpty';
|
5
5
|
import { generateResponsiveCustomProperties } from './_helpers/generateResponsiveCustomProperties';
|
6
6
|
import styles from './Grid.scss';
|
@@ -59,8 +59,8 @@ GridSpan.propTypes = {
|
|
59
59
|
md: PropTypes.number,
|
60
60
|
lg: PropTypes.number,
|
61
61
|
xl: PropTypes.number,
|
62
|
-
|
63
|
-
|
62
|
+
x2l: PropTypes.number,
|
63
|
+
x3l: PropTypes.number,
|
64
64
|
}),
|
65
65
|
]),
|
66
66
|
/**
|
@@ -78,8 +78,8 @@ GridSpan.propTypes = {
|
|
78
78
|
md: PropTypes.number,
|
79
79
|
lg: PropTypes.number,
|
80
80
|
xl: PropTypes.number,
|
81
|
-
|
82
|
-
|
81
|
+
x2l: PropTypes.number,
|
82
|
+
x3l: PropTypes.number,
|
83
83
|
}),
|
84
84
|
]),
|
85
85
|
/**
|
@@ -89,6 +89,6 @@ GridSpan.propTypes = {
|
|
89
89
|
tag: PropTypes.string,
|
90
90
|
};
|
91
91
|
|
92
|
-
export const
|
92
|
+
export const GridSpanWithGlobalProps = withGlobalProps(GridSpan, 'GridSpan');
|
93
93
|
|
94
|
-
export default
|
94
|
+
export default GridSpanWithGlobalProps;
|
@@ -27,10 +27,7 @@ import { Grid } from '@react-ui-org/react-ui';
|
|
27
27
|
And use it:
|
28
28
|
|
29
29
|
<Playground>
|
30
|
-
<Grid
|
31
|
-
<Placeholder bordered>Grid item</Placeholder>
|
32
|
-
<Placeholder bordered>Grid item</Placeholder>
|
33
|
-
<Placeholder bordered>Grid item</Placeholder>
|
30
|
+
<Grid>
|
34
31
|
<Placeholder bordered>Grid item</Placeholder>
|
35
32
|
<Placeholder bordered>Grid item</Placeholder>
|
36
33
|
<Placeholder bordered>Grid item</Placeholder>
|
@@ -41,7 +38,7 @@ See [API](#api) for all available options.
|
|
41
38
|
|
42
39
|
## General Guidelines
|
43
40
|
|
44
|
-
- This component implements native [CSS grid layout][grid-layout],
|
41
|
+
- This component implements native [CSS grid layout][grid-layout], a powerful
|
45
42
|
tool for two-dimensional layouts. You may use any value accepted by
|
46
43
|
[grid-template-columns], [grid-template-rows], [grid-column-gap],
|
47
44
|
[grid-row-gap], [grid-auto-flow], [align-content], [align-items],
|
@@ -53,20 +50,22 @@ See [API](#api) for all available options.
|
|
53
50
|
markup** like GridItem or Cell is necessary for your items. But it's there
|
54
51
|
when you really need it—see [Advanced Layouts](#advanced-layouts).
|
55
52
|
|
53
|
+
- For forms, use rather the [FormLayout](/components/form-layout) component
|
54
|
+
which is designed specifically for that purpose.
|
55
|
+
|
56
56
|
- The Grid component is so powerful that it enables you to build even very
|
57
57
|
advanced layouts **without** having to write **a single line of custom CSS.**
|
58
58
|
See [Advanced Layouts](#advanced-layouts) for more.
|
59
59
|
|
60
|
-
👉
|
61
|
-
[size 4](/foundation/spacing). Defaults for all Grid API options can be
|
62
|
-
[customized](/customize/theming/overview) with CSS custom properties.
|
60
|
+
👉 Vertical margin of items inside Grid is reset to zero.
|
63
61
|
|
64
|
-
## Columns
|
62
|
+
## Columns
|
65
63
|
|
66
|
-
Use `columns`
|
64
|
+
Stack is the default outcome of Grid. Use the `columns` option to organize your
|
65
|
+
items into grid.
|
67
66
|
|
68
67
|
<Playground>
|
69
|
-
<Grid columns="1fr
|
68
|
+
<Grid columns="1fr 1fr 1fr">
|
70
69
|
<Placeholder bordered>Grid item</Placeholder>
|
71
70
|
<Placeholder bordered>Grid item</Placeholder>
|
72
71
|
<Placeholder bordered>Grid item</Placeholder>
|
@@ -106,6 +105,21 @@ responsive layouts. Resize the playground to see it in action.
|
|
106
105
|
👉 If you need your items to have **equal height** even with content of varying
|
107
106
|
length, it may be necessary to set `height: 100%` on them.
|
108
107
|
|
108
|
+
## Rows
|
109
|
+
|
110
|
+
Use `columns` and `rows` to specify a more complicated grid layout.
|
111
|
+
|
112
|
+
<Playground>
|
113
|
+
<Grid columns="1fr 2fr" rows="auto 200px auto">
|
114
|
+
<Placeholder bordered>Grid item</Placeholder>
|
115
|
+
<Placeholder bordered>Grid item</Placeholder>
|
116
|
+
<Placeholder bordered>Grid item</Placeholder>
|
117
|
+
<Placeholder bordered>Grid item</Placeholder>
|
118
|
+
<Placeholder bordered>Grid item</Placeholder>
|
119
|
+
<Placeholder bordered>Grid item</Placeholder>
|
120
|
+
</Grid>
|
121
|
+
</Playground>
|
122
|
+
|
109
123
|
## Gaps
|
110
124
|
|
111
125
|
Both column and row gaps can be customized.
|
@@ -141,13 +155,32 @@ Individual items and the entire grid content can be aligned and along both axes.
|
|
141
155
|
</Grid>
|
142
156
|
</Playground>
|
143
157
|
|
158
|
+
## Custom HTML Tag
|
159
|
+
|
160
|
+
To render as list for example, just change the output `tag` to `ul` or `ol` and
|
161
|
+
wrap your items with `<li>`.
|
162
|
+
|
163
|
+
<Playground>
|
164
|
+
<Grid tag="ul">
|
165
|
+
<li>
|
166
|
+
<Placeholder bordered>List item</Placeholder>
|
167
|
+
</li>
|
168
|
+
<li>
|
169
|
+
<Placeholder bordered>List item</Placeholder>
|
170
|
+
</li>
|
171
|
+
<li>
|
172
|
+
<Placeholder bordered>List item</Placeholder>
|
173
|
+
</li>
|
174
|
+
</Grid>
|
175
|
+
</Playground>
|
176
|
+
|
144
177
|
## Media Queries
|
145
178
|
|
146
179
|
If you need to build more complicated layouts, you have full control over the
|
147
180
|
grid definition. Just specify your grid layout for
|
148
181
|
[breakpoints](/foundation/breakpoints) where a change of layout is needed.
|
149
182
|
The Grid component is written with the mobile-first approach so values for small
|
150
|
-
breakpoints are used until they're
|
183
|
+
breakpoints are used until they're overridden by a bigger breakpoint. If `xs`
|
151
184
|
settings are omitted, theme defaults are used. Resize your browser to see how it
|
152
185
|
works.
|
153
186
|
|
@@ -237,15 +270,8 @@ Wrapper for content that should span multiple rows or columns.
|
|
237
270
|
|
238
271
|
| Custom Property | Description |
|
239
272
|
|------------------------------------------------------|--------------------------------------------------------------|
|
240
|
-
| `--rui-Grid__columns` | Default columns layout |
|
241
273
|
| `--rui-Grid__column-gap` | Default column gap |
|
242
|
-
| `--rui-Grid__rows` | Default rows layout |
|
243
274
|
| `--rui-Grid__row-gap` | Default row gap |
|
244
|
-
| `--rui-Grid__align-content` | Default vertical alignment of the layout |
|
245
|
-
| `--rui-Grid__align-items` | Default vertical alignment of grid items |
|
246
|
-
| `--rui-Grid__justify-content` | Default horizontal alignment of the layout |
|
247
|
-
| `--rui-Grid__justify-items` | Default horizontal alignment of grid items |
|
248
|
-
| `--rui-Grid__auto-flow` | Default auto-flow algorithm |
|
249
275
|
|
250
276
|
[grid-layout]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
|
251
277
|
[grid-template-columns]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
|
@@ -253,7 +279,7 @@ Wrapper for content that should span multiple rows or columns.
|
|
253
279
|
[grid-column-gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap
|
254
280
|
[grid-row-gap]: https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap
|
255
281
|
[grid-auto-flow]: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow
|
256
|
-
[
|
282
|
+
[align-content]: https://developer.mozilla.org/en-US/docs/Web/CSS/align-content
|
257
283
|
[align-items]: https://developer.mozilla.org/en-US/docs/Web/CSS/align-items
|
258
284
|
[justify-content]: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content
|
259
285
|
[justify-items]: https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items
|
@@ -1,11 +1,11 @@
|
|
1
1
|
$responsive-properties: (
|
2
|
-
columns:
|
2
|
+
columns: 1fr,
|
3
3
|
column-gap: var(--rui-Grid__column-gap),
|
4
|
-
rows:
|
4
|
+
rows: auto,
|
5
5
|
row-gap: var(--rui-Grid__row-gap),
|
6
|
-
auto-flow:
|
7
|
-
align-content:
|
8
|
-
align-items:
|
9
|
-
justify-content:
|
10
|
-
justify-items:
|
6
|
+
auto-flow: initial,
|
7
|
+
align-content: initial,
|
8
|
+
align-items: initial,
|
9
|
+
justify-content: initial,
|
10
|
+
justify-items: initial,
|
11
11
|
);
|
@@ -1,7 +1,10 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
3
|
import { createPortal } from 'react-dom';
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
RUIContext,
|
6
|
+
withGlobalProps,
|
7
|
+
} from '../../provider';
|
5
8
|
import { classNames } from '../../utils/classNames';
|
6
9
|
import { transferProps } from '../_helpers/transferProps';
|
7
10
|
import {
|
@@ -81,7 +84,6 @@ export class Modal extends React.Component {
|
|
81
84
|
scrollView,
|
82
85
|
size,
|
83
86
|
title,
|
84
|
-
translations,
|
85
87
|
} = this.props;
|
86
88
|
|
87
89
|
const sizeClass = (modalSize) => {
|
@@ -173,15 +175,19 @@ export class Modal extends React.Component {
|
|
173
175
|
{title}
|
174
176
|
</h3>
|
175
177
|
{onClose && (
|
176
|
-
<
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
178
|
+
<RUIContext.Consumer>
|
179
|
+
{({ translations }) => (
|
180
|
+
<button
|
181
|
+
type="button"
|
182
|
+
className={styles.close}
|
183
|
+
onClick={onClose}
|
184
|
+
title={translations.Modal.close}
|
185
|
+
{...(id && { id: `${id}__closeModalHeaderButton` })}
|
186
|
+
>
|
187
|
+
×
|
188
|
+
</button>
|
189
|
+
)}
|
190
|
+
</RUIContext.Consumer>
|
185
191
|
)}
|
186
192
|
</div>
|
187
193
|
{modalBody()}
|
@@ -205,12 +211,16 @@ export class Modal extends React.Component {
|
|
205
211
|
))}
|
206
212
|
{onClose && (
|
207
213
|
<ToolbarItem>
|
208
|
-
<
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
+
<RUIContext.Consumer>
|
215
|
+
{({ translations }) => (
|
216
|
+
<Button
|
217
|
+
label={translations.Modal.close}
|
218
|
+
onClick={onClose}
|
219
|
+
priority="flat"
|
220
|
+
{...(id && { id: `${id}__closeModalFooterButton` })}
|
221
|
+
/>
|
222
|
+
)}
|
223
|
+
</RUIContext.Consumer>
|
214
224
|
</ToolbarItem>
|
215
225
|
)}
|
216
226
|
</Toolbar>
|
@@ -280,7 +290,7 @@ Modal.propTypes = {
|
|
280
290
|
*/
|
281
291
|
onClose: PropTypes.func,
|
282
292
|
/**
|
283
|
-
* If set,
|
293
|
+
* If set, modal is rendered in the React Portal with that ID.
|
284
294
|
*/
|
285
295
|
portalId: PropTypes.string,
|
286
296
|
/**
|
@@ -301,14 +311,8 @@ Modal.propTypes = {
|
|
301
311
|
* Title displayed in modal header.
|
302
312
|
*/
|
303
313
|
title: PropTypes.string.isRequired,
|
304
|
-
/**
|
305
|
-
* Translations required by the component.
|
306
|
-
*/
|
307
|
-
translations: PropTypes.shape({
|
308
|
-
close: PropTypes.string.isRequired,
|
309
|
-
}).isRequired,
|
310
314
|
};
|
311
315
|
|
312
|
-
export const
|
316
|
+
export const ModalWithGlobalProps = withGlobalProps(Modal, 'Modal');
|
313
317
|
|
314
|
-
export default
|
318
|
+
export default ModalWithGlobalProps;
|
@@ -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,6 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import React from 'react';
|
3
|
-
import {
|
3
|
+
import { withGlobalProps } from '../../provider';
|
4
4
|
import { classNames } from '../../utils/classNames';
|
5
5
|
import styles from './Paper.scss';
|
6
6
|
|
@@ -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;
|
@@ -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
|
+
}
|