cherry-styled-components 0.1.2 → 0.1.4

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.
@@ -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 };
@@ -6,6 +6,7 @@ export * from './col';
6
6
  export * from './container';
7
7
  export * from './flex';
8
8
  export * from './grid';
9
+ export * from './icon';
9
10
  export * from './input';
10
11
  export * from './max-width';
11
12
  export * from './range';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cherry-styled-components",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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
+ "lucide-react": "^0.563.0",
35
+ "polished": "^4.3.1"
34
36
  },
35
37
  "devDependencies": {
36
- "@types/node": "^25",
37
- "@types/react": "^19",
38
- "@types/react-dom": "^19",
38
+ "@types/node": "^25.2.1",
39
+ "@types/react": "^19.2.13",
40
+ "@types/react-dom": "^19.2.3",
39
41
  "@vitejs/plugin-react": "^5.1.3",
40
42
  "eslint-plugin-react-hooks": "^7.0.1",
41
43
  "eslint-plugin-react-refresh": "^0.5.0",
42
44
  "next": "^16.1.6",
43
- "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
  }
@@ -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};
@@ -37,6 +41,7 @@ export const buttonStyles = (
37
41
  gap: 10px;
38
42
  text-overflow: ellipsis;
39
43
  justify-content: center;
44
+ min-height: fit-content;
40
45
 
41
46
  & .icon,
42
47
  & .lucide {
@@ -118,6 +123,34 @@ export const buttonStyles = (
118
123
  }
119
124
  `}
120
125
 
126
+ ${!disabled &&
127
+ $isError &&
128
+ css`
129
+ color: ${$outline ? theme.colors.error : theme.colors.light};
130
+ background: ${$outline ? "transparent" : theme.colors.error};
131
+ border: solid 2px ${theme.colors.error};
132
+ box-shadow: 0 0 0 0px ${theme.colors.error};
133
+
134
+ @media (hover: hover) {
135
+ &:hover {
136
+ background: ${$outline
137
+ ? "transparent"
138
+ : darken(0.1, theme.colors.error)};
139
+ border-color: ${darken(0.1, theme.colors.error)};
140
+ ${$outline && `color: ${darken(0.1, theme.colors.error)}`};
141
+ }
142
+ }
143
+
144
+ &:focus {
145
+ box-shadow: 0 0 0 4px ${lighten(0.1, theme.colors.error)};
146
+ }
147
+
148
+ &:active {
149
+ box-shadow: 0 0 0 2px ${lighten(0.1, theme.colors.error)};
150
+ }
151
+ `}
152
+
153
+
121
154
  ${formElementHeightStyles($size)}
122
155
 
123
156
  ${$size === "big"
@@ -140,8 +173,16 @@ export const buttonStyles = (
140
173
  `;
141
174
 
142
175
  const StyledButton = styled.button<ButtonProps>`
143
- ${({ theme, $variant, $size, $outline, $fullWidth, disabled }) =>
144
- buttonStyles(theme, $variant, $size, $outline, $fullWidth, disabled)}
176
+ ${({ theme, $variant, $isError, $size, $outline, $fullWidth, disabled }) =>
177
+ buttonStyles(
178
+ theme,
179
+ $variant,
180
+ $size,
181
+ $outline,
182
+ $fullWidth,
183
+ $isError,
184
+ disabled,
185
+ )}
145
186
  `;
146
187
 
147
188
  function LocalButton(
@@ -149,7 +190,12 @@ function LocalButton(
149
190
  ref: React.Ref<HTMLButtonElement>,
150
191
  ) {
151
192
  return (
152
- <StyledButton $variant={$variant} {...props} ref={ref}>
193
+ <StyledButton
194
+ $variant={$variant}
195
+ $isError={props.$isError}
196
+ {...props}
197
+ ref={ref}
198
+ >
153
199
  {props.$iconPosition !== "right" && props.$icon && props.$icon}
154
200
  {props.children}
155
201
  {props.$iconPosition === "right" && props.$icon && props.$icon}
@@ -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 };
package/src/lib/index.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./col";
6
6
  export * from "./container";
7
7
  export * from "./flex";
8
8
  export * from "./grid";
9
+ export * from "./icon";
9
10
  export * from "./input";
10
11
  export * from "./max-width";
11
12
  export * from "./range";