cherry-styled-components 0.1.1 → 0.1.2
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/.claude/settings.local.json +1 -3
- package/.prettierignore +5 -0
- package/.prettierrc +2 -2
- package/.supermaven/config.json +6 -1
- package/dist/cherry.js +697 -613
- package/dist/cherry.umd.cjs +80 -80
- package/dist/lib/input.d.ts +1 -0
- package/dist/lib/range.d.ts +1 -0
- package/dist/lib/select.d.ts +1 -0
- package/dist/lib/textarea.d.ts +1 -0
- package/dist/lib/toggle.d.ts +1 -0
- package/package.json +2 -2
- package/src/App.tsx +101 -80
- package/src/lib/box.tsx +26 -26
- package/src/lib/button.tsx +162 -162
- package/src/lib/col.tsx +48 -45
- package/src/lib/container.tsx +69 -59
- package/src/lib/flex.tsx +99 -92
- package/src/lib/grid.tsx +76 -64
- package/src/lib/index.ts +15 -15
- package/src/lib/input.tsx +418 -384
- package/src/lib/max-width.tsx +53 -50
- package/src/lib/range.tsx +234 -208
- package/src/lib/select.tsx +136 -121
- package/src/lib/space.tsx +55 -52
- package/src/lib/styled-components/index.ts +2 -2
- package/src/lib/styled-components/registry.tsx +29 -26
- package/src/lib/styled-components/theme-provider.tsx +50 -49
- package/src/lib/textarea.tsx +115 -94
- package/src/lib/toggle.tsx +158 -147
- package/src/lib/utils/global.tsx +95 -95
- package/src/lib/utils/icons.tsx +84 -84
- package/src/lib/utils/index.ts +5 -5
- package/src/lib/utils/mixins.tsx +108 -95
- package/src/lib/utils/theme.ts +289 -289
- package/src/lib/utils/typography.tsx +204 -204
- package/src/main.tsx +19 -14
- package/src/toggle-theme.tsx +25 -25
- package/src/vite-env.d.ts +8 -8
- package/vite.config.js +18 -18
package/src/lib/col.tsx
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
import { theme as defaultTheme, Theme, generateColSpanStyles } from "./utils";
|
|
5
|
-
|
|
6
|
-
interface ColProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
$span?: number;
|
|
9
|
-
$xsSpan?: number;
|
|
10
|
-
$smSpan?: number;
|
|
11
|
-
$mdSpan?: number;
|
|
12
|
-
$lgSpan?: number;
|
|
13
|
-
$xlSpan?: number;
|
|
14
|
-
$xxlSpan?: number;
|
|
15
|
-
$xxxlSpan?: number;
|
|
16
|
-
theme?: Theme;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const StyledCol = styled.div<ColProps>`
|
|
20
|
-
${({ $span }) =>
|
|
21
|
-
$span &&
|
|
22
|
-
`
|
|
23
|
-
grid-column: span ${$span};
|
|
24
|
-
`}
|
|
25
|
-
|
|
26
|
-
${({ $xsSpan }) => $xsSpan && generateColSpanStyles("xs", $xsSpan)}
|
|
27
|
-
${({ $smSpan }) => $smSpan && generateColSpanStyles("sm", $smSpan)}
|
|
28
|
-
${({ $mdSpan }) => $mdSpan && generateColSpanStyles("md", $mdSpan)}
|
|
29
|
-
${({ $lgSpan }) => $lgSpan && generateColSpanStyles("lg", $lgSpan)}
|
|
30
|
-
${({ $xlSpan }) => $xlSpan && generateColSpanStyles("xl", $xlSpan)}
|
|
31
|
-
${({ $xxlSpan }) => $xxlSpan && generateColSpanStyles("xxl", $xxlSpan)}
|
|
32
|
-
${({ $xxxlSpan }) => $xxxlSpan && generateColSpanStyles("xxxl", $xxxlSpan)}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
function LocalCol(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { theme as defaultTheme, Theme, generateColSpanStyles } from "./utils";
|
|
5
|
+
|
|
6
|
+
interface ColProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
$span?: number;
|
|
9
|
+
$xsSpan?: number;
|
|
10
|
+
$smSpan?: number;
|
|
11
|
+
$mdSpan?: number;
|
|
12
|
+
$lgSpan?: number;
|
|
13
|
+
$xlSpan?: number;
|
|
14
|
+
$xxlSpan?: number;
|
|
15
|
+
$xxxlSpan?: number;
|
|
16
|
+
theme?: Theme;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const StyledCol = styled.div<ColProps>`
|
|
20
|
+
${({ $span }) =>
|
|
21
|
+
$span &&
|
|
22
|
+
`
|
|
23
|
+
grid-column: span ${$span};
|
|
24
|
+
`}
|
|
25
|
+
|
|
26
|
+
${({ $xsSpan }) => $xsSpan && generateColSpanStyles("xs", $xsSpan)}
|
|
27
|
+
${({ $smSpan }) => $smSpan && generateColSpanStyles("sm", $smSpan)}
|
|
28
|
+
${({ $mdSpan }) => $mdSpan && generateColSpanStyles("md", $mdSpan)}
|
|
29
|
+
${({ $lgSpan }) => $lgSpan && generateColSpanStyles("lg", $lgSpan)}
|
|
30
|
+
${({ $xlSpan }) => $xlSpan && generateColSpanStyles("xl", $xlSpan)}
|
|
31
|
+
${({ $xxlSpan }) => $xxlSpan && generateColSpanStyles("xxl", $xxlSpan)}
|
|
32
|
+
${({ $xxxlSpan }) => $xxxlSpan && generateColSpanStyles("xxxl", $xxxlSpan)}
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
function LocalCol(
|
|
36
|
+
{ theme = defaultTheme, ...props }: ColProps,
|
|
37
|
+
ref: React.Ref<HTMLDivElement>,
|
|
38
|
+
) {
|
|
39
|
+
return (
|
|
40
|
+
<StyledCol {...props} theme={theme} ref={ref}>
|
|
41
|
+
{props.children}
|
|
42
|
+
</StyledCol>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const Col = forwardRef(LocalCol);
|
|
47
|
+
|
|
48
|
+
export { Col };
|
package/src/lib/container.tsx
CHANGED
|
@@ -1,59 +1,69 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
$
|
|
15
|
-
$
|
|
16
|
-
$
|
|
17
|
-
$
|
|
18
|
-
$
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
${
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import {
|
|
5
|
+
theme as defaultTheme,
|
|
6
|
+
Theme,
|
|
7
|
+
mq,
|
|
8
|
+
generatePaddingStyles,
|
|
9
|
+
} from "./utils";
|
|
10
|
+
|
|
11
|
+
export interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
className?: string;
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
$fluid?: boolean;
|
|
15
|
+
$textAlign?: "right" | "left" | "center";
|
|
16
|
+
$padding?: number | "none";
|
|
17
|
+
$xsPadding?: number | "none";
|
|
18
|
+
$smPadding?: number | "none";
|
|
19
|
+
$mdPadding?: number | "none";
|
|
20
|
+
$lgPadding?: number | "none";
|
|
21
|
+
$xlPadding?: number | "none";
|
|
22
|
+
$xxlPadding?: number | "none";
|
|
23
|
+
$xxxlPadding?: number | "none";
|
|
24
|
+
theme?: Theme;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const StyledContainer = styled.div<ContainerProps>`
|
|
28
|
+
margin: auto;
|
|
29
|
+
width: 100%;
|
|
30
|
+
max-width: ${({ theme, $fluid }) =>
|
|
31
|
+
$fluid ? `100%` : theme.spacing.maxWidth.xs};
|
|
32
|
+
${({ $textAlign }) => $textAlign && `text-align: ${$textAlign}`};
|
|
33
|
+
padding: ${({ $padding, theme }) =>
|
|
34
|
+
($padding && `${$padding}px`) || theme.spacing.padding.xs};
|
|
35
|
+
|
|
36
|
+
${mq("lg")} {
|
|
37
|
+
padding: ${({ $padding, theme }) =>
|
|
38
|
+
($padding && `${$padding}px`) || theme.spacing.padding.lg};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${mq("xxxl")} {
|
|
42
|
+
max-width: ${({ theme, $fluid }) =>
|
|
43
|
+
$fluid ? `100%` : theme.spacing.maxWidth.xxxl};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
${({ $xsPadding }) => $xsPadding && generatePaddingStyles("xs", $xsPadding)}
|
|
47
|
+
${({ $smPadding }) => $smPadding && generatePaddingStyles("sm", $smPadding)}
|
|
48
|
+
${({ $mdPadding }) => $mdPadding && generatePaddingStyles("md", $mdPadding)}
|
|
49
|
+
${({ $lgPadding }) => $lgPadding && generatePaddingStyles("lg", $lgPadding)}
|
|
50
|
+
${({ $xlPadding }) => $xlPadding && generatePaddingStyles("xl", $xlPadding)}
|
|
51
|
+
${({ $xxlPadding }) => $xxlPadding && generatePaddingStyles("xxl", $xxlPadding)}
|
|
52
|
+
${({ $xxxlPadding }) =>
|
|
53
|
+
$xxxlPadding && generatePaddingStyles("xxxl", $xxxlPadding)}
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
function LocalContainer(
|
|
57
|
+
{ theme = defaultTheme, ...props }: ContainerProps,
|
|
58
|
+
ref: React.Ref<HTMLDivElement>,
|
|
59
|
+
) {
|
|
60
|
+
return (
|
|
61
|
+
<StyledContainer {...props} theme={theme} ref={ref}>
|
|
62
|
+
{props.children}
|
|
63
|
+
</StyledContainer>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const Container = forwardRef(LocalContainer);
|
|
68
|
+
|
|
69
|
+
export { Container };
|
package/src/lib/flex.tsx
CHANGED
|
@@ -1,92 +1,99 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
import {
|
|
5
|
-
theme as defaultTheme,
|
|
6
|
-
Theme,
|
|
7
|
-
mq,
|
|
8
|
-
generateGapStyles,
|
|
9
|
-
generateJustifyContentStyles,
|
|
10
|
-
fullWidthStyles,
|
|
11
|
-
} from "./utils";
|
|
12
|
-
|
|
13
|
-
type JustifyContentType =
|
|
14
|
-
| "center"
|
|
15
|
-
| "flex-start"
|
|
16
|
-
| "flex-end"
|
|
17
|
-
| "space-between"
|
|
18
|
-
| "space-around"
|
|
19
|
-
| "space-evenly";
|
|
20
|
-
|
|
21
|
-
type GapType = number | "none";
|
|
22
|
-
|
|
23
|
-
interface FlexProps extends React.AllHTMLAttributes<FlexProps> {
|
|
24
|
-
children?: React.ReactNode;
|
|
25
|
-
$justifyContent?: JustifyContentType;
|
|
26
|
-
$xsJustifyContent?: JustifyContentType;
|
|
27
|
-
$smJustifyContent?: JustifyContentType;
|
|
28
|
-
$mdJustifyContent?: JustifyContentType;
|
|
29
|
-
$lgJustifyContent?: JustifyContentType;
|
|
30
|
-
$xlJustifyContent?: JustifyContentType;
|
|
31
|
-
$xxlJustifyContent?: JustifyContentType;
|
|
32
|
-
$xxxlJustifyContent?: JustifyContentType;
|
|
33
|
-
$wrap?: "wrap" | "nowrap" | "wrap-reverse";
|
|
34
|
-
$gap?: GapType;
|
|
35
|
-
$xsGap?: GapType;
|
|
36
|
-
$smGap?: GapType;
|
|
37
|
-
$mdGap?: GapType;
|
|
38
|
-
$lgGap?: GapType;
|
|
39
|
-
$xlGap?: GapType;
|
|
40
|
-
$xxlGap?: GapType;
|
|
41
|
-
$xxxlGap?: GapType;
|
|
42
|
-
$direction?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
43
|
-
$fullWidth?: boolean;
|
|
44
|
-
theme?: Theme;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const StyledFlex = styled.div<FlexProps>`
|
|
48
|
-
display: flex;
|
|
49
|
-
justify-content: ${({ $justifyContent }) => $justifyContent || "flex-start"};
|
|
50
|
-
flex-wrap: ${({ $wrap }) => $wrap || "wrap"};
|
|
51
|
-
gap: ${({ $gap, theme }) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
${({ $
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
${({ $
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
${({ $
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
${({ $
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
${({ $
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import {
|
|
5
|
+
theme as defaultTheme,
|
|
6
|
+
Theme,
|
|
7
|
+
mq,
|
|
8
|
+
generateGapStyles,
|
|
9
|
+
generateJustifyContentStyles,
|
|
10
|
+
fullWidthStyles,
|
|
11
|
+
} from "./utils";
|
|
12
|
+
|
|
13
|
+
type JustifyContentType =
|
|
14
|
+
| "center"
|
|
15
|
+
| "flex-start"
|
|
16
|
+
| "flex-end"
|
|
17
|
+
| "space-between"
|
|
18
|
+
| "space-around"
|
|
19
|
+
| "space-evenly";
|
|
20
|
+
|
|
21
|
+
type GapType = number | "none";
|
|
22
|
+
|
|
23
|
+
interface FlexProps extends React.AllHTMLAttributes<FlexProps> {
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
$justifyContent?: JustifyContentType;
|
|
26
|
+
$xsJustifyContent?: JustifyContentType;
|
|
27
|
+
$smJustifyContent?: JustifyContentType;
|
|
28
|
+
$mdJustifyContent?: JustifyContentType;
|
|
29
|
+
$lgJustifyContent?: JustifyContentType;
|
|
30
|
+
$xlJustifyContent?: JustifyContentType;
|
|
31
|
+
$xxlJustifyContent?: JustifyContentType;
|
|
32
|
+
$xxxlJustifyContent?: JustifyContentType;
|
|
33
|
+
$wrap?: "wrap" | "nowrap" | "wrap-reverse";
|
|
34
|
+
$gap?: GapType;
|
|
35
|
+
$xsGap?: GapType;
|
|
36
|
+
$smGap?: GapType;
|
|
37
|
+
$mdGap?: GapType;
|
|
38
|
+
$lgGap?: GapType;
|
|
39
|
+
$xlGap?: GapType;
|
|
40
|
+
$xxlGap?: GapType;
|
|
41
|
+
$xxxlGap?: GapType;
|
|
42
|
+
$direction?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
43
|
+
$fullWidth?: boolean;
|
|
44
|
+
theme?: Theme;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const StyledFlex = styled.div<FlexProps>`
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: ${({ $justifyContent }) => $justifyContent || "flex-start"};
|
|
50
|
+
flex-wrap: ${({ $wrap }) => $wrap || "wrap"};
|
|
51
|
+
gap: ${({ $gap, theme }) =>
|
|
52
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.xs};
|
|
53
|
+
flex-direction: ${({ $direction }) => $direction || "row"};
|
|
54
|
+
|
|
55
|
+
${mq("lg")} {
|
|
56
|
+
gap: ${({ $gap, theme }) =>
|
|
57
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.lg};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
${({ $xsGap }) => $xsGap && generateGapStyles("xs", $xsGap)}
|
|
61
|
+
${({ $xsJustifyContent }) =>
|
|
62
|
+
$xsJustifyContent && generateJustifyContentStyles("xs", $xsJustifyContent)}
|
|
63
|
+
${({ $smGap }) => $smGap && generateGapStyles("sm", $smGap)}
|
|
64
|
+
${({ $smJustifyContent }) =>
|
|
65
|
+
$smJustifyContent && generateJustifyContentStyles("sm", $smJustifyContent)}
|
|
66
|
+
${({ $mdGap }) => $mdGap && generateGapStyles("md", $mdGap)}
|
|
67
|
+
${({ $mdJustifyContent }) =>
|
|
68
|
+
$mdJustifyContent && generateJustifyContentStyles("md", $mdJustifyContent)}
|
|
69
|
+
${({ $lgGap }) => $lgGap && generateGapStyles("lg", $lgGap)}
|
|
70
|
+
${({ $lgJustifyContent }) =>
|
|
71
|
+
$lgJustifyContent && generateJustifyContentStyles("lg", $lgJustifyContent)}
|
|
72
|
+
${({ $xlGap }) => $xlGap && generateGapStyles("xl", $xlGap)}
|
|
73
|
+
${({ $xlJustifyContent }) =>
|
|
74
|
+
$xlJustifyContent && generateJustifyContentStyles("xl", $xlJustifyContent)}
|
|
75
|
+
${({ $xxlGap }) => $xxlGap && generateGapStyles("xxl", $xxlGap)}
|
|
76
|
+
${({ $xxlJustifyContent }) =>
|
|
77
|
+
$xxlJustifyContent &&
|
|
78
|
+
generateJustifyContentStyles("xxl", $xxlJustifyContent)}
|
|
79
|
+
${({ $xxxlGap }) => $xxxlGap && generateGapStyles("xxxl", $xxxlGap)}
|
|
80
|
+
${({ $xxxlJustifyContent }) =>
|
|
81
|
+
$xxxlJustifyContent &&
|
|
82
|
+
generateJustifyContentStyles("xxxl", $xxxlJustifyContent)}
|
|
83
|
+
${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
function LocalFlex(
|
|
87
|
+
{ theme = defaultTheme, ...props }: FlexProps,
|
|
88
|
+
ref: React.Ref<HTMLDivElement>,
|
|
89
|
+
) {
|
|
90
|
+
return (
|
|
91
|
+
<StyledFlex {...props} theme={theme} ref={ref}>
|
|
92
|
+
{props.children}
|
|
93
|
+
</StyledFlex>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const Flex = forwardRef(LocalFlex);
|
|
98
|
+
|
|
99
|
+
export { Flex };
|
package/src/lib/grid.tsx
CHANGED
|
@@ -1,64 +1,76 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
$
|
|
15
|
-
$
|
|
16
|
-
$
|
|
17
|
-
$
|
|
18
|
-
$
|
|
19
|
-
$
|
|
20
|
-
$
|
|
21
|
-
$
|
|
22
|
-
$
|
|
23
|
-
$
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
${({ $
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
${({ $
|
|
49
|
-
${({ $
|
|
50
|
-
${({ $
|
|
51
|
-
${({ $
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import {
|
|
5
|
+
theme as defaultTheme,
|
|
6
|
+
Theme,
|
|
7
|
+
mq,
|
|
8
|
+
generateColsStyles,
|
|
9
|
+
generateGapStyles,
|
|
10
|
+
} from "./utils";
|
|
11
|
+
|
|
12
|
+
interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
$gap?: number | "none";
|
|
15
|
+
$xsGap?: number | "none";
|
|
16
|
+
$smGap?: number | "none";
|
|
17
|
+
$mdGap?: number | "none";
|
|
18
|
+
$lgGap?: number | "none";
|
|
19
|
+
$xlGap?: number | "none";
|
|
20
|
+
$xxlGap?: number | "none";
|
|
21
|
+
$xxxlGap?: number | "none";
|
|
22
|
+
$cols?: number;
|
|
23
|
+
$xsCols?: number;
|
|
24
|
+
$smCols?: number;
|
|
25
|
+
$mdCols?: number;
|
|
26
|
+
$lgCols?: number;
|
|
27
|
+
$xlCols?: number;
|
|
28
|
+
$xxlCols?: number;
|
|
29
|
+
$xxxlCols?: number;
|
|
30
|
+
theme?: Theme;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const StyledGrid = styled.div<GridProps>`
|
|
34
|
+
width: 100%;
|
|
35
|
+
display: grid;
|
|
36
|
+
grid-template-columns: ${({ $cols }) =>
|
|
37
|
+
`repeat(${$cols || 3}, minmax(0, 1fr))`};
|
|
38
|
+
gap: ${({ $gap, theme }) =>
|
|
39
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.xs};
|
|
40
|
+
|
|
41
|
+
${mq("lg")} {
|
|
42
|
+
gap: ${({ $gap, theme }) =>
|
|
43
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.lg};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
${({ $xsGap }) => $xsGap && generateGapStyles("xs", $xsGap)}
|
|
47
|
+
${({ $smGap }) => $smGap && generateGapStyles("sm", $smGap)}
|
|
48
|
+
${({ $mdGap }) => $mdGap && generateGapStyles("md", $mdGap)}
|
|
49
|
+
${({ $lgGap }) => $lgGap && generateGapStyles("lg", $lgGap)}
|
|
50
|
+
${({ $xlGap }) => $xlGap && generateGapStyles("xl", $xlGap)}
|
|
51
|
+
${({ $xxlGap }) => $xxlGap && generateGapStyles("xxl", $xxlGap)}
|
|
52
|
+
${({ $xxxlGap }) => $xxxlGap && generateGapStyles("xxxl", $xxxlGap)}
|
|
53
|
+
|
|
54
|
+
${({ $xsCols }) => $xsCols && generateColsStyles("xs", $xsCols)}
|
|
55
|
+
${({ $smCols }) => $smCols && generateColsStyles("sm", $smCols)}
|
|
56
|
+
${({ $mdCols }) => $mdCols && generateColsStyles("md", $mdCols)}
|
|
57
|
+
${({ $lgCols }) => $lgCols && generateColsStyles("lg", $lgCols)}
|
|
58
|
+
${({ $xlCols }) => $xlCols && generateColsStyles("xl", $xlCols)}
|
|
59
|
+
${({ $xxlCols }) => $xxlCols && generateColsStyles("xxl", $xxlCols)}
|
|
60
|
+
${({ $xxxlCols }) => $xxxlCols && generateColsStyles("xxxl", $xxxlCols)}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
function LocalGrid(
|
|
64
|
+
{ theme = defaultTheme, ...props }: GridProps,
|
|
65
|
+
ref: React.Ref<HTMLDivElement>,
|
|
66
|
+
) {
|
|
67
|
+
return (
|
|
68
|
+
<StyledGrid {...props} theme={theme} ref={ref}>
|
|
69
|
+
{props.children}
|
|
70
|
+
</StyledGrid>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const Grid = forwardRef(LocalGrid);
|
|
75
|
+
|
|
76
|
+
export { Grid };
|
package/src/lib/index.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from "./styled-components";
|
|
2
|
-
export * from "./utils";
|
|
3
|
-
export * from "./box";
|
|
4
|
-
export * from "./button";
|
|
5
|
-
export * from "./col";
|
|
6
|
-
export * from "./container";
|
|
7
|
-
export * from "./flex";
|
|
8
|
-
export * from "./grid";
|
|
9
|
-
export * from "./input";
|
|
10
|
-
export * from "./max-width";
|
|
11
|
-
export * from "./range";
|
|
12
|
-
export * from "./select";
|
|
13
|
-
export * from "./space";
|
|
14
|
-
export * from "./textarea";
|
|
15
|
-
export * from "./toggle";
|
|
1
|
+
export * from "./styled-components";
|
|
2
|
+
export * from "./utils";
|
|
3
|
+
export * from "./box";
|
|
4
|
+
export * from "./button";
|
|
5
|
+
export * from "./col";
|
|
6
|
+
export * from "./container";
|
|
7
|
+
export * from "./flex";
|
|
8
|
+
export * from "./grid";
|
|
9
|
+
export * from "./input";
|
|
10
|
+
export * from "./max-width";
|
|
11
|
+
export * from "./range";
|
|
12
|
+
export * from "./select";
|
|
13
|
+
export * from "./space";
|
|
14
|
+
export * from "./textarea";
|
|
15
|
+
export * from "./toggle";
|