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/dist/lib/input.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IStyledComponent } from 'styled-components';
|
|
|
3
3
|
import { Theme } from './utils';
|
|
4
4
|
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
|
+
$wrapperClassName?: string;
|
|
6
7
|
$label?: string;
|
|
7
8
|
$size?: "default" | "big";
|
|
8
9
|
$error?: boolean;
|
package/dist/lib/range.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { Theme } from './utils';
|
|
3
3
|
interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
4
4
|
className?: string;
|
|
5
|
+
$wrapperClassName?: string;
|
|
5
6
|
$label?: string;
|
|
6
7
|
$size?: "default" | "big";
|
|
7
8
|
$error?: boolean;
|
package/dist/lib/select.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IStyledComponent } from 'styled-components';
|
|
|
3
3
|
import { Theme } from './utils';
|
|
4
4
|
interface SelectProps extends React.InputHTMLAttributes<HTMLSelectElement> {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
|
+
$wrapperClassName?: string;
|
|
6
7
|
$label?: string;
|
|
7
8
|
$size?: "default" | "big";
|
|
8
9
|
$error?: boolean;
|
package/dist/lib/textarea.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { Theme } from './utils';
|
|
3
3
|
interface TextareaProps extends Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "size"> {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
+
$wrapperClassName?: string;
|
|
5
6
|
$label?: string;
|
|
6
7
|
$size?: "default" | "big";
|
|
7
8
|
$error?: boolean;
|
package/dist/lib/toggle.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cherry-styled-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Cherry is a design system for the modern web. Designed in Figma, built in React using Typescript.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"dev": "vite dev",
|
|
28
28
|
"build": "vite build",
|
|
29
|
-
"format": "prettier --write \"
|
|
29
|
+
"format": "prettier --write \"./**/*.{js,json,ts,tsx}\""
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"react": "^19",
|
package/src/App.tsx
CHANGED
|
@@ -1,80 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Container,
|
|
3
|
-
Button,
|
|
4
|
-
Col,
|
|
5
|
-
Flex,
|
|
6
|
-
Grid,
|
|
7
|
-
Input,
|
|
8
|
-
MaxWidth,
|
|
9
|
-
Range,
|
|
10
|
-
Select,
|
|
11
|
-
Space,
|
|
12
|
-
Textarea,
|
|
13
|
-
Toggle,
|
|
14
|
-
} from "./lib";
|
|
15
|
-
import { ToggleTheme } from "./toggle-theme";
|
|
16
|
-
|
|
17
|
-
function App() {
|
|
18
|
-
return (
|
|
19
|
-
<Container>
|
|
20
|
-
<Space $size={100} />
|
|
21
|
-
<MaxWidth $xs={845}>
|
|
22
|
-
<ToggleTheme />
|
|
23
|
-
<hr />
|
|
24
|
-
<Input $fullWidth $label="Input" id="data-1" type="date" />
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
import {
|
|
2
|
+
Container,
|
|
3
|
+
Button,
|
|
4
|
+
Col,
|
|
5
|
+
Flex,
|
|
6
|
+
Grid,
|
|
7
|
+
Input,
|
|
8
|
+
MaxWidth,
|
|
9
|
+
Range,
|
|
10
|
+
Select,
|
|
11
|
+
Space,
|
|
12
|
+
Textarea,
|
|
13
|
+
Toggle,
|
|
14
|
+
} from "./lib";
|
|
15
|
+
import { ToggleTheme } from "./toggle-theme";
|
|
16
|
+
|
|
17
|
+
function App() {
|
|
18
|
+
return (
|
|
19
|
+
<Container>
|
|
20
|
+
<Space $size={100} />
|
|
21
|
+
<MaxWidth $xs={845}>
|
|
22
|
+
<ToggleTheme />
|
|
23
|
+
<hr />
|
|
24
|
+
<Input $fullWidth $label="Input" id="data-1" type="date" />
|
|
25
|
+
<Space $size={20} />
|
|
26
|
+
<Grid $xsCols={1} $lgCols={3} $gap={20}>
|
|
27
|
+
<Col $xsSpan={1} $lgSpan={2}>
|
|
28
|
+
<Grid $xsCols={1} $lgCols={2} $gap={20}>
|
|
29
|
+
<Input
|
|
30
|
+
placeholder="Placeholder"
|
|
31
|
+
$fullWidth
|
|
32
|
+
$label="Input"
|
|
33
|
+
id="input-1"
|
|
34
|
+
/>
|
|
35
|
+
<Select $fullWidth $label="Select" id="select-1">
|
|
36
|
+
<option>Select</option>
|
|
37
|
+
</Select>
|
|
38
|
+
<Col $lgSpan={2}>
|
|
39
|
+
<Flex
|
|
40
|
+
$xsGap={10}
|
|
41
|
+
$lgGap={20}
|
|
42
|
+
$wrap="nowrap"
|
|
43
|
+
$justifyContent="space-between"
|
|
44
|
+
>
|
|
45
|
+
<Input type="checkbox" id="checkbox-1" />
|
|
46
|
+
<Input type="checkbox" id="checkbox-2" defaultChecked />
|
|
47
|
+
<Input type="radio" id="radio-2" name="demo-radio" />
|
|
48
|
+
<Input
|
|
49
|
+
type="radio"
|
|
50
|
+
id="radio-3"
|
|
51
|
+
name="demo-radio"
|
|
52
|
+
defaultChecked
|
|
53
|
+
/>
|
|
54
|
+
<Range />
|
|
55
|
+
<Toggle />
|
|
56
|
+
<Toggle defaultChecked />
|
|
57
|
+
</Flex>
|
|
58
|
+
</Col>
|
|
59
|
+
</Grid>
|
|
60
|
+
</Col>
|
|
61
|
+
<Textarea
|
|
62
|
+
$label="Textarea"
|
|
63
|
+
$fullWidth
|
|
64
|
+
defaultValue="Textarea"
|
|
65
|
+
id="textarea-1"
|
|
66
|
+
/>
|
|
67
|
+
</Grid>
|
|
68
|
+
<Space $size={20} />
|
|
69
|
+
<Grid $xsCols={1} $lgCols={2} $gap={20}>
|
|
70
|
+
<Col>
|
|
71
|
+
<Flex $wrap="nowrap" $gap={20}>
|
|
72
|
+
<Button $fullWidth>Button</Button>
|
|
73
|
+
<Button $variant="secondary" $fullWidth>
|
|
74
|
+
Button
|
|
75
|
+
</Button>
|
|
76
|
+
<Button $variant="tertiary" $fullWidth>
|
|
77
|
+
Button
|
|
78
|
+
</Button>
|
|
79
|
+
</Flex>
|
|
80
|
+
</Col>
|
|
81
|
+
<Col>
|
|
82
|
+
<Flex $wrap="nowrap" $gap={20}>
|
|
83
|
+
<Button $outline $fullWidth>
|
|
84
|
+
Button
|
|
85
|
+
</Button>
|
|
86
|
+
<Button $variant="secondary" $outline $fullWidth>
|
|
87
|
+
Button
|
|
88
|
+
</Button>
|
|
89
|
+
<Button $variant="tertiary" $outline $fullWidth>
|
|
90
|
+
Button
|
|
91
|
+
</Button>
|
|
92
|
+
</Flex>
|
|
93
|
+
</Col>
|
|
94
|
+
</Grid>
|
|
95
|
+
</MaxWidth>
|
|
96
|
+
<Space $size={100} />
|
|
97
|
+
</Container>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default App;
|
package/src/lib/box.tsx
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import styled from "styled-components";
|
|
4
|
-
import { Container, ContainerProps } from "./container";
|
|
5
|
-
import { theme as defaultTheme } from "./utils";
|
|
6
|
-
|
|
7
|
-
const StyledBox = 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 LocalBox(
|
|
14
|
-
{ theme = defaultTheme, ...props }: ContainerProps,
|
|
15
|
-
ref: React.Ref<HTMLDivElement>,
|
|
16
|
-
) {
|
|
17
|
-
return (
|
|
18
|
-
<StyledBox {...props} theme={theme} ref={ref}>
|
|
19
|
-
{props.children}
|
|
20
|
-
</StyledBox>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const Box = forwardRef(LocalBox);
|
|
25
|
-
|
|
26
|
-
export { Box };
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Container, ContainerProps } from "./container";
|
|
5
|
+
import { theme as defaultTheme } from "./utils";
|
|
6
|
+
|
|
7
|
+
const StyledBox = 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 LocalBox(
|
|
14
|
+
{ theme = defaultTheme, ...props }: ContainerProps,
|
|
15
|
+
ref: React.Ref<HTMLDivElement>,
|
|
16
|
+
) {
|
|
17
|
+
return (
|
|
18
|
+
<StyledBox {...props} theme={theme} ref={ref}>
|
|
19
|
+
{props.children}
|
|
20
|
+
</StyledBox>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Box = forwardRef(LocalBox);
|
|
25
|
+
|
|
26
|
+
export { Box };
|
package/src/lib/button.tsx
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import React, { forwardRef } from "react";
|
|
3
|
-
import styled, { css } from "styled-components";
|
|
4
|
-
import { Theme, formElementHeightStyles, resetButton } from "./utils";
|
|
5
|
-
|
|
6
|
-
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
$variant?: "primary" | "secondary" | "tertiary";
|
|
9
|
-
$size?: "default" | "big";
|
|
10
|
-
$outline?: boolean;
|
|
11
|
-
$fullWidth?: boolean;
|
|
12
|
-
$icon?: React.ReactNode;
|
|
13
|
-
$iconPosition?: "left" | "right";
|
|
14
|
-
theme?: Theme;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const buttonStyles = (
|
|
18
|
-
theme: Theme,
|
|
19
|
-
$variant?: "primary" | "secondary" | "tertiary",
|
|
20
|
-
$size?: "default" | "big",
|
|
21
|
-
$outline?: boolean,
|
|
22
|
-
$fullWidth?: boolean,
|
|
23
|
-
disabled?: boolean,
|
|
24
|
-
) => css`
|
|
25
|
-
${resetButton};
|
|
26
|
-
font-family: inherit;
|
|
27
|
-
display: inline-flex;
|
|
28
|
-
padding: 15px 30px;
|
|
29
|
-
border-radius: 100px;
|
|
30
|
-
font-weight: 600;
|
|
31
|
-
white-space: nowrap;
|
|
32
|
-
hyphens: auto;
|
|
33
|
-
color: ${theme.isDark ? theme.colors.dark : theme.colors.light};
|
|
34
|
-
text-decoration: none;
|
|
35
|
-
transition: all 0.3s ease;
|
|
36
|
-
text-align: center;
|
|
37
|
-
gap: 10px;
|
|
38
|
-
text-overflow: ellipsis;
|
|
39
|
-
justify-content: center;
|
|
40
|
-
|
|
41
|
-
& .icon,
|
|
42
|
-
& .lucide {
|
|
43
|
-
margin: auto 0;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
${!disabled &&
|
|
47
|
-
$variant === "primary" &&
|
|
48
|
-
css`
|
|
49
|
-
color: ${$outline ? theme.colors.primary : theme.colors.light};
|
|
50
|
-
background: ${$outline ? "transparent" : theme.colors.primary};
|
|
51
|
-
border: solid 2px ${theme.colors.primary};
|
|
52
|
-
box-shadow: 0 0 0 0px ${theme.colors.primary};
|
|
53
|
-
|
|
54
|
-
@media (hover: hover) {
|
|
55
|
-
&:hover {
|
|
56
|
-
background: ${$outline ? "transparent" : theme.colors.primaryDark};
|
|
57
|
-
border-color: ${theme.colors.primaryDark};
|
|
58
|
-
${$outline && `color: ${theme.colors.primaryDark}`};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&:focus {
|
|
63
|
-
box-shadow: 0 0 0 4px ${theme.colors.primaryLight};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&:active {
|
|
67
|
-
box-shadow: 0 0 0 2px ${theme.colors.primaryLight};
|
|
68
|
-
}
|
|
69
|
-
`}
|
|
70
|
-
|
|
71
|
-
${!disabled &&
|
|
72
|
-
$variant === "secondary" &&
|
|
73
|
-
css`
|
|
74
|
-
color: ${$outline ? theme.colors.secondary : theme.colors.light};
|
|
75
|
-
background: ${$outline ? "transparent" : theme.colors.secondary};
|
|
76
|
-
border: solid 2px ${theme.colors.secondary};
|
|
77
|
-
box-shadow: 0 0 0 0px ${theme.colors.secondary};
|
|
78
|
-
|
|
79
|
-
@media (hover: hover) {
|
|
80
|
-
&:hover {
|
|
81
|
-
background: ${$outline ? "transparent" : theme.colors.secondaryDark};
|
|
82
|
-
border-color: ${theme.colors.secondaryDark};
|
|
83
|
-
${$outline && `color: ${theme.colors.secondaryDark}`};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
&:focus {
|
|
88
|
-
box-shadow: 0 0 0 4px ${theme.colors.secondaryLight};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&:active {
|
|
92
|
-
box-shadow: 0 0 0 2px ${theme.colors.secondaryLight};
|
|
93
|
-
}
|
|
94
|
-
`}
|
|
95
|
-
|
|
96
|
-
${!disabled &&
|
|
97
|
-
$variant === "tertiary" &&
|
|
98
|
-
css`
|
|
99
|
-
color: ${$outline ? theme.colors.tertiary : theme.colors.light};
|
|
100
|
-
background: ${$outline ? "transparent" : theme.colors.tertiary};
|
|
101
|
-
border: solid 2px ${theme.colors.tertiary};
|
|
102
|
-
box-shadow: 0 0 0 0px ${theme.colors.tertiary};
|
|
103
|
-
|
|
104
|
-
@media (hover: hover) {
|
|
105
|
-
&:hover {
|
|
106
|
-
background: ${$outline ? "transparent" : theme.colors.tertiaryDark};
|
|
107
|
-
border-color: ${theme.colors.tertiaryDark};
|
|
108
|
-
${$outline && `color: ${theme.colors.tertiaryDark}`};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
&:focus {
|
|
113
|
-
box-shadow: 0 0 0 4px ${theme.colors.tertiaryLight};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
&:active {
|
|
117
|
-
box-shadow: 0 0 0 2px ${theme.colors.tertiaryLight};
|
|
118
|
-
}
|
|
119
|
-
`}
|
|
120
|
-
|
|
121
|
-
${formElementHeightStyles($size)}
|
|
122
|
-
|
|
123
|
-
${$size === "big"
|
|
124
|
-
? `font-size: ${theme.fontSizes.buttonBig.lg};
|
|
125
|
-
line-height: ${theme.lineHeights.buttonBig.lg};
|
|
126
|
-
padding: 18px 30px;
|
|
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: solid 2px ${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 LocalButton(
|
|
148
|
-
{ $variant = "primary", ...props }: ButtonProps,
|
|
149
|
-
ref: React.Ref<HTMLButtonElement>,
|
|
150
|
-
) {
|
|
151
|
-
return (
|
|
152
|
-
<StyledButton $variant={$variant} {...props} ref={ref}>
|
|
153
|
-
{props.$iconPosition !== "right" && props.$icon && props.$icon}
|
|
154
|
-
{props.children}
|
|
155
|
-
{props.$iconPosition === "right" && props.$icon && props.$icon}
|
|
156
|
-
</StyledButton>
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const Button = forwardRef(LocalButton);
|
|
161
|
-
|
|
162
|
-
export { Button };
|
|
1
|
+
"use client";
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import styled, { css } from "styled-components";
|
|
4
|
+
import { Theme, formElementHeightStyles, resetButton } from "./utils";
|
|
5
|
+
|
|
6
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
$variant?: "primary" | "secondary" | "tertiary";
|
|
9
|
+
$size?: "default" | "big";
|
|
10
|
+
$outline?: boolean;
|
|
11
|
+
$fullWidth?: boolean;
|
|
12
|
+
$icon?: React.ReactNode;
|
|
13
|
+
$iconPosition?: "left" | "right";
|
|
14
|
+
theme?: Theme;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const buttonStyles = (
|
|
18
|
+
theme: Theme,
|
|
19
|
+
$variant?: "primary" | "secondary" | "tertiary",
|
|
20
|
+
$size?: "default" | "big",
|
|
21
|
+
$outline?: boolean,
|
|
22
|
+
$fullWidth?: boolean,
|
|
23
|
+
disabled?: boolean,
|
|
24
|
+
) => css`
|
|
25
|
+
${resetButton};
|
|
26
|
+
font-family: inherit;
|
|
27
|
+
display: inline-flex;
|
|
28
|
+
padding: 15px 30px;
|
|
29
|
+
border-radius: 100px;
|
|
30
|
+
font-weight: 600;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
hyphens: auto;
|
|
33
|
+
color: ${theme.isDark ? theme.colors.dark : theme.colors.light};
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
transition: all 0.3s ease;
|
|
36
|
+
text-align: center;
|
|
37
|
+
gap: 10px;
|
|
38
|
+
text-overflow: ellipsis;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
|
|
41
|
+
& .icon,
|
|
42
|
+
& .lucide {
|
|
43
|
+
margin: auto 0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
${!disabled &&
|
|
47
|
+
$variant === "primary" &&
|
|
48
|
+
css`
|
|
49
|
+
color: ${$outline ? theme.colors.primary : theme.colors.light};
|
|
50
|
+
background: ${$outline ? "transparent" : theme.colors.primary};
|
|
51
|
+
border: solid 2px ${theme.colors.primary};
|
|
52
|
+
box-shadow: 0 0 0 0px ${theme.colors.primary};
|
|
53
|
+
|
|
54
|
+
@media (hover: hover) {
|
|
55
|
+
&:hover {
|
|
56
|
+
background: ${$outline ? "transparent" : theme.colors.primaryDark};
|
|
57
|
+
border-color: ${theme.colors.primaryDark};
|
|
58
|
+
${$outline && `color: ${theme.colors.primaryDark}`};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&:focus {
|
|
63
|
+
box-shadow: 0 0 0 4px ${theme.colors.primaryLight};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:active {
|
|
67
|
+
box-shadow: 0 0 0 2px ${theme.colors.primaryLight};
|
|
68
|
+
}
|
|
69
|
+
`}
|
|
70
|
+
|
|
71
|
+
${!disabled &&
|
|
72
|
+
$variant === "secondary" &&
|
|
73
|
+
css`
|
|
74
|
+
color: ${$outline ? theme.colors.secondary : theme.colors.light};
|
|
75
|
+
background: ${$outline ? "transparent" : theme.colors.secondary};
|
|
76
|
+
border: solid 2px ${theme.colors.secondary};
|
|
77
|
+
box-shadow: 0 0 0 0px ${theme.colors.secondary};
|
|
78
|
+
|
|
79
|
+
@media (hover: hover) {
|
|
80
|
+
&:hover {
|
|
81
|
+
background: ${$outline ? "transparent" : theme.colors.secondaryDark};
|
|
82
|
+
border-color: ${theme.colors.secondaryDark};
|
|
83
|
+
${$outline && `color: ${theme.colors.secondaryDark}`};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&:focus {
|
|
88
|
+
box-shadow: 0 0 0 4px ${theme.colors.secondaryLight};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&:active {
|
|
92
|
+
box-shadow: 0 0 0 2px ${theme.colors.secondaryLight};
|
|
93
|
+
}
|
|
94
|
+
`}
|
|
95
|
+
|
|
96
|
+
${!disabled &&
|
|
97
|
+
$variant === "tertiary" &&
|
|
98
|
+
css`
|
|
99
|
+
color: ${$outline ? theme.colors.tertiary : theme.colors.light};
|
|
100
|
+
background: ${$outline ? "transparent" : theme.colors.tertiary};
|
|
101
|
+
border: solid 2px ${theme.colors.tertiary};
|
|
102
|
+
box-shadow: 0 0 0 0px ${theme.colors.tertiary};
|
|
103
|
+
|
|
104
|
+
@media (hover: hover) {
|
|
105
|
+
&:hover {
|
|
106
|
+
background: ${$outline ? "transparent" : theme.colors.tertiaryDark};
|
|
107
|
+
border-color: ${theme.colors.tertiaryDark};
|
|
108
|
+
${$outline && `color: ${theme.colors.tertiaryDark}`};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&:focus {
|
|
113
|
+
box-shadow: 0 0 0 4px ${theme.colors.tertiaryLight};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
&:active {
|
|
117
|
+
box-shadow: 0 0 0 2px ${theme.colors.tertiaryLight};
|
|
118
|
+
}
|
|
119
|
+
`}
|
|
120
|
+
|
|
121
|
+
${formElementHeightStyles($size)}
|
|
122
|
+
|
|
123
|
+
${$size === "big"
|
|
124
|
+
? `font-size: ${theme.fontSizes.buttonBig.lg};
|
|
125
|
+
line-height: ${theme.lineHeights.buttonBig.lg};
|
|
126
|
+
padding: 18px 30px;
|
|
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: solid 2px ${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 LocalButton(
|
|
148
|
+
{ $variant = "primary", ...props }: ButtonProps,
|
|
149
|
+
ref: React.Ref<HTMLButtonElement>,
|
|
150
|
+
) {
|
|
151
|
+
return (
|
|
152
|
+
<StyledButton $variant={$variant} {...props} ref={ref}>
|
|
153
|
+
{props.$iconPosition !== "right" && props.$icon && props.$icon}
|
|
154
|
+
{props.children}
|
|
155
|
+
{props.$iconPosition === "right" && props.$icon && props.$icon}
|
|
156
|
+
</StyledButton>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const Button = forwardRef(LocalButton);
|
|
161
|
+
|
|
162
|
+
export { Button };
|