cherry-styled-components 0.1.2 → 0.1.3
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.md +70 -0
- package/dist/cherry.js +20069 -2609
- package/dist/cherry.umd.cjs +631 -459
- package/dist/lib/button.d.ts +2 -1
- package/dist/lib/icon.d.ts +10 -0
- package/dist/lib/index.d.ts +1 -0
- package/package.json +8 -7
- package/src/lib/button.tsx +48 -3
- package/src/lib/icon.tsx +18 -0
- package/src/lib/index.ts +1 -0
package/dist/lib/button.d.ts
CHANGED
|
@@ -8,8 +8,9 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
8
8
|
$fullWidth?: boolean;
|
|
9
9
|
$icon?: React.ReactNode;
|
|
10
10
|
$iconPosition?: "left" | "right";
|
|
11
|
+
$isError?: boolean;
|
|
11
12
|
theme?: Theme;
|
|
12
13
|
}
|
|
13
|
-
export declare const buttonStyles: (theme: Theme, $variant?: "primary" | "secondary" | "tertiary", $size?: "default" | "big", $outline?: boolean, $fullWidth?: boolean, disabled?: boolean) => import('styled-components').RuleSet<object>;
|
|
14
|
+
export declare const buttonStyles: (theme: Theme, $variant?: "primary" | "secondary" | "tertiary", $size?: "default" | "big", $outline?: boolean, $fullWidth?: boolean, $isError?: boolean, disabled?: boolean) => import('styled-components').RuleSet<object>;
|
|
14
15
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
15
16
|
export { Button };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { icons } from 'lucide-react';
|
|
2
|
+
export type IconProps = keyof typeof icons;
|
|
3
|
+
interface Props {
|
|
4
|
+
name: IconProps;
|
|
5
|
+
color?: string;
|
|
6
|
+
size?: number;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const Icon: ({ name, color, size, className }: Props) => import("react").JSX.Element;
|
|
10
|
+
export { Icon };
|
package/dist/lib/index.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.3",
|
|
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",
|
|
@@ -29,21 +29,22 @@
|
|
|
29
29
|
"format": "prettier --write \"./**/*.{js,json,ts,tsx}\""
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"react": "^19",
|
|
33
|
-
"react-dom": "^19"
|
|
32
|
+
"react": "^19.2.4",
|
|
33
|
+
"react-dom": "^19.2.4"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^25",
|
|
37
|
-
"@types/react": "^19",
|
|
38
|
-
"@types/react-dom": "^19",
|
|
36
|
+
"@types/node": "^25.2.1",
|
|
37
|
+
"@types/react": "^19.2.13",
|
|
38
|
+
"@types/react-dom": "^19.2.3",
|
|
39
39
|
"@vitejs/plugin-react": "^5.1.3",
|
|
40
40
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
41
41
|
"eslint-plugin-react-refresh": "^0.5.0",
|
|
42
|
+
"lucide-react": "^0.563.0",
|
|
42
43
|
"next": "^16.1.6",
|
|
43
44
|
"polished": "^4.3.1",
|
|
44
45
|
"prettier": "^3.8.1",
|
|
45
46
|
"styled-components": "^6.3.8",
|
|
46
|
-
"typescript": "^5",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
47
48
|
"vite": "^7.3.1",
|
|
48
49
|
"vite-plugin-dts": "^4.5.4"
|
|
49
50
|
}
|
package/src/lib/button.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
import styled, { css } from "styled-components";
|
|
4
|
+
import { lighten, darken } from "polished";
|
|
5
|
+
|
|
4
6
|
import { Theme, formElementHeightStyles, resetButton } from "./utils";
|
|
5
7
|
|
|
6
8
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
@@ -11,6 +13,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElemen
|
|
|
11
13
|
$fullWidth?: boolean;
|
|
12
14
|
$icon?: React.ReactNode;
|
|
13
15
|
$iconPosition?: "left" | "right";
|
|
16
|
+
$isError?: boolean;
|
|
14
17
|
theme?: Theme;
|
|
15
18
|
}
|
|
16
19
|
|
|
@@ -20,6 +23,7 @@ export const buttonStyles = (
|
|
|
20
23
|
$size?: "default" | "big",
|
|
21
24
|
$outline?: boolean,
|
|
22
25
|
$fullWidth?: boolean,
|
|
26
|
+
$isError?: boolean,
|
|
23
27
|
disabled?: boolean,
|
|
24
28
|
) => css`
|
|
25
29
|
${resetButton};
|
|
@@ -118,6 +122,34 @@ export const buttonStyles = (
|
|
|
118
122
|
}
|
|
119
123
|
`}
|
|
120
124
|
|
|
125
|
+
${!disabled &&
|
|
126
|
+
$isError &&
|
|
127
|
+
css`
|
|
128
|
+
color: ${$outline ? theme.colors.error : theme.colors.light};
|
|
129
|
+
background: ${$outline ? "transparent" : theme.colors.error};
|
|
130
|
+
border: solid 2px ${theme.colors.error};
|
|
131
|
+
box-shadow: 0 0 0 0px ${theme.colors.error};
|
|
132
|
+
|
|
133
|
+
@media (hover: hover) {
|
|
134
|
+
&:hover {
|
|
135
|
+
background: ${$outline
|
|
136
|
+
? "transparent"
|
|
137
|
+
: darken(0.1, theme.colors.error)};
|
|
138
|
+
border-color: ${darken(0.1, theme.colors.error)};
|
|
139
|
+
${$outline && `color: ${darken(0.1, theme.colors.error)}`};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
&:focus {
|
|
144
|
+
box-shadow: 0 0 0 4px ${lighten(0.1, theme.colors.error)};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&:active {
|
|
148
|
+
box-shadow: 0 0 0 2px ${lighten(0.1, theme.colors.error)};
|
|
149
|
+
}
|
|
150
|
+
`}
|
|
151
|
+
|
|
152
|
+
|
|
121
153
|
${formElementHeightStyles($size)}
|
|
122
154
|
|
|
123
155
|
${$size === "big"
|
|
@@ -140,8 +172,16 @@ export const buttonStyles = (
|
|
|
140
172
|
`;
|
|
141
173
|
|
|
142
174
|
const StyledButton = styled.button<ButtonProps>`
|
|
143
|
-
${({ theme, $variant, $size, $outline, $fullWidth, disabled }) =>
|
|
144
|
-
buttonStyles(
|
|
175
|
+
${({ theme, $variant, $isError, $size, $outline, $fullWidth, disabled }) =>
|
|
176
|
+
buttonStyles(
|
|
177
|
+
theme,
|
|
178
|
+
$variant,
|
|
179
|
+
$size,
|
|
180
|
+
$outline,
|
|
181
|
+
$fullWidth,
|
|
182
|
+
$isError,
|
|
183
|
+
disabled,
|
|
184
|
+
)}
|
|
145
185
|
`;
|
|
146
186
|
|
|
147
187
|
function LocalButton(
|
|
@@ -149,7 +189,12 @@ function LocalButton(
|
|
|
149
189
|
ref: React.Ref<HTMLButtonElement>,
|
|
150
190
|
) {
|
|
151
191
|
return (
|
|
152
|
-
<StyledButton
|
|
192
|
+
<StyledButton
|
|
193
|
+
$variant={$variant}
|
|
194
|
+
$isError={props.$isError}
|
|
195
|
+
{...props}
|
|
196
|
+
ref={ref}
|
|
197
|
+
>
|
|
153
198
|
{props.$iconPosition !== "right" && props.$icon && props.$icon}
|
|
154
199
|
{props.children}
|
|
155
200
|
{props.$iconPosition === "right" && props.$icon && props.$icon}
|
package/src/lib/icon.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { icons } from "lucide-react";
|
|
2
|
+
|
|
3
|
+
export type IconProps = keyof typeof icons;
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
name: IconProps;
|
|
7
|
+
color?: string;
|
|
8
|
+
size?: number;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Icon = ({ name, color, size, className }: Props) => {
|
|
13
|
+
const LucideIcon = icons[name];
|
|
14
|
+
|
|
15
|
+
return <LucideIcon color={color} size={size} className={className} />;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { Icon };
|