cherry-styled-components 0.1.11 → 0.1.13

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 (73) hide show
  1. package/README.md +2 -0
  2. package/dist/box.js +17 -0
  3. package/{src/lib/button.tsx → dist/button.js} +45 -98
  4. package/dist/col.js +25 -0
  5. package/dist/container.js +36 -0
  6. package/dist/flex.js +40 -0
  7. package/dist/grid.js +39 -0
  8. package/dist/icon.js +26 -0
  9. package/dist/index.js +89 -0
  10. package/{src/lib/input.tsx → dist/input.js} +95 -151
  11. package/dist/lib/button.d.ts +2 -3
  12. package/dist/lib/col.d.ts +0 -2
  13. package/dist/lib/container.d.ts +0 -2
  14. package/dist/lib/flex.d.ts +1 -3
  15. package/dist/lib/grid.d.ts +0 -2
  16. package/dist/lib/icon.d.ts +2 -1
  17. package/dist/lib/input.d.ts +0 -3
  18. package/dist/lib/range.d.ts +0 -2
  19. package/dist/lib/select.d.ts +0 -2
  20. package/dist/lib/styled-components/theme-provider.d.ts +1 -1
  21. package/dist/lib/textarea.d.ts +0 -2
  22. package/dist/lib/toggle.d.ts +0 -2
  23. package/dist/lib/utils/mixins.d.ts +2 -2
  24. package/dist/lib/utils/theme.d.ts +1 -2
  25. package/dist/lib/utils/typography.d.ts +3 -2
  26. package/dist/max-width.js +35 -0
  27. package/{src/lib/range.tsx → dist/range.js} +44 -71
  28. package/dist/select.js +108 -0
  29. package/dist/space.js +37 -0
  30. package/dist/styled-components/registry.js +25 -0
  31. package/dist/styled-components/theme-provider.js +35 -0
  32. package/dist/textarea.js +86 -0
  33. package/{src/lib/toggle.tsx → dist/toggle.js} +41 -67
  34. package/{src/lib/utils/global.tsx → dist/utils/global.js} +4 -5
  35. package/dist/utils/icons.js +86 -0
  36. package/{src/lib/utils/mixins.tsx → dist/utils/mixins.js} +23 -51
  37. package/dist/utils/theme.js +156 -0
  38. package/dist/utils/typography.js +51 -0
  39. package/package.json +28 -10
  40. package/.claude/settings.local.json +0 -21
  41. package/.eslintrc.cjs +0 -18
  42. package/.prettierignore +0 -5
  43. package/.prettierrc +0 -11
  44. package/.supermaven/config.json +0 -6
  45. package/CLAUDE.md +0 -70
  46. package/dist/cherry.js +0 -22802
  47. package/dist/cherry.umd.cjs +0 -1424
  48. package/index.html +0 -13
  49. package/pnpm-workspace.yaml +0 -3
  50. package/src/App.tsx +0 -311
  51. package/src/lib/box.tsx +0 -26
  52. package/src/lib/col.tsx +0 -48
  53. package/src/lib/container.tsx +0 -69
  54. package/src/lib/flex.tsx +0 -99
  55. package/src/lib/grid.tsx +0 -76
  56. package/src/lib/icon.tsx +0 -19
  57. package/src/lib/index.ts +0 -16
  58. package/src/lib/max-width.tsx +0 -53
  59. package/src/lib/select.tsx +0 -136
  60. package/src/lib/space.tsx +0 -55
  61. package/src/lib/styled-components/index.ts +0 -2
  62. package/src/lib/styled-components/registry.tsx +0 -29
  63. package/src/lib/styled-components/theme-provider.tsx +0 -50
  64. package/src/lib/textarea.tsx +0 -118
  65. package/src/lib/utils/icons.tsx +0 -84
  66. package/src/lib/utils/index.ts +0 -5
  67. package/src/lib/utils/theme.ts +0 -297
  68. package/src/lib/utils/typography.tsx +0 -204
  69. package/src/main.tsx +0 -19
  70. package/src/toggle-theme.tsx +0 -25
  71. package/src/vite-env.d.ts +0 -8
  72. package/tsconfig.json +0 -24
  73. package/vite.config.js +0 -24
