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,131 +1,121 @@
1
- "use client";
2
- import React from "react";
3
- import styled from "styled-components";
4
- import {
5
- theme as defaultTheme,
6
- Theme,
7
- IconArrow,
8
- formElementHeightStyles,
9
- fullWidthStyles,
10
- resetButton,
11
- resetInput,
12
- statusBorderStyles,
13
- } from "./utils";
14
- import { StyledInputWrapper, StyledLabel } from "./input";
15
-
16
- interface SelectProps extends React.InputHTMLAttributes<HTMLSelectElement> {
17
- children?: React.ReactNode;
18
- $label?: string;
19
- $size?: "default" | "big";
20
- $error?: boolean;
21
- $success?: boolean;
22
- $fullWidth?: boolean;
23
- theme?: Theme;
24
- }
25
-
26
- const StyledSelect = styled.select<SelectProps>`
27
- ${resetButton};
28
- ${resetInput};
29
- font-family: inherit;
30
- display: inline-block;
31
- padding: 15px;
32
- border-radius: ${({ theme }) => theme.spacing.radius.xs};
33
- font-weight: 400;
34
- white-space: nowrap;
35
- hyphens: auto;
36
- color: ${({ theme }) => theme.colors.dark};
37
- background: ${({ theme }) => theme.colors.light};
38
- border: solid 2px ${({ theme }) => theme.colors.grayLight};
39
- box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
40
- transition: all 0.3s ease;
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 }) => formElementHeightStyles($size)}
62
-
63
- ${({ $size, theme }) =>
64
- $size === "big"
65
- ? `font-size: ${theme.fontSizes.inputBig.lg};
66
- line-height: ${theme.lineHeights.inputBig.lg};
67
- `
68
- : `font-size: ${theme.fontSizes.input.lg};
69
- line-height: ${theme.lineHeights.input.lg};`}
70
-
71
- ${({ $error, $success, theme }) => {
72
- return statusBorderStyles(
73
- $error ? true : false,
74
- $success ? true : false,
75
- theme,
76
- );
77
- }}
78
-
79
- ${({ disabled, theme }) =>
80
- disabled &&
81
- `cursor: not-allowed;
82
- background: ${theme.colors.grayLight};
83
- border-color: ${theme.colors.gray};
84
- color: ${theme.colors.gray};
85
- `}
86
-
87
- ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
88
- `;
89
-
90
- export const StyledIconWrapper = styled.span<SelectProps>`
91
- position: relative;
92
- ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
93
-
94
- & svg {
95
- position: absolute;
96
- top: 50%;
97
- right: 15px;
98
- transform: translateY(-50%) rotate(0);
99
- transition: all 0.3s ease;
100
- pointer-events: none;
101
- }
102
-
103
- & select {
104
- padding-right: 40px;
105
- }
106
-
107
- & select:active:not([disabled]) ~ svg,
108
- & select:focus:not([disabled]) ~ svg {
109
- transform: translateY(-50%) rotate(180deg);
110
- }
111
- `;
112
-
113
- function Select({ theme = defaultTheme, ...props }: SelectProps) {
114
- return (
115
- <StyledInputWrapper $fullWidth={props.$fullWidth} theme={theme}>
116
- {props.$label && (
117
- <StyledLabel htmlFor={props.id} theme={theme}>
118
- {props.$label}
119
- </StyledLabel>
120
- )}
121
- <StyledIconWrapper $fullWidth={props.$fullWidth} theme={theme}>
122
- <StyledSelect {...props} theme={theme}>
123
- {props.children}
124
- </StyledSelect>
125
- <IconArrow theme={theme} />
126
- </StyledIconWrapper>
127
- </StyledInputWrapper>
128
- );
129
- }
130
-
131
- export { Select };
1
+ "use client";
2
+ import React, { forwardRef } from "react";
3
+ import styled, { IStyledComponent } from "styled-components";
4
+ import {
5
+ Theme,
6
+ IconArrow,
7
+ formElementHeightStyles,
8
+ fullWidthStyles,
9
+ resetButton,
10
+ resetInput,
11
+ statusBorderStyles,
12
+ } from "./utils";
13
+ import { StyledInputWrapper, StyledLabel } from "./input";
14
+
15
+ interface SelectProps extends React.InputHTMLAttributes<HTMLSelectElement> {
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 StyledSelect = styled.select<SelectProps>`
26
+ ${resetButton};
27
+ ${resetInput};
28
+ font-family: inherit;
29
+ display: inline-block;
30
+ padding: 0 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
+
41
+ &::placeholder {
42
+ color: ${({ theme }) => theme.colors.gray};
43
+ }
44
+
45
+ @media (hover: hover) {
46
+ &:hover:not([disabled]) {
47
+ border-color: ${({ theme }) => theme.colors.primary};
48
+ }
49
+ }
50
+
51
+ &:focus:not([disabled]) {
52
+ box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
53
+ border-color: ${({ theme }) => theme.colors.primary};
54
+ }
55
+
56
+ &:active:not([disabled]) {
57
+ box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
58
+ }
59
+
60
+ ${({ $size }) => formElementHeightStyles($size)}
61
+
62
+ ${({ $size, theme }) =>
63
+ $size === "big"
64
+ ? `font-size: ${theme.fontSizes.inputBig.lg};`
65
+ : `font-size: ${theme.fontSizes.input.lg};`}
66
+
67
+ ${({ $error, $success, theme }) => {
68
+ return statusBorderStyles($error ? true : false, $success ? true : false, theme);
69
+ }}
70
+
71
+ ${({ disabled, theme }) =>
72
+ disabled &&
73
+ `cursor: not-allowed;
74
+ background: ${theme.colors.grayLight};
75
+ border-color: ${theme.colors.gray};
76
+ color: ${theme.colors.gray};
77
+ `}
78
+
79
+ ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
80
+ `;
81
+
82
+ export const StyledIconWrapper: IStyledComponent<"web", SelectProps> = styled.span<SelectProps>`
83
+ position: relative;
84
+ ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
85
+
86
+ & svg {
87
+ position: absolute;
88
+ top: 50%;
89
+ right: 15px;
90
+ transform: translateY(-50%) rotate(0);
91
+ transition: all 0.3s ease;
92
+ pointer-events: none;
93
+ }
94
+
95
+ & select {
96
+ padding-right: 40px;
97
+ }
98
+
99
+ & select:active:not([disabled]) ~ svg,
100
+ & select:focus:not([disabled]) ~ svg {
101
+ transform: translateY(-50%) rotate(180deg);
102
+ }
103
+ `;
104
+
105
+ function LocalSelect({ ...props }: SelectProps, ref: React.Ref<HTMLSelectElement>) {
106
+ return (
107
+ <StyledInputWrapper $fullWidth={props.$fullWidth} $label={props.$label}>
108
+ {props.$label && <StyledLabel htmlFor={props.id}>{props.$label}</StyledLabel>}
109
+ <StyledIconWrapper $fullWidth={props.$fullWidth}>
110
+ <StyledSelect {...props} ref={ref}>
111
+ {props.children}
112
+ </StyledSelect>
113
+ <IconArrow />
114
+ </StyledIconWrapper>
115
+ </StyledInputWrapper>
116
+ );
117
+ }
118
+
119
+ const Select = forwardRef(LocalSelect);
120
+
121
+ export { Select };
package/src/lib/space.tsx CHANGED
@@ -1,54 +1,52 @@
1
- "use client";
2
- import React from "react";
3
- import styled from "styled-components";
4
- import { Breakpoints, mq } from "./utils";
5
-
6
- interface SpaceProps {
7
- $size?: number | "none";
8
- $xs?: number | "none";
9
- $sm?: number | "none";
10
- $md?: number | "none";
11
- $lg?: number | "none";
12
- $xl?: number | "none";
13
- $xxl?: number | "none";
14
- $xxxl?: number | "none";
15
- $horizontal?: boolean;
16
- }
17
-
18
- const styles = ($size: number | "none", $horizontal: boolean) =>
19
- $horizontal
20
- ? `display: inline-block;
21
- max-height: 0;
22
- min-width: ${$size}px;
23
- max-width: ${$size}px;`
24
- : `display: block;
25
- min-height: ${$size}px;
26
- max-height: ${$size}px;`;
27
-
28
- function responsiveStyles(props: any) {
29
- return Object.keys(props)
30
- .filter((key) => key.startsWith("$"))
31
- .map((key) => {
32
- const size = key.substring(1) as keyof Breakpoints<number>;
33
- return (
34
- props[key] &&
35
- mq(size) +
36
- `{ ${styles(props[key], props.$horizontal || false)} }`
37
- );
38
- })
39
- .join("");
40
- }
41
-
42
- const StyledSpace = styled.span<SpaceProps>`
43
- ${({ $horizontal, $size }) => `
44
- ${$size && $size !== "none" && styles($size, $horizontal || false)};
45
- ${$size === "none" && `display: none;`};
46
- `}
47
- ${(props) => responsiveStyles(props)}
48
- `;
49
-
50
- function Space({ ...props }: SpaceProps) {
51
- return <StyledSpace {...props} />;
52
- }
53
-
54
- export { Space };
1
+ "use client";
2
+ import React, { forwardRef } from "react";
3
+ import styled from "styled-components";
4
+ import { Breakpoints, mq } from "./utils";
5
+
6
+ interface SpaceProps {
7
+ $size?: number | "none";
8
+ $xs?: number | "none";
9
+ $sm?: number | "none";
10
+ $md?: number | "none";
11
+ $lg?: number | "none";
12
+ $xl?: number | "none";
13
+ $xxl?: number | "none";
14
+ $xxxl?: number | "none";
15
+ $horizontal?: boolean;
16
+ }
17
+
18
+ const styles = ($size: number | "none", $horizontal: boolean) =>
19
+ $horizontal
20
+ ? `display: inline-block;
21
+ max-height: 0;
22
+ min-width: ${$size}px;
23
+ max-width: ${$size}px;`
24
+ : `display: block;
25
+ min-height: ${$size}px;
26
+ max-height: ${$size}px;`;
27
+
28
+ function responsiveStyles(props: any) {
29
+ return Object.keys(props)
30
+ .filter((key) => key.startsWith("$"))
31
+ .map((key) => {
32
+ const size = key.substring(1) as keyof Breakpoints<number>;
33
+ return props[key] && mq(size) + `{ ${styles(props[key], props.$horizontal || false)} }`;
34
+ })
35
+ .join("");
36
+ }
37
+
38
+ const StyledSpace = styled.span<SpaceProps>`
39
+ ${({ $horizontal, $size }) => `
40
+ ${$size && $size !== "none" && styles($size, $horizontal || false)};
41
+ ${$size === "none" && `display: none;`};
42
+ `}
43
+ ${(props) => responsiveStyles(props)}
44
+ `;
45
+
46
+ function LocalSpace({ ...props }: SpaceProps, ref: React.Ref<HTMLSpanElement>) {
47
+ return <StyledSpace {...props} ref={ref} />;
48
+ }
49
+
50
+ const Space = forwardRef(LocalSpace);
51
+
52
+ export { Space };
@@ -1,2 +1,2 @@
1
- export * from "./registry";
2
- export * from "./theme-provider";
1
+ export * from "./registry";
2
+ export * from "./theme-provider";
@@ -1,26 +1,26 @@
1
- "use client";
2
- import React, { useState } from "react";
3
- import { useServerInsertedHTML } from "next/navigation";
4
- import { ServerStyleSheet, StyleSheetManager } from "styled-components";
5
-
6
- function StyledComponentsRegistry({ children }: { children: React.ReactNode }) {
7
- // Only create stylesheet once with lazy initial state
8
- // x-ref: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
9
- const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet());
10
-
11
- useServerInsertedHTML(() => {
12
- const styles = styledComponentsStyleSheet.getStyleElement();
13
- styledComponentsStyleSheet.instance.clearTag();
14
- return <>{styles}</>;
15
- });
16
-
17
- if (typeof window !== "undefined") return <>{children}</>;
18
-
19
- return (
20
- <StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
21
- {children}
22
- </StyleSheetManager>
23
- );
24
- }
25
-
26
- export { StyledComponentsRegistry };
1
+ "use client";
2
+ import React, { useState } from "react";
3
+ import { useServerInsertedHTML } from "next/navigation";
4
+ import { ServerStyleSheet, StyleSheetManager } from "styled-components";
5
+
6
+ function StyledComponentsRegistry({ children }: { children: React.ReactNode }) {
7
+ // Only create stylesheet once with lazy initial state
8
+ // x-ref: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
9
+ const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet());
10
+
11
+ useServerInsertedHTML(() => {
12
+ const styles = styledComponentsStyleSheet.getStyleElement();
13
+ styledComponentsStyleSheet.instance.clearTag();
14
+ return <>{styles}</>;
15
+ });
16
+
17
+ if (typeof window !== "undefined") return <>{children}</>;
18
+
19
+ return (
20
+ <StyleSheetManager sheet={styledComponentsStyleSheet.instance} enableVendorPrefixes>
21
+ {children}
22
+ </StyleSheetManager>
23
+ );
24
+ }
25
+
26
+ export { StyledComponentsRegistry };
@@ -1,21 +1,49 @@
1
- "use client";
2
- import React from "react";
3
- import { ThemeProvider as StyledThemeProvider } from "styled-components";
4
- import { theme as defaultTheme, GlobalStyles } from "../utils";
5
-
6
- function CherryThemeProvider({
7
- children,
8
- theme,
9
- }: {
10
- children: any;
11
- theme?: any;
12
- }) {
13
- return (
14
- <StyledThemeProvider theme={theme || defaultTheme}>
15
- <GlobalStyles />
16
- {children}
17
- </StyledThemeProvider>
18
- );
19
- }
20
-
21
- export { CherryThemeProvider };
1
+ "use client";
2
+ import React, { createContext, useEffect, useState } from "react";
3
+ import { ThemeProvider as StyledThemeProvider } from "styled-components";
4
+ import { GlobalStyles, Theme } from "../utils";
5
+
6
+ interface ThemeContextProps {
7
+ setTheme: any;
8
+ }
9
+
10
+ export const ThemeContext = createContext<ThemeContextProps>({
11
+ setTheme: null,
12
+ });
13
+
14
+ function CherryThemeProvider({
15
+ children,
16
+ theme,
17
+ themeDark,
18
+ }: {
19
+ children: React.ReactNode;
20
+ theme: Theme;
21
+ themeDark?: Theme;
22
+ }) {
23
+ const [currentTheme, setTheme] = useState(theme);
24
+ useEffect(() => {
25
+ if (!themeDark) return setTheme(theme);
26
+ if (
27
+ localStorage.theme === "dark" ||
28
+ (!("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches)
29
+ ) {
30
+ document.documentElement.classList.add("dark");
31
+ setTheme(themeDark);
32
+ } else {
33
+ document.documentElement.classList.remove("dark");
34
+ setTheme(theme);
35
+ }
36
+ }, []);
37
+ const GlobalStylesComponent = GlobalStyles(currentTheme);
38
+
39
+ return (
40
+ <StyledThemeProvider theme={currentTheme}>
41
+ <ThemeContext.Provider value={{ setTheme }}>
42
+ <GlobalStylesComponent />
43
+ {children}
44
+ </ThemeContext.Provider>
45
+ </StyledThemeProvider>
46
+ );
47
+ }
48
+
49
+ export { CherryThemeProvider };