cherry-styled-components 0.1.0-9 → 0.1.1

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.
Files changed (60) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/.prettierrc +9 -9
  3. package/.supermaven/config.json +1 -0
  4. package/README.md +1 -1
  5. package/dist/App.d.ts +0 -1
  6. package/dist/cherry.js +4066 -2890
  7. package/dist/cherry.umd.cjs +916 -791
  8. package/dist/lib/box.d.ts +3 -3
  9. package/dist/lib/button.d.ts +6 -4
  10. package/dist/lib/col.d.ts +3 -3
  11. package/dist/lib/container.d.ts +3 -3
  12. package/dist/lib/flex.d.ts +5 -3
  13. package/dist/lib/grid.d.ts +3 -3
  14. package/dist/lib/index.d.ts +15 -15
  15. package/dist/lib/input.d.ts +16 -5
  16. package/dist/lib/max-width.d.ts +3 -2
  17. package/dist/lib/range.d.ts +3 -3
  18. package/dist/lib/select.d.ts +5 -4
  19. package/dist/lib/space.d.ts +2 -2
  20. package/dist/lib/styled-components/index.d.ts +2 -2
  21. package/dist/lib/styled-components/registry.d.ts +1 -1
  22. package/dist/lib/styled-components/theme-provider.d.ts +10 -4
  23. package/dist/lib/textarea.d.ts +4 -3
  24. package/dist/lib/toggle.d.ts +3 -3
  25. package/dist/lib/utils/global.d.ts +2 -2
  26. package/dist/lib/utils/icons.d.ts +6 -10
  27. package/dist/lib/utils/index.d.ts +5 -5
  28. package/dist/lib/utils/mixins.d.ts +11 -11
  29. package/dist/lib/utils/theme.d.ts +4 -0
  30. package/dist/lib/utils/typography.d.ts +19 -19
  31. package/dist/toggle-theme.d.ts +3 -0
  32. package/package.json +17 -15
  33. package/pnpm-workspace.yaml +3 -0
  34. package/src/App.tsx +80 -93
  35. package/src/lib/box.tsx +26 -21
  36. package/src/lib/button.tsx +162 -159
  37. package/src/lib/col.tsx +45 -43
  38. package/src/lib/container.tsx +59 -64
  39. package/src/lib/flex.tsx +92 -95
  40. package/src/lib/grid.tsx +64 -70
  41. package/src/lib/index.ts +15 -15
  42. package/src/lib/input.tsx +384 -267
  43. package/src/lib/max-width.tsx +50 -43
  44. package/src/lib/range.tsx +208 -226
  45. package/src/lib/select.tsx +121 -131
  46. package/src/lib/space.tsx +52 -54
  47. package/src/lib/styled-components/index.ts +2 -2
  48. package/src/lib/styled-components/registry.tsx +26 -26
  49. package/src/lib/styled-components/theme-provider.tsx +49 -21
  50. package/src/lib/textarea.tsx +94 -103
  51. package/src/lib/toggle.tsx +147 -160
  52. package/src/lib/utils/global.tsx +95 -79
  53. package/src/lib/utils/icons.tsx +84 -170
  54. package/src/lib/utils/index.ts +5 -5
  55. package/src/lib/utils/mixins.tsx +95 -108
  56. package/src/lib/utils/theme.ts +289 -242
  57. package/src/lib/utils/typography.tsx +204 -204
  58. package/src/main.tsx +14 -14
  59. package/src/toggle-theme.tsx +25 -0
  60. package/src/vite-env.d.ts +8 -1