@@ -1,53 +0,0 @@
1
- "use client";
2
- import React, { forwardRef } from "react";
3
- import styled from "styled-components";
4
- import { Breakpoints, mq } from "./utils";
5
-
6
- interface MaxWidthProps extends React.HTMLAttributes<HTMLDivElement> {
7
- $size?: number;
8
- $xs?: number;
9
- $sm?: number;
10
- $md?: number;
11
- $lg?: number;
12
- $xl?: number;
13
- $xxl?: number;
14
- $xxxl?: number;
15
- $m0?: boolean;
16
- }
17
-
18
- const styles = ($size: number | "none") => `max-width: ${$size}px;`;
19
-
20
- function responsiveStyles(props: any) {
21
- return Object.keys(props)
22
- .filter((key) => key.startsWith("$"))
23
- .map((key) => {
24
- const size = key.substring(1) as keyof Breakpoints<number>;
25
- return props[key] && mq(size) + `{ ${styles(props[key])} }`;
26
- })
27
- .join("");
28
- }
29
-
30
- const StyledMaxWidth = styled.div<MaxWidthProps>`
31
- display: block;
32
- margin: ${({ $m0 }) => ($m0 ? "0" : "auto")};
33
-
34
- ${({ $size }) => `
35
- ${$size && styles($size)};
36
- `}
37
- ${(props) => responsiveStyles(props)}
38
- `;
39
-
40
- function LocalMaxWidth(
41
- { ...props }: MaxWidthProps,
42
- ref: React.Ref<HTMLDivElement>,
43
- ) {
44
- return (
45
- <StyledMaxWidth {...props} ref={ref}>
46
- {props.children}
47
- </StyledMaxWidth>
48
- );
49
- }
50
-
51
- const MaxWidth = forwardRef(LocalMaxWidth);
52
-
53
- export { MaxWidth };
@@ -1,136 +0,0 @@
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
- $wrapperClassName?: string;
18
- $label?: string;
19
- $size?: "default" | "big" | "small";
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: 0 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
- &:hover:not([disabled]) {
47
- border-color: ${({ theme }) => theme.colors.primary};
48
- }
49
-
50
- &:focus:not([disabled]) {
51
- box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
52
- border-color: ${({ theme }) => theme.colors.primary};
53
- }
54
-
55
- &:active:not([disabled]) {
56
- box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
57
- }
58
-
59
- ${({ $size }) => formElementHeightStyles($size)}
60
-
61
- ${({ $size, theme }) =>
62
- $size === "big"
63
- ? `font-size: ${theme.fontSizes.inputBig.lg};`
64
- : $size === "small"
65
- ? `font-size: ${theme.fontSizes.inputSmall.lg}; padding: 0 12px;`
66
- : `font-size: ${theme.fontSizes.input.lg};`}
67
-
68
- ${({ $error, $success, theme }) => {
69
- return statusBorderStyles(
70
- $error ? true : false,
71
- $success ? true : false,
72
- theme,
73
- );
74
- }}
75
-
76
- ${({ disabled, theme }) =>
77
- disabled &&
78
- `cursor: not-allowed;
79
- background: ${theme.colors.grayLight};
80
- border-color: ${theme.colors.gray};
81
- color: ${theme.colors.gray};
82
- `}
83
-
84
- ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
85
- `;
86
-
87
- export const StyledIconWrapper: IStyledComponent<"web", SelectProps> =
88
- styled.span<SelectProps>`
89
- position: relative;
90
- ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
91
-
92
- & svg {
93
- position: absolute;
94
- top: 50%;
95
- right: 15px;
96
- transform: translateY(-50%) rotate(0);
97
- transition: all 0.3s ease;
98
- pointer-events: none;
99
- }
100
-
101
- & select {
102
- padding-right: 40px;
103
- }
104
-
105
- & select:active:not([disabled]) ~ svg,
106
- & select:focus:not([disabled]) ~ svg {
107
- transform: translateY(-50%) rotate(180deg);
108
- }
109
- `;
110
-
111
- function LocalSelect(
112
- { ...props }: SelectProps,
113
- ref: React.Ref<HTMLSelectElement>,
114
- ) {
115
- return (
116
- <StyledInputWrapper
117
- $fullWidth={props.$fullWidth}
118
- $label={props.$label}
119
- className={props.$wrapperClassName}
120
- >
121
- {props.$label && (
122
- <StyledLabel htmlFor={props.id}>{props.$label}</StyledLabel>
123
- )}
124
- <StyledIconWrapper $fullWidth={props.$fullWidth}>
125
- <StyledSelect {...props} ref={ref}>
126
- {props.children}
127
- </StyledSelect>
128
- <IconArrow />
129
- </StyledIconWrapper>
130
- </StyledInputWrapper>
131
- );
132
- }
133
-
134
- const Select = forwardRef(LocalSelect);
135
-
136
- export { Select };
package/src/lib/space.tsx DELETED
@@ -1,55 +0,0 @@
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
- $size === "none"
20
- ? `display: none;`
21
- : $horizontal
22
- ? `display: inline-block;
23
- max-height: 0;
24
- min-width: ${$size}px;
25
- max-width: ${$size}px;`
26
- : `display: block;
27
- min-height: ${$size}px;
28
- max-height: ${$size}px;`;
29
-
30
- function responsiveStyles(props: any) {
31
- return Object.keys(props)
32
- .filter((key) => key.startsWith("$"))
33
- .map((key) => {
34
- const size = key.substring(1) as keyof Breakpoints<number>;
35
- return (
36
- props[key] &&
37
- mq(size) + `{ ${styles(props[key], props.$horizontal || false)} }`
38
- );
39
- })
40
- .join("");
41
- }
42
-
43
- const StyledSpace = styled.span<SpaceProps>`
44
- ${({ $horizontal, $size }) =>
45
- $size ? styles($size, $horizontal || false) : ""}
46
- ${(props) => responsiveStyles(props)}
47
- `;
48
-
49
- function LocalSpace({ ...props }: SpaceProps, ref: React.Ref<HTMLSpanElement>) {
50
- return <StyledSpace {...props} ref={ref} />;
51
- }
52
-
53
- const Space = forwardRef(LocalSpace);
54
-
55
- export { Space };
@@ -1,2 +0,0 @@
1
- export * from "./registry";
2
- export * from "./theme-provider";
@@ -1,29 +0,0 @@
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
21
- sheet={styledComponentsStyleSheet.instance}
22
- enableVendorPrefixes
23
- >
24
- {children}
25
- </StyleSheetManager>
26
- );
27
- }
28
-
29
- export { StyledComponentsRegistry };
@@ -1,50 +0,0 @@
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) &&
29
- window.matchMedia("(prefers-color-scheme: dark)").matches)
30
- ) {
31
- document.documentElement.classList.add("dark");
32
- setTheme(themeDark);
33
- } else {
34
- document.documentElement.classList.remove("dark");
35
- setTheme(theme);
36
- }
37
- }, []);
38
- const GlobalStylesComponent = GlobalStyles(currentTheme);
39
-
40
- return (
41
- <StyledThemeProvider theme={currentTheme}>
42
- <ThemeContext.Provider value={{ setTheme }}>
43
- <GlobalStylesComponent />
44
- {children}
45
- </ThemeContext.Provider>
46
- </StyledThemeProvider>
47
- );
48
- }
49
-
50
- export { CherryThemeProvider };
@@ -1,118 +0,0 @@
1
- "use client";
2
- import React, { forwardRef } from "react";
3
- import styled from "styled-components";
4
- import {
5
- Theme,
6
- fullWidthStyles,
7
- resetButton,
8
- resetInput,
9
- statusBorderStyles,
10
- } from "./utils";
11
- import { StyledInputWrapper, StyledLabel } from "./input";
12
-
13
- interface TextareaProps extends Omit<
14
- React.InputHTMLAttributes<HTMLTextAreaElement>,
15
- "size"
16
- > {
17
- children?: React.ReactNode;
18
- $wrapperClassName?: string;
19
- $label?: string;
20
- $size?: "default" | "big" | "small";
21
- $error?: boolean;
22
- $success?: boolean;
23
- $fullWidth?: boolean;
24
- theme?: Theme;
25
- rows?: number;
26
- }
27
-
28
- const StyledTextarea = styled.textarea<TextareaProps>`
29
- ${resetButton};
30
- ${resetInput};
31
- font-family: inherit;
32
- display: inline-block;
33
- padding: 15px;
34
- border-radius: ${({ theme }) => theme.spacing.radius.xs};
35
- font-weight: 400;
36
- white-space: break-spaces;
37
- hyphens: none;
38
- color: ${({ theme }) => theme.colors.dark};
39
- background: ${({ theme }) => theme.colors.light};
40
- border: solid 2px ${({ theme }) => theme.colors.grayLight};
41
- box-shadow: 0 0 0 0px ${({ theme }) => theme.colors.primaryLight};
42
- transition: all 0.3s ease;
43
- min-height: 80px;
44
-
45
- &::placeholder {
46
- color: ${({ theme }) => theme.colors.gray};
47
- }
48
-
49
- &:hover:not([disabled]) {
50
- border-color: ${({ theme }) => theme.colors.primary};
51
- }
52
-
53
- &:focus:not([disabled]) {
54
- box-shadow: 0 0 0 4px ${({ theme }) => theme.colors.primaryLight};
55
- border-color: ${({ theme }) => theme.colors.primary};
56
- }
57
-
58
- &:active:not([disabled]) {
59
- box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};
60
- }
61
-
62
- ${({ $size, theme }) =>
63
- $size === "big"
64
- ? `font-size: ${theme.fontSizes.inputBig.lg};
65
- line-height: ${theme.lineHeights.text.lg};
66
- `
67
- : $size === "small"
68
- ? `font-size: ${theme.fontSizes.inputSmall.lg};
69
- line-height: ${theme.lineHeights.text.lg};
70
- padding: 10px 12px;
71
- `
72
- : `font-size: ${theme.fontSizes.input.lg};
73
- line-height: ${theme.lineHeights.text.lg};`}
74
-
75
- ${({ $error, $success, theme }) => {
76
- return statusBorderStyles(
77
- $error ? true : false,
78
- $success ? true : false,
79
- theme,
80
- );
81
- }}
82
-
83
- ${({ disabled, theme }) =>
84
- disabled &&
85
- `cursor: not-allowed;
86
- background: ${theme.colors.grayLight};
87
- border-color: ${theme.colors.gray};
88
- color: ${theme.colors.gray};
89
- `}
90
-
91
- ${({ $fullWidth }) => fullWidthStyles($fullWidth ? true : false)}
92
- `;
93
-
94
- function LocalTextarea(
95
- { ...props }: TextareaProps,
96
- ref: React.Ref<HTMLTextAreaElement>,
97
- ) {
98
- return (
99
- <StyledInputWrapper
100
- $fullWidth={props.$fullWidth}
101
- $label={props.$label}
102
- className={props.$wrapperClassName}
103
- >
104
- {props.$label && (
105
- <StyledLabel htmlFor={props.id} $label={props.$label}>
106
- {props.$label}
107
- </StyledLabel>
108
- )}
109
- <StyledTextarea {...props} ref={ref}>
110
- {props.children}
111
- </StyledTextarea>
112
- </StyledInputWrapper>
113
- );
114
- }
115
-
116
- const Textarea = forwardRef(LocalTextarea);
117
-
118
- export { Textarea };
@@ -1,84 +0,0 @@
1
- "use client";
2
- import React from "react";
3
- import { useTheme } from "styled-components";
4
- import { Theme } from "./theme";
5
-
6
- interface IconProps extends React.SVGProps<SVGSVGElement> {
7
- theme?: Theme;
8
- }
9
-
10
- function IconCheck({ ...props }: IconProps) {
11
- const theme: Theme = useTheme() as Theme;
12
- return (
13
- <svg
14
- width="12"
15
- height="10"
16
- viewBox="0 0 12 10"
17
- fill="none"
18
- xmlns="http://www.w3.org/2000/svg"
19
- {...props}
20
- >
21
- <path
22
- d="M10 2L4.4 8L2 5.75"
23
- stroke={theme.colors.primary}
24
- strokeWidth="3"
25
- strokeLinecap="round"
26
- strokeLinejoin="round"
27
- />
28
- </svg>
29
- );
30
- }
31
-
32
- function IconArrow({ ...props }: IconProps) {
33
- const theme: Theme = useTheme() as Theme;
34
- return (
35
- <svg
36
- width="16"
37
- height="10"
38
- viewBox="0 0 16 10"
39
- fill="none"
40
- xmlns="http://www.w3.org/2000/svg"
41
- {...props}
42
- >
43
- <path
44
- d="M2 2L8 8L14 2"
45
- stroke={theme.colors.primary}
46
- strokeWidth="3"
47
- strokeLinecap="round"
48
- strokeLinejoin="round"
49
- />
50
- </svg>
51
- );
52
- }
53
-
54
- function IconCalendar({ ...props }: IconProps) {
55
- const theme: Theme = useTheme() as Theme;
56
-
57
- return (
58
- <svg
59
- xmlns="http://www.w3.org/2000/svg"
60
- width="24"
61
- height="24"
62
- viewBox="0 0 24 24"
63
- fill="none"
64
- stroke={theme.colors.primary}
65
- strokeWidth="2"
66
- strokeLinecap="round"
67
- strokeLinejoin="round"
68
- {...props}
69
- >
70
- <path d="M8 2v4" />
71
- <path d="M16 2v4" />
72
- <rect width="18" height="18" x="3" y="4" rx="2" />
73
- <path d="M3 10h18" />
74
- <path d="M8 14h.01" />
75
- <path d="M12 14h.01" />
76
- <path d="M16 14h.01" />
77
- <path d="M8 18h.01" />
78
- <path d="M12 18h.01" />
79
- <path d="M16 18h.01" />
80
- </svg>
81
- );
82
- }
83
-
84
- export { IconCheck, IconArrow, IconCalendar };
@@ -1,5 +0,0 @@
1
- export * from "./global";
2
- export * from "./icons";
3
- export * from "./mixins";
4
- export * from "./theme";
5
- export * from "./typography";