@basic-ui/material 1.0.0-alpha.37 → 1.0.0-alpha.38
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/build/cjs/index.js +140 -15
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Alert/Alert.d.ts +1 -1
- package/build/esm/AppBar/AppBar.d.ts +1 -1
- package/build/esm/AppBar/AppBarButton.d.ts +1 -1
- package/build/esm/Badge/Badge.d.ts +1 -1
- package/build/esm/BottomSheet/BottomSheet.d.ts +1 -1
- package/build/esm/BottomSheet/BottomSheetSurface.d.ts +1 -1
- package/build/esm/Button/BaseButton.d.ts +1 -1
- package/build/esm/Button/Button.d.ts +1 -1
- package/build/esm/Button/ButtonGroup.d.ts +1 -1
- package/build/esm/Button/FilledButton.d.ts +1 -1
- package/build/esm/Button/OutlinedButton.d.ts +1 -1
- package/build/esm/Button/TransparentButton.d.ts +1 -1
- package/build/esm/CheckBox/CheckBox.d.ts +1 -1
- package/build/esm/CheckBox/CheckBoxIcon.d.ts +1 -1
- package/build/esm/Chip/ButtonChip.d.ts +1 -1
- package/build/esm/Chip/ChipBase.d.ts +1 -1
- package/build/esm/Chip/ChoiceChip.d.ts +1 -1
- package/build/esm/Combobox/Combobox.d.ts +7 -7
- package/build/esm/Dialog/Dialog.d.ts +1 -1
- package/build/esm/Dialog/DialogBackdrop.d.ts +1 -1
- package/build/esm/Dialog/DialogContainer.d.ts +1 -1
- package/build/esm/Dialog/DialogSurface.d.ts +1 -1
- package/build/esm/Dialog/Scrim.d.ts +1 -1
- package/build/esm/Divider/Divider.d.ts +1 -1
- package/build/esm/LineRipple/LineRipple.d.ts +1 -1
- package/build/esm/Link/Link.d.ts +1 -1
- package/build/esm/List/List.d.ts +1 -1
- package/build/esm/ListItem/ListItem.d.ts +1 -1
- package/build/esm/Menu/Menu.d.ts +5 -5
- package/build/esm/Menu/index.d.ts +1 -0
- package/build/esm/Menu/index.js +1 -0
- package/build/esm/Menu/index.js.map +1 -1
- package/build/esm/NavRail/NavRailItem.d.ts +3 -3
- package/build/esm/Paper/Paper.d.ts +1 -1
- package/build/esm/Popover/Popover.d.ts +20 -0
- package/build/esm/Popover/Popover.js +74 -0
- package/build/esm/Popover/Popover.js.map +1 -0
- package/build/esm/Popover/PopoverContainer.d.ts +4 -0
- package/build/esm/Popover/PopoverContainer.js +20 -0
- package/build/esm/Popover/PopoverContainer.js.map +1 -0
- package/build/esm/Popover/PopoverSurface.d.ts +5 -0
- package/build/esm/Popover/PopoverSurface.js +41 -0
- package/build/esm/Popover/PopoverSurface.js.map +1 -0
- package/build/esm/Popover/index.d.ts +1 -0
- package/build/esm/Popover/index.js +2 -0
- package/build/esm/Popover/index.js.map +1 -0
- package/build/esm/ProgressSpinner/ProgressSpinner.d.ts +1 -1
- package/build/esm/RadioButton/RadioGroup.d.ts +1 -1
- package/build/esm/Select/CustomContainerExample.d.ts +1 -1
- package/build/esm/Select/SelectIcon.d.ts +1 -1
- package/build/esm/SelectionControl/SelectionControlLabel.d.ts +1 -1
- package/build/esm/SelectionControl/SelectionControlText.d.ts +1 -1
- package/build/esm/Skeleton/DelayAppearance.d.ts +1 -1
- package/build/esm/Skeleton/Skeleton.d.ts +1 -1
- package/build/esm/Slider/Slider.d.ts +6 -6
- package/build/esm/Snackbar/Snackbar.d.ts +1 -1
- package/build/esm/Switch/Switch.d.ts +1 -1
- package/build/esm/Tab/Tab.d.ts +1 -1
- package/build/esm/Tab/TabList.d.ts +1 -1
- package/build/esm/Tab/TabPanel.d.ts +1 -1
- package/build/esm/TabIndicator/TabIndicator.d.ts +1 -1
- package/build/esm/Table/Table.d.ts +1 -1
- package/build/esm/Table/TableBody.d.ts +1 -1
- package/build/esm/Table/TableCell.d.ts +1 -1
- package/build/esm/Table/TableHead.d.ts +1 -1
- package/build/esm/Table/TableRow.d.ts +1 -1
- package/build/esm/Text/Text.d.ts +1 -1
- package/build/esm/TextField/FilledContainer.d.ts +1 -1
- package/build/esm/TextField/HelperText.d.ts +1 -1
- package/build/esm/TextField/Input.d.ts +1 -1
- package/build/esm/TextField/OutlinedContainer.d.ts +1 -1
- package/build/esm/TextField/TextField.d.ts +1 -1
- package/build/esm/Tooltip/Tooltip.d.ts +1 -1
- package/build/esm/Tooltip/Tooltip.js +24 -12
- package/build/esm/Tooltip/Tooltip.js.map +1 -1
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/index.js.map +1 -1
- package/build/tsconfig-build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/Menu/index.ts +1 -0
- package/src/Popover/Popover.story.tsx +29 -0
- package/src/Popover/Popover.tsx +95 -0
- package/src/Popover/PopoverContainer.tsx +25 -0
- package/src/Popover/PopoverSurface.tsx +51 -0
- package/src/Popover/index.ts +1 -0
- package/src/Tooltip/Tooltip.tsx +19 -12
- package/src/index.ts +1 -0
- package/build/esm/ThemeExplorer/importGoogleFont.d.ts +0 -4
- package/build/esm/ThemeExplorer/importGoogleFont.js +0 -25
- package/build/esm/ThemeExplorer/importGoogleFont.js.map +0 -1
- package/build/esm/tailwind/makeTailwindTheme.d.ts +0 -5
- package/build/esm/tailwind/makeTailwindTheme.js +0 -32
- package/build/esm/tailwind/makeTailwindTheme.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basic-ui/material",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.38",
|
|
4
4
|
"description": "Accessible React Components used as building blocks for UI patterns",
|
|
5
5
|
"author": "Lucas Terra <lucasterra7@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0",
|
|
63
63
|
"tailwindcss": "^3.0.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "58116e5c2f4f369e96b5b61b382a49d017632970"
|
|
66
66
|
}
|
package/src/Menu/index.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Button } from '../Button';
|
|
4
|
+
import { Box } from '../Box';
|
|
5
|
+
import { TextField } from '../TextField';
|
|
6
|
+
import { Popover } from './Popover';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'components/Popover',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Example = () => {
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<Box bg="surface" display="flex" justifyContent="center">
|
|
18
|
+
<Button id="open-button" onClick={() => setOpen(true)} ref={buttonRef}>
|
|
19
|
+
Open dialog
|
|
20
|
+
</Button>
|
|
21
|
+
<Popover open={open} onClose={() => setOpen(false)} anchorEl={buttonRef}>
|
|
22
|
+
Hello hello
|
|
23
|
+
<TextField placeholder="Hello" />
|
|
24
|
+
</Popover>
|
|
25
|
+
</Box>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Simple = () => <Example />;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Popper,
|
|
3
|
+
type PopperProps,
|
|
4
|
+
assignMultipleRefs,
|
|
5
|
+
Portal,
|
|
6
|
+
} from '@basic-ui/core';
|
|
7
|
+
import { forwardRef, useEffect, useRef } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Box } from '../';
|
|
10
|
+
import type { DialogBackdropProps } from '../Dialog/DialogBackdrop';
|
|
11
|
+
import { DialogBackdrop } from '../Dialog/DialogBackdrop';
|
|
12
|
+
import { PopoverSurface } from './PopoverSurface';
|
|
13
|
+
import type { PopoverContainerProps } from './PopoverContainer';
|
|
14
|
+
import { PopoverContainer } from './PopoverContainer';
|
|
15
|
+
|
|
16
|
+
export type PopoverProps = Omit<PopperProps, 'usePortal'> & {
|
|
17
|
+
open: boolean;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
disableBackdropClick?: boolean;
|
|
20
|
+
disableEscapeKeyDown?: boolean;
|
|
21
|
+
backdropProps?: DialogBackdropProps;
|
|
22
|
+
containerProps?: PopoverContainerProps;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
26
|
+
function Popover(
|
|
27
|
+
{
|
|
28
|
+
portalSelector,
|
|
29
|
+
open,
|
|
30
|
+
anchorEl,
|
|
31
|
+
placement = 'bottom',
|
|
32
|
+
strategy = 'fixed',
|
|
33
|
+
modifiers,
|
|
34
|
+
skidding,
|
|
35
|
+
distance = 0,
|
|
36
|
+
offsetFn,
|
|
37
|
+
arrowPadding,
|
|
38
|
+
onClose,
|
|
39
|
+
children,
|
|
40
|
+
backdropProps,
|
|
41
|
+
containerProps,
|
|
42
|
+
disableBackdropClick,
|
|
43
|
+
disableEscapeKeyDown,
|
|
44
|
+
...otherProps
|
|
45
|
+
},
|
|
46
|
+
forwardedRef
|
|
47
|
+
) {
|
|
48
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!anchorEl || !anchorEl.current) {
|
|
51
|
+
console.warn(
|
|
52
|
+
'<Popover /> will not open because it does not have an anchor element defined'
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}, [anchorEl]);
|
|
56
|
+
|
|
57
|
+
if (!open || !anchorEl || !anchorEl.current) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Portal selector={portalSelector}>
|
|
63
|
+
<DialogBackdrop
|
|
64
|
+
onClose={onClose}
|
|
65
|
+
open={open}
|
|
66
|
+
disableCloseOnClick={disableBackdropClick}
|
|
67
|
+
disableEscapeKeyDown={disableEscapeKeyDown}
|
|
68
|
+
{...backdropProps}
|
|
69
|
+
>
|
|
70
|
+
<Popper
|
|
71
|
+
as={Box}
|
|
72
|
+
innerAs="div"
|
|
73
|
+
anchorEl={anchorEl}
|
|
74
|
+
placement={placement}
|
|
75
|
+
strategy={strategy}
|
|
76
|
+
modifiers={modifiers}
|
|
77
|
+
skidding={skidding}
|
|
78
|
+
distance={distance}
|
|
79
|
+
offsetFn={offsetFn}
|
|
80
|
+
arrowPadding={arrowPadding}
|
|
81
|
+
>
|
|
82
|
+
<PopoverContainer {...containerProps}>
|
|
83
|
+
<PopoverSurface
|
|
84
|
+
ref={assignMultipleRefs(forwardedRef, ref)}
|
|
85
|
+
{...otherProps}
|
|
86
|
+
>
|
|
87
|
+
{children}
|
|
88
|
+
</PopoverSurface>
|
|
89
|
+
</PopoverContainer>
|
|
90
|
+
</Popper>
|
|
91
|
+
</DialogBackdrop>
|
|
92
|
+
</Portal>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { BoxProps } from '../Box';
|
|
4
|
+
import { Box } from '../Box';
|
|
5
|
+
|
|
6
|
+
export type PopoverContainerProps = BoxProps;
|
|
7
|
+
|
|
8
|
+
export const PopoverContainer = forwardRef<HTMLDivElement, BoxProps>(
|
|
9
|
+
function PopoverContainer(props, forwardedRef) {
|
|
10
|
+
const { __css, ...otherProps } = props;
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Box
|
|
14
|
+
ref={forwardedRef}
|
|
15
|
+
__css={{
|
|
16
|
+
minWidth: ['100vw', 'auto'],
|
|
17
|
+
px: [3, 0],
|
|
18
|
+
pointerEvents: 'none',
|
|
19
|
+
...__css,
|
|
20
|
+
}}
|
|
21
|
+
{...otherProps}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { FC, Ref } from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import type { ModalProps } from '@basic-ui/core';
|
|
4
|
+
import { Modal as _Modal } from '@basic-ui/core';
|
|
5
|
+
import { get } from 'styled-system';
|
|
6
|
+
|
|
7
|
+
import type { PaperProps } from '../Paper';
|
|
8
|
+
import { Paper } from '../Paper';
|
|
9
|
+
import { useTheme } from '../theme';
|
|
10
|
+
import { growAnimation } from '../Menu';
|
|
11
|
+
import { EASING_STANDARD } from '../motion';
|
|
12
|
+
|
|
13
|
+
const Modal = _Modal as FC<PopoverSurfaceProps & { ref?: Ref<HTMLDivElement> }>;
|
|
14
|
+
|
|
15
|
+
export type PopoverSurfaceProps = ModalProps & PaperProps;
|
|
16
|
+
|
|
17
|
+
export const PopoverSurface = forwardRef<HTMLDivElement, PopoverSurfaceProps>(
|
|
18
|
+
function PopoverSurface(props, forwardedRef) {
|
|
19
|
+
const { __css, ...otherProps } = props;
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
|
|
22
|
+
const overlayValue =
|
|
23
|
+
(get(theme, 'dialogs.backgroundColorOverlay') as number) || 0;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Modal
|
|
27
|
+
ref={forwardedRef}
|
|
28
|
+
as={Paper}
|
|
29
|
+
theme={theme}
|
|
30
|
+
elevation={3}
|
|
31
|
+
darkThemeBackgroundOverlay={overlayValue}
|
|
32
|
+
__css={{
|
|
33
|
+
position: 'relative',
|
|
34
|
+
borderRadius: 'extra-small',
|
|
35
|
+
overflow: 'auto',
|
|
36
|
+
pointerEvents: 'auto',
|
|
37
|
+
willChange: 'transform,opacity',
|
|
38
|
+
'[data-popper-placement="top"] &': {
|
|
39
|
+
transformOrigin: 'bottom center',
|
|
40
|
+
},
|
|
41
|
+
'[data-popper-placement="bottom"] &': {
|
|
42
|
+
transformOrigin: 'top center',
|
|
43
|
+
},
|
|
44
|
+
animation: `${growAnimation} .12s ${EASING_STANDARD}`,
|
|
45
|
+
...__css,
|
|
46
|
+
}}
|
|
47
|
+
{...otherProps}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Popover';
|
package/src/Tooltip/Tooltip.tsx
CHANGED
|
@@ -22,7 +22,21 @@ const BaseTooltip: FC<
|
|
|
22
22
|
|
|
23
23
|
export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
24
24
|
function Tooltip(props, forwardedRef) {
|
|
25
|
-
const { placement = 'bottom', __css, ...otherProps } = props;
|
|
25
|
+
const { placement = 'bottom', children, __css, ...otherProps } = props;
|
|
26
|
+
const cssStyle = {
|
|
27
|
+
variant: ['text.body-medium', 'text.body-small'],
|
|
28
|
+
bg: alpha('#616161', 0.9),
|
|
29
|
+
color: '#fff',
|
|
30
|
+
px: 2,
|
|
31
|
+
py: 1,
|
|
32
|
+
borderRadius: 'extra-small',
|
|
33
|
+
zIndex: 'tooltip',
|
|
34
|
+
...__css,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
if (!children) {
|
|
38
|
+
return <Box ref={forwardedRef} __css={cssStyle} {...otherProps} />;
|
|
39
|
+
}
|
|
26
40
|
|
|
27
41
|
return (
|
|
28
42
|
<BaseTooltip
|
|
@@ -31,18 +45,11 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
31
45
|
ref={forwardedRef}
|
|
32
46
|
placement={placement}
|
|
33
47
|
distance={8}
|
|
34
|
-
__css={
|
|
35
|
-
variant: ['text.body-medium', 'text.body-small'],
|
|
36
|
-
bg: alpha('#616161', 0.9),
|
|
37
|
-
color: '#fff',
|
|
38
|
-
px: 2,
|
|
39
|
-
py: 1,
|
|
40
|
-
borderRadius: 'extra-small',
|
|
41
|
-
zIndex: 'tooltip',
|
|
42
|
-
...__css,
|
|
43
|
-
}}
|
|
48
|
+
__css={cssStyle}
|
|
44
49
|
{...otherProps}
|
|
45
|
-
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</BaseTooltip>
|
|
46
53
|
);
|
|
47
54
|
}
|
|
48
55
|
);
|
package/src/index.ts
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export function importGoogleFont(fonts) {
|
|
2
|
-
function addStylesheetURL(url) {
|
|
3
|
-
var link = document.createElement('link');
|
|
4
|
-
link.rel = 'stylesheet';
|
|
5
|
-
link.href = url;
|
|
6
|
-
document.getElementsByTagName('head')[0].appendChild(link);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
var fontStr = fonts.map(function (f) {
|
|
10
|
-
var family = f.family.split(/ +/).join('+');
|
|
11
|
-
|
|
12
|
-
if (f.weights && f.weights.length > 0) {
|
|
13
|
-
return family + ':' + f.weights.join(',');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return family;
|
|
17
|
-
}).join('|');
|
|
18
|
-
|
|
19
|
-
if (!fontStr) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
addStylesheetURL("https://fonts.googleapis.com/css?family=".concat(fontStr, "&display=swap"));
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=importGoogleFont.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"importGoogleFont.js","names":["importGoogleFont","fonts","addStylesheetURL","url","link","document","createElement","rel","href","getElementsByTagName","appendChild","fontStr","map","f","family","split","join","weights","length"],"sources":["../../../src/ThemeExplorer/importGoogleFont.ts"],"sourcesContent":["export function importGoogleFont(\n fonts: { family: string; weights?: number[] }[]\n) {\n function addStylesheetURL(url: string) {\n const link = document.createElement('link');\n link.rel = 'stylesheet';\n link.href = url;\n document.getElementsByTagName('head')[0].appendChild(link);\n }\n\n const fontStr = fonts\n .map((f) => {\n const family = f.family.split(/ +/).join('+');\n if (f.weights && f.weights.length > 0) {\n return family + ':' + f.weights.join(',');\n }\n return family;\n })\n .join('|');\n\n if (!fontStr) {\n return;\n }\n\n addStylesheetURL(\n `https://fonts.googleapis.com/css?family=${fontStr}&display=swap`\n );\n}\n"],"mappings":"AAAA,OAAO,SAASA,gBAAT,CACLC,KADK,EAEL;EACA,SAASC,gBAAT,CAA0BC,GAA1B,EAAuC;IACrC,IAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAT,CAAuB,MAAvB,CAAb;IACAF,IAAI,CAACG,GAAL,GAAW,YAAX;IACAH,IAAI,CAACI,IAAL,GAAYL,GAAZ;IACAE,QAAQ,CAACI,oBAAT,CAA8B,MAA9B,EAAsC,CAAtC,EAAyCC,WAAzC,CAAqDN,IAArD;EACD;;EAED,IAAMO,OAAO,GAAGV,KAAK,CAClBW,GADa,CACT,UAACC,CAAD,EAAO;IACV,IAAMC,MAAM,GAAGD,CAAC,CAACC,MAAF,CAASC,KAAT,CAAe,IAAf,EAAqBC,IAArB,CAA0B,GAA1B,CAAf;;IACA,IAAIH,CAAC,CAACI,OAAF,IAAaJ,CAAC,CAACI,OAAF,CAAUC,MAAV,GAAmB,CAApC,EAAuC;MACrC,OAAOJ,MAAM,GAAG,GAAT,GAAeD,CAAC,CAACI,OAAF,CAAUD,IAAV,CAAe,GAAf,CAAtB;IACD;;IACD,OAAOF,MAAP;EACD,CAPa,EAQbE,IARa,CAQR,GARQ,CAAhB;;EAUA,IAAI,CAACL,OAAL,EAAc;IACZ;EACD;;EAEDT,gBAAgB,mDAC6BS,OAD7B,mBAAhB;AAGD"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
export function extendColors(theme) {
|
|
3
|
-
var modifiedColors = {};
|
|
4
|
-
|
|
5
|
-
function extractColors(colors, arr) {
|
|
6
|
-
var root = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
7
|
-
|
|
8
|
-
for (var _i = 0, _Object$keys = Object.keys(colors); _i < _Object$keys.length; _i++) {
|
|
9
|
-
var _key = _Object$keys[_i];
|
|
10
|
-
|
|
11
|
-
if (_key === 'modes') {
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
var c = colors[_key];
|
|
16
|
-
|
|
17
|
-
if (typeof c === 'string') {
|
|
18
|
-
var varName = "--".concat(root + _key, "--rgb"); // arr[key.replace(/-/g, '_')] = `rgba(var(${varName}), <alpha-value>)`;
|
|
19
|
-
|
|
20
|
-
arr[_key] = "rgba(var(".concat(varName, "), <alpha-value>)");
|
|
21
|
-
} else if (_typeof(c) === 'object') {
|
|
22
|
-
var subColors = {};
|
|
23
|
-
extractColors(c, subColors, root + _key + '-');
|
|
24
|
-
arr[_key] = subColors;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
extractColors(theme.colors, modifiedColors);
|
|
30
|
-
return modifiedColors;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=makeTailwindTheme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"makeTailwindTheme.js","names":["extendColors","theme","modifiedColors","extractColors","colors","arr","root","Object","keys","key","c","varName","subColors"],"sources":["../../../src/tailwind/makeTailwindTheme.ts"],"sourcesContent":["import type { Theme } from '../theme/theme';\n\nexport type ColorsObject = { [key: string]: string | ColorsObject };\nexport function extendColors(theme: Theme): ColorsObject {\n const modifiedColors: ColorsObject = {};\n function extractColors(colors: ColorsObject, arr: ColorsObject, root = '') {\n for (const key of Object.keys(colors)) {\n if (key === 'modes') {\n continue;\n }\n\n const c = colors[key];\n if (typeof c === 'string') {\n const varName = `--${root + key}--rgb`;\n // arr[key.replace(/-/g, '_')] = `rgba(var(${varName}), <alpha-value>)`;\n arr[key] = `rgba(var(${varName}), <alpha-value>)`;\n } else if (typeof c === 'object') {\n const subColors: ColorsObject = {};\n extractColors(c, subColors, root + key + '-');\n arr[key] = subColors;\n }\n }\n }\n\n extractColors(theme.colors as any, modifiedColors);\n return modifiedColors;\n}\n"],"mappings":";AAGA,OAAO,SAASA,YAAT,CAAsBC,KAAtB,EAAkD;EACvD,IAAMC,cAA4B,GAAG,EAArC;;EACA,SAASC,aAAT,CAAuBC,MAAvB,EAA6CC,GAA7C,EAA2E;IAAA,IAAXC,IAAW,uEAAJ,EAAI;;IACzE,gCAAkBC,MAAM,CAACC,IAAP,CAAYJ,MAAZ,CAAlB,kCAAuC;MAAlC,IAAMK,IAAG,mBAAT;;MACH,IAAIA,IAAG,KAAK,OAAZ,EAAqB;QACnB;MACD;;MAED,IAAMC,CAAC,GAAGN,MAAM,CAACK,IAAD,CAAhB;;MACA,IAAI,OAAOC,CAAP,KAAa,QAAjB,EAA2B;QACzB,IAAMC,OAAO,eAAQL,IAAI,GAAGG,IAAf,UAAb,CADyB,CAEzB;;QACAJ,GAAG,CAACI,IAAD,CAAH,sBAAuBE,OAAvB;MACD,CAJD,MAIO,IAAI,QAAOD,CAAP,MAAa,QAAjB,EAA2B;QAChC,IAAME,SAAuB,GAAG,EAAhC;QACAT,aAAa,CAACO,CAAD,EAAIE,SAAJ,EAAeN,IAAI,GAAGG,IAAP,GAAa,GAA5B,CAAb;QACAJ,GAAG,CAACI,IAAD,CAAH,GAAWG,SAAX;MACD;IACF;EACF;;EAEDT,aAAa,CAACF,KAAK,CAACG,MAAP,EAAsBF,cAAtB,CAAb;EACA,OAAOA,cAAP;AACD"}
|