@@ -1,103 +1,94 @@
1
- "use client";
2
- import React from "react";
3
- import styled from "styled-components";
4
- import {
5
- theme as defaultTheme,
6
- Theme,
7
- fullWidthStyles,
8
- resetButton,
9
- resetInput,
10
- statusBorderStyles,
11
- } from "./utils";
12
- import { StyledInputWrapper, StyledLabel } from "./input";
13
-
14
- interface TextareaProps
15
- extends Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "size"> {
16
- children?: React.ReactNode;
17
- $label?: string;
18
- $size?: "default" | "big";
19
- $error?: boolean;
20
- $success?: boolean;
21
- $fullWidth?: boolean;
22
- theme?: Theme;
23
- }
24
-
25
- const StyledTextarea = styled.textarea<TextareaProps>`
26
- ${resetButton};
27
- ${resetInput};
28
- font-family: inherit;
29
- display: inline-block;
30
- padding: 15px;
31
- border-radius: ${({ theme }) => theme.spacing.radius.xs};
32
- font-weight: 400;
33
- white-space: nowrap;
34
- hyphens: auto;
35
- color: ${({ theme }) => theme.colors.dark};
36
- background: ${({ theme }) => theme.colors.light};
37
- border: solid 2px ${({ theme }) => theme.colors.grayLight};
38
- box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
39
- transition: all 0.3s ease;
40
- min-height: 80px;
41
-
42
- &::placeholder {
43
- color: ${({ theme }) => theme.colors.gray};
44
- }
45
-
46
- @media (hover: hover) {
47
- &:hover:not([disabled]) {
48
- border-color: ${({ theme }) => theme.colors.primary};
49
- }
50
- }
51
-
52
- &:focus:not([disabled]) {
53
- box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
54
- border-color: ${({ theme }) => theme.colors.primary};
55
- }
56
-
57
- &:active:not([disabled]) {
58
- box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
59
- }
60
-
61
- ${({ $size, theme }) =>
62
- $size === "big"
63
- ? `font-size: ${theme.fontSizes.inputBig.lg};
64
- line-height: ${theme.lineHeights.text.lg};
65
- `
66
- : `font-size: ${theme.fontSizes.input.lg};
67
- line-height: ${theme.lineHeights.text.lg};`}
68
-
69
- ${({ $error, $success, theme }) => {
70
- return statusBorderStyles(
71
- $error ? true : false,
72
- $success ? true : false,
73
- theme,
74
- );
75
- }}
76
-
77
- ${({ disabled, theme }) =>
78
- disabled &&
79
- `cursor: not-allowed;
80
- background: ${theme.colors.grayLight};
81
- border-color: ${theme.colors.gray};
82
- color: ${theme.colors.gray};
83
- `}
84
-
85
- ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
86
- `;
87
-
88
- function Textarea({ theme = defaultTheme, ...props }: TextareaProps) {
89
- return (
90
- <StyledInputWrapper $fullWidth={props.$fullWidth} theme={theme}>
91
- {props.$label && (
92
- <StyledLabel htmlFor={props.id} theme={theme}>
93
- {props.$label}
94
- </StyledLabel>
95
- )}
96
- <StyledTextarea {...props} theme={theme}>
97
- {props.children}
98
- </StyledTextarea>
99
- </StyledInputWrapper>
100
- );
101
- }
102
-
103
- export { Textarea };
1
+ "use client";
2
+ import React, { forwardRef } from "react";
3
+ import styled from "styled-components";
4
+ import { Theme, fullWidthStyles, resetButton, resetInput, statusBorderStyles } from "./utils";
5
+ import { StyledInputWrapper, StyledLabel } from "./input";
6
+
7
+ interface TextareaProps extends Omit<React.InputHTMLAttributes<HTMLTextAreaElement>, "size"> {
8
+ children?: React.ReactNode;
9
+ $label?: string;
10
+ $size?: "default" | "big";
11
+ $error?: boolean;
12
+ $success?: boolean;
13
+ $fullWidth?: boolean;
14
+ theme?: Theme;
15
+ rows?: number;
16
+ }
17
+
18
+ const StyledTextarea = styled.textarea<TextareaProps>`
19
+ ${resetButton};
20
+ ${resetInput};
21
+ font-family: inherit;
22
+ display: inline-block;
23
+ padding: 15px;
24
+ border-radius: ${({ theme }) => theme.spacing.radius.xs};
25
+ font-weight: 400;
26
+ white-space: break-spaces;
27
+ hyphens: none;
28
+ color: ${({ theme }) => theme.colors.dark};
29
+ background: ${({ theme }) => theme.colors.light};
30
+ border: solid 2px ${({ theme }) => theme.colors.grayLight};
31
+ box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
32
+ transition: all 0.3s ease;
33
+ min-height: 80px;
34
+
35
+ &::placeholder {
36
+ color: ${({ theme }) => theme.colors.gray};
37
+ }
38
+
39
+ @media (hover: hover) {
40
+ &:hover:not([disabled]) {
41
+ border-color: ${({ theme }) => theme.colors.primary};
42
+ }
43
+ }
44
+
45
+ &:focus:not([disabled]) {
46
+ box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
47
+ border-color: ${({ theme }) => theme.colors.primary};
48
+ }
49
+
50
+ &:active:not([disabled]) {
51
+ box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
52
+ }
53
+
54
+ ${({ $size, theme }) =>
55
+ $size === "big"
56
+ ? `font-size: ${theme.fontSizes.inputBig.lg};
57
+ line-height: ${theme.lineHeights.text.lg};
58
+ `
59
+ : `font-size: ${theme.fontSizes.input.lg};
60
+ line-height: ${theme.lineHeights.text.lg};`}
61
+
62
+ ${({ $error, $success, theme }) => {
63
+ return statusBorderStyles($error ? true : false, $success ? true : false, theme);
64
+ }}
65
+
66
+ ${({ disabled, theme }) =>
67
+ disabled &&
68
+ `cursor: not-allowed;
69
+ background: ${theme.colors.grayLight};
70
+ border-color: ${theme.colors.gray};
71
+ color: ${theme.colors.gray};
72
+ `}
73
+
74
+ ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
75
+ `;
76
+
77
+ function LocalTextarea({ ...props }: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) {
78
+ return (
79
+ <StyledInputWrapper $fullWidth={props.$fullWidth} $label={props.$label}>
80
+ {props.$label && (
81
+ <StyledLabel htmlFor={props.id} $label={props.$label}>
82
+ {props.$label}
83
+ </StyledLabel>
84
+ )}
85
+ <StyledTextarea {...props} ref={ref}>
86
+ {props.children}
87
+ </StyledTextarea>
88
+ </StyledInputWrapper>
89
+ );
90
+ }
91
+
92
+ const Textarea = forwardRef(LocalTextarea);
93
+
94
+ export { Textarea };
@@ -1,160 +1,147 @@
1
- "use client";
2
- import React from "react";
3
- import styled from "styled-components";
4
- import {
5
- theme as defaultTheme,
6
- Theme,
7
- resetButton,
8
- statusBorderStyles,
9
- } from "./utils";
10
- import { StyledInputWrapper, StyledLabel } from "./input";
11
-
12
- interface ToggleProps extends React.InputHTMLAttributes<HTMLInputElement> {
13
- children?: React.ReactNode;
14
- type?: "checkbox" | "radio";
15
- $label?: string;
16
- $size?: "default" | "big";
17
- $error?: boolean;
18
- $success?: boolean;
19
- $fullWidth?: boolean;
20
- theme?: Theme;
21
- }
22
-
23
- const StyledToggleWrapper = styled.span<ToggleProps>`
24
- display: inline-block;
25
- margin: auto 0;
26
- position: relative;
27
- vertical-align: middle;
28
- `;
29
-
30
- const StyledFakeToggle = styled.span<ToggleProps>`
31
- display: block;
32
- border: solid 2px ${({ theme }) => theme.colors.grayLight};
33
- background: ${({ theme }) => theme.colors.light};
34
- border-radius: ${({ theme }) => theme.spacing.radius.xl};
35
- pointer-events: none;
36
- transition: all 0.3s ease;
37
- box-shadow: 0 0 0 0 ${({ theme }) => theme.colors.primaryLight};
38
- transform: none;
39
- width: ${({ $size }) => ($size === "big" ? "56px" : "46px")};
40
- height: ${({ $size }) => ($size === "big" ? "32px" : "22px")};
41
-
42
- ${({ $error, $success, theme }) => {
43
- return statusBorderStyles(
44
- $error ? true : false,
45
- $success ? true : false,
46
- theme,
47
- );
48
- }}
49
-
50
- &::before,
51
- &::after {
52
- content: "";
53
- display: block;
54
- position: absolute;
55
- }
56
-
57
- &::before {
58
- top: 5px;
59
- left: 5px;
60
- width: calc(100% - 10px);
61
- height: calc(100% - 10px);
62
- max-width: 0;
63
- border-radius: ${({ theme }) => theme.spacing.radius.xl};
64
- background: ${({ theme }) => theme.colors.light};
65
- transition: all 0.3s ease;
66
- }
67
-
68
- &::after {
69
- left: 0;
70
- top: 0;
71
- border-radius: 50%;
72
- transition: all 0.3s ease;
73
- transform: translateX(0);
74
- background: ${({ theme }) => theme.colors.primary};
75
- width: ${({ $size }) => ($size === "big" ? "32px" : "22px")};
76
- height: ${({ $size }) => ($size === "big" ? "32px" : "22px")};
77
- }
78
- `;
79
-
80
- const StyledToggle = styled.input<ToggleProps>`
81
- ${resetButton};
82
- position: absolute;
83
- left: 0;
84
- top: 0;
85
- width: 100%;
86
- height: 100%;
87
- outline: none;
88
- z-index: 10;
89
-
90
- &:checked ~ .fake-toggle {
91
- &::before {
92
- max-width: 46px;
93
- background: ${({ theme }) => theme.colors.primaryLight};
94
- }
95
-
96
- &::after {
97
- transform: translateX(25px);
98
- }
99
- }
100
-
101
- @media (hover: hover) {
102
- &:hover:not([disabled]) ~ .fake-toggle {
103
- border-color: ${({ theme }) => theme.colors.primary};
104
- }
105
- }
106
-
107
- &:focus:not([disabled]) ~ .fake-toggle {
108
- outline: none;
109
- border-color: ${({ theme }) => theme.colors.primary};
110
- box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
111
- }
112
-
113
- &:active:not([disabled]) ~ .fake-toggle {
114
- box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
115
- }
116
-
117
- ${({ disabled, theme }) =>
118
- disabled &&
119
- `cursor: not-allowed;
120
-
121
- & ~ .fake-toggle {
122
- border-color: ${theme.colors.gray};
123
-
124
- &::before {
125
- background: ${theme.colors.grayLight};
126
- }
127
-
128
- &::after {
129
- background: ${theme.colors.gray};
130
- }
131
- }`}
132
- `;
133
-
134
- function Toggle({
135
- theme = defaultTheme,
136
- type = "checkbox",
137
- ...props
138
- }: ToggleProps) {
139
- return (
140
- <StyledInputWrapper $fullWidth={props.$fullWidth} theme={theme}>
141
- <StyledToggleWrapper theme={theme}>
142
- <StyledToggle {...props} type={type} theme={theme} />
143
- <StyledFakeToggle
144
- $error={props.$error}
145
- $success={props.$success}
146
- className="fake-toggle"
147
- $size={props.$size}
148
- theme={theme}
149
- />
150
- </StyledToggleWrapper>
151
- {props.$label && (
152
- <StyledLabel htmlFor={props.id} theme={theme}>
153
- {props.$label}
154
- </StyledLabel>
155
- )}
156
- </StyledInputWrapper>
157
- );
158
- }
159
-
160
- export { Toggle };
1
+ "use client";
2
+ import React, { forwardRef } from "react";
3
+ import styled from "styled-components";
4
+ import { Theme, resetButton, statusBorderStyles } from "./utils";
5
+ import { StyledInputWrapper, StyledLabel } from "./input";
6
+
7
+ interface ToggleProps extends React.InputHTMLAttributes<HTMLInputElement> {
8
+ children?: React.ReactNode;
9
+ type?: "checkbox" | "radio";
10
+ $label?: string;
11
+ $size?: "default" | "big";
12
+ $error?: boolean;
13
+ $success?: boolean;
14
+ $fullWidth?: boolean;
15
+ theme?: Theme;
16
+ }
17
+
18
+ const StyledToggleWrapper = styled.span<ToggleProps>`
19
+ display: inline-block;
20
+ margin: auto 0;
21
+ position: relative;
22
+ vertical-align: middle;
23
+ `;
24
+
25
+ const StyledFakeToggle = styled.span<ToggleProps>`
26
+ display: block;
27
+ border: solid 2px ${({ theme }) => theme.colors.grayLight};
28
+ background: ${({ theme }) => theme.colors.light};
29
+ border-radius: ${({ theme }) => theme.spacing.radius.xl};
30
+ pointer-events: none;
31
+ transition: all 0.3s ease;
32
+ box-shadow: 0 0 0 0 ${({ theme }) => theme.colors.primaryLight};
33
+ transform: none;
34
+ width: ${({ $size }) => ($size === "big" ? "56px" : "46px")};
35
+ height: ${({ $size }) => ($size === "big" ? "32px" : "22px")};
36
+
37
+ ${({ $error, $success, theme }) => {
38
+ return statusBorderStyles($error ? true : false, $success ? true : false, theme);
39
+ }}
40
+
41
+ &::before,
42
+ &::after {
43
+ content: "";
44
+ display: block;
45
+ position: absolute;
46
+ }
47
+
48
+ &::before {
49
+ top: 5px;
50
+ left: 5px;
51
+ width: calc(100% - 10px);
52
+ height: calc(100% - 10px);
53
+ max-width: 0;
54
+ border-radius: ${({ theme }) => theme.spacing.radius.xl};
55
+ background: ${({ theme }) => theme.colors.light};
56
+ transition: all 0.3s ease;
57
+ }
58
+
59
+ &::after {
60
+ left: 0;
61
+ top: 0;
62
+ border-radius: 50%;
63
+ transition: all 0.3s ease;
64
+ transform: translateX(0);
65
+ background: ${({ theme }) => theme.colors.primary};
66
+ width: ${({ $size }) => ($size === "big" ? "32px" : "22px")};
67
+ height: ${({ $size }) => ($size === "big" ? "32px" : "22px")};
68
+ }
69
+ `;
70
+
71
+ const StyledToggle = styled.input<ToggleProps>`
72
+ ${resetButton};
73
+ position: absolute;
74
+ left: 0;
75
+ top: 0;
76
+ width: 100%;
77
+ height: 100%;
78
+ outline: none;
79
+ z-index: 10;
80
+
81
+ &:checked ~ .fake-toggle {
82
+ &::before {
83
+ max-width: 46px;
84
+ background: ${({ theme }) => theme.colors.primaryLight};
85
+ }
86
+
87
+ &::after {
88
+ transform: translateX(25px);
89
+ }
90
+ }
91
+
92
+ @media (hover: hover) {
93
+ &:hover:not([disabled]) ~ .fake-toggle {
94
+ border-color: ${({ theme }) => theme.colors.primary};
95
+ }
96
+ }
97
+
98
+ &:focus:not([disabled]) ~ .fake-toggle {
99
+ outline: none;
100
+ border-color: ${({ theme }) => theme.colors.primary};
101
+ box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
102
+ }
103
+
104
+ &:active:not([disabled]) ~ .fake-toggle {
105
+ box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
106
+ }
107
+
108
+ ${({ disabled, theme }) =>
109
+ disabled &&
110
+ `cursor: not-allowed;
111
+
112
+ & ~ .fake-toggle {
113
+ border-color: ${theme.colors.gray};
114
+
115
+ &::before {
116
+ background: ${theme.colors.grayLight};
117
+ }
118
+
119
+ &::after {
120
+ background: ${theme.colors.gray};
121
+ }
122
+ }`}
123
+ `;
124
+
125
+ function LocalToggle(
126
+ { type = "checkbox", ...props }: ToggleProps,
127
+ ref: React.Ref<HTMLInputElement>,
128
+ ) {
129
+ return (
130
+ <StyledInputWrapper $fullWidth={props.$fullWidth} $label={props.$label}>
131
+ <StyledToggleWrapper>
132
+ <StyledToggle {...props} type={type} ref={ref} />
133
+ <StyledFakeToggle
134
+ $error={props.$error}
135
+ $success={props.$success}
136
+ className="fake-toggle"
137
+ $size={props.$size}
138
+ />
139
+ </StyledToggleWrapper>
140
+ {props.$label && <StyledLabel htmlFor={props.id}>{props.$label}</StyledLabel>}
141
+ </StyledInputWrapper>
142
+ );
143
+ }
144
+
145
+ const Toggle = forwardRef(LocalToggle);
146
+
147
+ export { Toggle };