cherry-styled-components 0.1.0-3 → 0.1.0-5
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/.eslintrc.cjs +18 -0
- package/.prettierrc +11 -0
- package/index.html +13 -0
- package/package.json +1 -5
- package/src/App.tsx +93 -0
- package/src/lib/box.tsx +21 -0
- package/src/lib/button.tsx +159 -0
- package/src/lib/col.tsx +43 -0
- package/src/lib/container.tsx +64 -0
- package/src/lib/flex.tsx +95 -0
- package/src/lib/grid.tsx +70 -0
- package/src/lib/index.ts +15 -0
- package/src/lib/input.tsx +267 -0
- package/src/lib/max-width.tsx +43 -0
- package/src/lib/range.tsx +226 -0
- package/src/lib/select.tsx +127 -0
- package/src/lib/space.tsx +54 -0
- package/src/lib/styled-components/index.ts +2 -0
- package/src/lib/styled-components/registry.tsx +26 -0
- package/src/lib/styled-components/theme-provider.tsx +21 -0
- package/src/lib/textarea.tsx +103 -0
- package/src/lib/toggle.tsx +160 -0
- package/src/lib/utils/global.tsx +79 -0
- package/src/lib/utils/icons.tsx +165 -0
- package/src/lib/utils/index.ts +5 -0
- package/src/lib/utils/mixins.tsx +108 -0
- package/src/lib/utils/theme.ts +241 -0
- package/src/lib/utils/typography.tsx +204 -0
- package/src/main.tsx +14 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +24 -0
- package/vite.config.js +24 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: { browser: true, es2020: true },
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'plugin:react-hooks/recommended',
|
|
8
|
+
],
|
|
9
|
+
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
plugins: ['react-refresh'],
|
|
12
|
+
rules: {
|
|
13
|
+
'react-refresh/only-export-components': [
|
|
14
|
+
'warn',
|
|
15
|
+
{ allowConstantExport: true },
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
}
|
package/.prettierrc
ADDED
package/index.html
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React + TS</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cherry-styled-components",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
"./dist"
|
|
8
|
-
],
|
|
9
6
|
"main": "./dist/cherry.umd.cjs",
|
|
10
7
|
"module": "./dist/cherry.js",
|
|
11
8
|
"types": "./dist/lib/index.d.ts",
|
|
@@ -29,7 +26,6 @@
|
|
|
29
26
|
"format": "prettier --write \"./src/**/*.{js,json,ts,tsx}\" \"!.node_modules/**\""
|
|
30
27
|
},
|
|
31
28
|
"dependencies": {
|
|
32
|
-
"next": "^14.1.3",
|
|
33
29
|
"react": "^18",
|
|
34
30
|
"react-dom": "^18"
|
|
35
31
|
},
|
package/src/App.tsx
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
Col,
|
|
4
|
+
Flex,
|
|
5
|
+
Grid,
|
|
6
|
+
Input,
|
|
7
|
+
MaxWidth,
|
|
8
|
+
Range,
|
|
9
|
+
Select,
|
|
10
|
+
Space,
|
|
11
|
+
Textarea,
|
|
12
|
+
Toggle,
|
|
13
|
+
} from "./lib";
|
|
14
|
+
|
|
15
|
+
function App() {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<Space $size={100} />
|
|
19
|
+
<MaxWidth $xs={845}>
|
|
20
|
+
<Grid $xsCols={1} $lgCols={3} $gap={20}>
|
|
21
|
+
<Col $xsSpan={1} $lgSpan={2}>
|
|
22
|
+
<Grid $xsCols={1} $lgCols={2} $gap={20}>
|
|
23
|
+
<Input placeholder="Placeholder" $fullWidth />
|
|
24
|
+
<Select $fullWidth>
|
|
25
|
+
<option>Select</option>
|
|
26
|
+
</Select>
|
|
27
|
+
<Col $lgSpan={2}>
|
|
28
|
+
<Flex
|
|
29
|
+
$xsGap={10}
|
|
30
|
+
$lgGap={20}
|
|
31
|
+
$wrap="nowrap"
|
|
32
|
+
$justifyContent="space-between"
|
|
33
|
+
>
|
|
34
|
+
<Input type="checkbox" id="checkbox-1" />
|
|
35
|
+
<Input
|
|
36
|
+
type="checkbox"
|
|
37
|
+
id="checkbox-2"
|
|
38
|
+
defaultChecked
|
|
39
|
+
/>
|
|
40
|
+
<Input
|
|
41
|
+
type="radio"
|
|
42
|
+
id="radio-2"
|
|
43
|
+
name="demo-radio"
|
|
44
|
+
/>
|
|
45
|
+
<Input
|
|
46
|
+
type="radio"
|
|
47
|
+
id="radio-3"
|
|
48
|
+
name="demo-radio"
|
|
49
|
+
defaultChecked
|
|
50
|
+
/>
|
|
51
|
+
<Range />
|
|
52
|
+
<Toggle />
|
|
53
|
+
<Toggle defaultChecked />
|
|
54
|
+
</Flex>
|
|
55
|
+
</Col>
|
|
56
|
+
</Grid>
|
|
57
|
+
</Col>
|
|
58
|
+
<Textarea $fullWidth defaultValue="Textarea" />
|
|
59
|
+
</Grid>
|
|
60
|
+
<Space $size={20} />
|
|
61
|
+
<Grid $xsCols={1} $lgCols={2} $gap={20}>
|
|
62
|
+
<Col>
|
|
63
|
+
<Flex $wrap="nowrap" $gap={20}>
|
|
64
|
+
<Button $fullWidth>Button</Button>
|
|
65
|
+
<Button $variant="secondary" $fullWidth>
|
|
66
|
+
Button
|
|
67
|
+
</Button>
|
|
68
|
+
<Button $variant="tertiary" $fullWidth>
|
|
69
|
+
Button
|
|
70
|
+
</Button>
|
|
71
|
+
</Flex>
|
|
72
|
+
</Col>
|
|
73
|
+
<Col>
|
|
74
|
+
<Flex $wrap="nowrap" $gap={20}>
|
|
75
|
+
<Button $outline $fullWidth>
|
|
76
|
+
Button
|
|
77
|
+
</Button>
|
|
78
|
+
<Button $variant="secondary" $outline $fullWidth>
|
|
79
|
+
Button
|
|
80
|
+
</Button>
|
|
81
|
+
<Button $variant="tertiary" $outline $fullWidth>
|
|
82
|
+
Button
|
|
83
|
+
</Button>
|
|
84
|
+
</Flex>
|
|
85
|
+
</Col>
|
|
86
|
+
</Grid>
|
|
87
|
+
</MaxWidth>
|
|
88
|
+
<Space $size={100} />
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default App;
|
package/src/lib/box.tsx
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Container, ContainerProps } from "./container";
|
|
5
|
+
import { theme as defaultTheme } from "./utils";
|
|
6
|
+
|
|
7
|
+
const StylesBox = styled(Container)<ContainerProps>`
|
|
8
|
+
background: ${({ theme }) => theme.colors.light};
|
|
9
|
+
border-radius: ${({ theme }) => theme.spacing.radius.lg};
|
|
10
|
+
border: solid 1px ${({ theme }) => theme.colors.grayLight};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
function Box({ theme = defaultTheme, ...props }: ContainerProps) {
|
|
14
|
+
return (
|
|
15
|
+
<StylesBox {...props} theme={theme}>
|
|
16
|
+
{props.children}
|
|
17
|
+
</StylesBox>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { Box };
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled, { css } from "styled-components";
|
|
4
|
+
import {
|
|
5
|
+
theme as defaultTheme,
|
|
6
|
+
Theme,
|
|
7
|
+
formElementHeightStyles,
|
|
8
|
+
resetButton,
|
|
9
|
+
} from "./utils";
|
|
10
|
+
|
|
11
|
+
export interface ButtonProps
|
|
12
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
$variant?: "primary" | "secondary" | "tertiary";
|
|
15
|
+
$size?: "default" | "big";
|
|
16
|
+
$outline?: boolean;
|
|
17
|
+
$fullWidth?: boolean;
|
|
18
|
+
theme?: Theme;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const buttonStyles = (
|
|
22
|
+
theme: Theme,
|
|
23
|
+
$variant?: "primary" | "secondary" | "tertiary",
|
|
24
|
+
$size?: "default" | "big",
|
|
25
|
+
$outline?: boolean,
|
|
26
|
+
$fullWidth?: boolean,
|
|
27
|
+
disabled?: boolean,
|
|
28
|
+
) => css`
|
|
29
|
+
${resetButton};
|
|
30
|
+
font-family: inherit;
|
|
31
|
+
display: inline-block;
|
|
32
|
+
padding: 15px 30px;
|
|
33
|
+
border-radius: 100px;
|
|
34
|
+
font-weight: 600;
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
hyphens: auto;
|
|
37
|
+
color: ${theme.colors.light};
|
|
38
|
+
text-decoration: none;
|
|
39
|
+
transition: all 0.3s ease;
|
|
40
|
+
|
|
41
|
+
${!disabled &&
|
|
42
|
+
$variant === "primary" &&
|
|
43
|
+
css`
|
|
44
|
+
color: ${$outline ? theme.colors.primary : theme.colors.light};
|
|
45
|
+
background: ${$outline ? "transparent" : theme.colors.primary};
|
|
46
|
+
border: solid 2px ${theme.colors.primary};
|
|
47
|
+
box-shadow: 0 0 0 0px ${theme.colors.primary};
|
|
48
|
+
|
|
49
|
+
@media (hover: hover) {
|
|
50
|
+
&:hover {
|
|
51
|
+
background: ${$outline
|
|
52
|
+
? "transparent"
|
|
53
|
+
: theme.colors.primaryDark};
|
|
54
|
+
border-color: ${theme.colors.primaryDark};
|
|
55
|
+
${$outline && `color: ${theme.colors.primaryDark}`};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&:focus {
|
|
60
|
+
box-shadow: 0 0 0 4px ${theme.colors.primaryLight};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:active {
|
|
64
|
+
box-shadow: 0 0 0 2px ${theme.colors.primaryLight};
|
|
65
|
+
}
|
|
66
|
+
`}
|
|
67
|
+
|
|
68
|
+
${!disabled &&
|
|
69
|
+
$variant === "secondary" &&
|
|
70
|
+
css`
|
|
71
|
+
color: ${$outline ? theme.colors.secondary : theme.colors.light};
|
|
72
|
+
background: ${$outline ? "transparent" : theme.colors.secondary};
|
|
73
|
+
border: solid 2px ${theme.colors.secondary};
|
|
74
|
+
box-shadow: 0 0 0 0px ${theme.colors.secondary};
|
|
75
|
+
|
|
76
|
+
@media (hover: hover) {
|
|
77
|
+
&:hover {
|
|
78
|
+
background: ${$outline
|
|
79
|
+
? "transparent"
|
|
80
|
+
: theme.colors.secondaryDark};
|
|
81
|
+
border-color: ${theme.colors.secondaryDark};
|
|
82
|
+
${$outline && `color: ${theme.colors.secondaryDark}`};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&:focus {
|
|
87
|
+
box-shadow: 0 0 0 4px ${theme.colors.secondaryLight};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:active {
|
|
91
|
+
box-shadow: 0 0 0 2px ${theme.colors.secondaryLight};
|
|
92
|
+
}
|
|
93
|
+
`}
|
|
94
|
+
|
|
95
|
+
${!disabled &&
|
|
96
|
+
$variant === "tertiary" &&
|
|
97
|
+
css`
|
|
98
|
+
color: ${$outline ? theme.colors.tertiary : theme.colors.light};
|
|
99
|
+
background: ${$outline ? "transparent" : theme.colors.tertiary};
|
|
100
|
+
border: solid 2px ${theme.colors.tertiary};
|
|
101
|
+
box-shadow: 0 0 0 0px ${theme.colors.tertiary};
|
|
102
|
+
|
|
103
|
+
@media (hover: hover) {
|
|
104
|
+
&:hover {
|
|
105
|
+
background: ${$outline
|
|
106
|
+
? "transparent"
|
|
107
|
+
: theme.colors.tertiaryDark};
|
|
108
|
+
border-color: ${theme.colors.tertiaryDark};
|
|
109
|
+
${$outline && `color: ${theme.colors.tertiaryDark}`};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
&:focus {
|
|
114
|
+
box-shadow: 0 0 0 4px ${theme.colors.tertiaryLight};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&:active {
|
|
118
|
+
box-shadow: 0 0 0 2px ${theme.colors.tertiaryLight};
|
|
119
|
+
}
|
|
120
|
+
`}
|
|
121
|
+
|
|
122
|
+
${formElementHeightStyles($size)}
|
|
123
|
+
|
|
124
|
+
${$size === "big"
|
|
125
|
+
? `font-size: ${theme.fontSizes.buttonBig.lg};
|
|
126
|
+
line-height: ${theme.lineHeights.buttonBig.lg};
|
|
127
|
+
`
|
|
128
|
+
: `font-size: ${theme.fontSizes.button.lg};
|
|
129
|
+
line-height: ${theme.lineHeights.button.lg};`}
|
|
130
|
+
|
|
131
|
+
${disabled &&
|
|
132
|
+
`
|
|
133
|
+
cursor: not-allowed;
|
|
134
|
+
background: ${theme.colors.grayLight};
|
|
135
|
+
border-color: ${theme.colors.grayLight};
|
|
136
|
+
color: ${theme.colors.gray};
|
|
137
|
+
`}
|
|
138
|
+
|
|
139
|
+
${$fullWidth && `width: 100%;`}
|
|
140
|
+
`;
|
|
141
|
+
|
|
142
|
+
const StyledButton = styled.button<ButtonProps>`
|
|
143
|
+
${({ theme, $variant, $size, $outline, $fullWidth, disabled }) =>
|
|
144
|
+
buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
function Button({
|
|
148
|
+
theme = defaultTheme,
|
|
149
|
+
$variant = "primary",
|
|
150
|
+
...props
|
|
151
|
+
}: ButtonProps) {
|
|
152
|
+
return (
|
|
153
|
+
<StyledButton $variant={$variant} {...props} theme={theme}>
|
|
154
|
+
{props.children}
|
|
155
|
+
</StyledButton>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export { Button };
|
package/src/lib/col.tsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React 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 Col({ theme = defaultTheme, ...props }: ColProps) {
|
|
36
|
+
return (
|
|
37
|
+
<StyledCol {...props} theme={theme}>
|
|
38
|
+
{props.children}
|
|
39
|
+
</StyledCol>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { Col };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React 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 Container({ theme = defaultTheme, ...props }: ContainerProps) {
|
|
57
|
+
return (
|
|
58
|
+
<StyledContainer {...props} theme={theme}>
|
|
59
|
+
{props.children}
|
|
60
|
+
</StyledContainer>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { Container };
|
package/src/lib/flex.tsx
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import {
|
|
5
|
+
theme as defaultTheme,
|
|
6
|
+
Theme,
|
|
7
|
+
mq,
|
|
8
|
+
generateGapStyles,
|
|
9
|
+
generateJustifyContentStyles,
|
|
10
|
+
} from "./utils";
|
|
11
|
+
|
|
12
|
+
type JustifyContentType =
|
|
13
|
+
| "center"
|
|
14
|
+
| "flex-start"
|
|
15
|
+
| "flex-end"
|
|
16
|
+
| "space-between"
|
|
17
|
+
| "space-around"
|
|
18
|
+
| "space-evenly";
|
|
19
|
+
|
|
20
|
+
type GapType = number | "none";
|
|
21
|
+
|
|
22
|
+
interface FlexProps extends React.AllHTMLAttributes<FlexProps> {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
$justifyContent?: JustifyContentType;
|
|
25
|
+
$xsJustifyContent?: JustifyContentType;
|
|
26
|
+
$smJustifyContent?: JustifyContentType;
|
|
27
|
+
$mdJustifyContent?: JustifyContentType;
|
|
28
|
+
$lgJustifyContent?: JustifyContentType;
|
|
29
|
+
$xlJustifyContent?: JustifyContentType;
|
|
30
|
+
$xxlJustifyContent?: JustifyContentType;
|
|
31
|
+
$xxxlJustifyContent?: JustifyContentType;
|
|
32
|
+
$wrap?: "wrap" | "nowrap" | "wrap-reverse";
|
|
33
|
+
$gap?: GapType;
|
|
34
|
+
$xsGap?: GapType;
|
|
35
|
+
$smGap?: GapType;
|
|
36
|
+
$mdGap?: GapType;
|
|
37
|
+
$lgGap?: GapType;
|
|
38
|
+
$xlGap?: GapType;
|
|
39
|
+
$xxlGap?: GapType;
|
|
40
|
+
$xxxlGap?: GapType;
|
|
41
|
+
theme?: Theme;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const StyledFlex = styled.div<FlexProps>`
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: ${({ $justifyContent }) =>
|
|
47
|
+
$justifyContent || "flex-start"};
|
|
48
|
+
flex-wrap: ${({ $wrap }) => $wrap || "wrap"};
|
|
49
|
+
gap: ${({ $gap, theme }) =>
|
|
50
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.xs};
|
|
51
|
+
|
|
52
|
+
${mq("lg")} {
|
|
53
|
+
gap: ${({ $gap, theme }) =>
|
|
54
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.lg};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
${({ $xsGap }) => $xsGap && generateGapStyles("xs", $xsGap)}
|
|
58
|
+
${({ $xsJustifyContent }) =>
|
|
59
|
+
$xsJustifyContent &&
|
|
60
|
+
generateJustifyContentStyles("xs", $xsJustifyContent)}
|
|
61
|
+
${({ $smGap }) => $smGap && generateGapStyles("sm", $smGap)}
|
|
62
|
+
${({ $smJustifyContent }) =>
|
|
63
|
+
$smJustifyContent &&
|
|
64
|
+
generateJustifyContentStyles("sm", $smJustifyContent)}
|
|
65
|
+
${({ $mdGap }) => $mdGap && generateGapStyles("md", $mdGap)}
|
|
66
|
+
${({ $mdJustifyContent }) =>
|
|
67
|
+
$mdJustifyContent &&
|
|
68
|
+
generateJustifyContentStyles("md", $mdJustifyContent)}
|
|
69
|
+
${({ $lgGap }) => $lgGap && generateGapStyles("lg", $lgGap)}
|
|
70
|
+
${({ $lgJustifyContent }) =>
|
|
71
|
+
$lgJustifyContent &&
|
|
72
|
+
generateJustifyContentStyles("lg", $lgJustifyContent)}
|
|
73
|
+
${({ $xlGap }) => $xlGap && generateGapStyles("xl", $xlGap)}
|
|
74
|
+
${({ $xlJustifyContent }) =>
|
|
75
|
+
$xlJustifyContent &&
|
|
76
|
+
generateJustifyContentStyles("xl", $xlJustifyContent)}
|
|
77
|
+
${({ $xxlGap }) => $xxlGap && generateGapStyles("xxl", $xxlGap)}
|
|
78
|
+
${({ $xxlJustifyContent }) =>
|
|
79
|
+
$xxlJustifyContent &&
|
|
80
|
+
generateJustifyContentStyles("xxl", $xxlJustifyContent)}
|
|
81
|
+
${({ $xxxlGap }) => $xxxlGap && generateGapStyles("xxxl", $xxxlGap)}
|
|
82
|
+
${({ $xxxlJustifyContent }) =>
|
|
83
|
+
$xxxlJustifyContent &&
|
|
84
|
+
generateJustifyContentStyles("xxxl", $xxxlJustifyContent)}
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
function Flex({ theme = defaultTheme, ...props }: FlexProps) {
|
|
88
|
+
return (
|
|
89
|
+
<StyledFlex {...props} theme={theme}>
|
|
90
|
+
{props.children}
|
|
91
|
+
</StyledFlex>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { Flex };
|
package/src/lib/grid.tsx
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React 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
|
+
display: grid;
|
|
35
|
+
grid-template-columns: ${({ $cols }) =>
|
|
36
|
+
`repeat(${$cols || 3}, minmax(0, 1fr))`};
|
|
37
|
+
gap: ${({ $gap, theme }) =>
|
|
38
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.xs};
|
|
39
|
+
|
|
40
|
+
${mq("lg")} {
|
|
41
|
+
gap: ${({ $gap, theme }) =>
|
|
42
|
+
($gap && `${$gap}px`) || theme.spacing.gridGap.lg};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
${({ $xsGap }) => $xsGap && generateGapStyles("xs", $xsGap)}
|
|
46
|
+
${({ $smGap }) => $smGap && generateGapStyles("sm", $smGap)}
|
|
47
|
+
${({ $mdGap }) => $mdGap && generateGapStyles("md", $mdGap)}
|
|
48
|
+
${({ $lgGap }) => $lgGap && generateGapStyles("lg", $lgGap)}
|
|
49
|
+
${({ $xlGap }) => $xlGap && generateGapStyles("xl", $xlGap)}
|
|
50
|
+
${({ $xxlGap }) => $xxlGap && generateGapStyles("xxl", $xxlGap)}
|
|
51
|
+
${({ $xxxlGap }) => $xxxlGap && generateGapStyles("xxxl", $xxxlGap)}
|
|
52
|
+
|
|
53
|
+
${({ $xsCols }) => $xsCols && generateColsStyles("xs", $xsCols)}
|
|
54
|
+
${({ $smCols }) => $smCols && generateColsStyles("sm", $smCols)}
|
|
55
|
+
${({ $mdCols }) => $mdCols && generateColsStyles("md", $mdCols)}
|
|
56
|
+
${({ $lgCols }) => $lgCols && generateColsStyles("lg", $lgCols)}
|
|
57
|
+
${({ $xlCols }) => $xlCols && generateColsStyles("xl", $xlCols)}
|
|
58
|
+
${({ $xxlCols }) => $xxlCols && generateColsStyles("xxl", $xxlCols)}
|
|
59
|
+
${({ $xxxlCols }) => $xxxlCols && generateColsStyles("xxxl", $xxxlCols)}
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
function Grid({ theme = defaultTheme, ...props }: GridProps) {
|
|
63
|
+
return (
|
|
64
|
+
<StyledGrid {...props} theme={theme}>
|
|
65
|
+
{props.children}
|
|
66
|
+
</StyledGrid>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { Grid };
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +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";
|