onecart-ui 1.0.6 → 2.0.0

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.
@@ -14,6 +14,7 @@ export const Button: React.FC<ButtonProps> = ({
14
14
  icon,
15
15
  fullWidth = false,
16
16
  style,
17
+ ghostUnderline = true,
17
18
  accessibilityLabel,
18
19
  testID,
19
20
  onClick,
@@ -63,6 +64,7 @@ export const Button: React.FC<ButtonProps> = ({
63
64
  };
64
65
 
65
66
  // Apply styles based on type and state
67
+ // TODO: consider using maps
66
68
  switch (type) {
67
69
  case "primary":
68
70
  switch (buttonState) {
@@ -157,7 +159,7 @@ export const Button: React.FC<ButtonProps> = ({
157
159
  break;
158
160
  }
159
161
  break;
160
- case "ghost":
162
+ case "ghost": {
161
163
  switch (buttonState) {
162
164
  case "default":
163
165
  textStyle.color = tokens.ACTION_TERTIARY_DEFAULT;
@@ -172,7 +174,14 @@ export const Button: React.FC<ButtonProps> = ({
172
174
  textStyle.color = tokens.ACTION_TERTIARY_DISABLE;
173
175
  break;
174
176
  }
177
+ // Underline ghost button text by default unless explicitly disabled
178
+ if (!disabled && ghostUnderline) {
179
+ textStyle.textDecoration = "underline";
180
+ } else {
181
+ textStyle.textDecoration = "none";
182
+ }
175
183
  break;
184
+ }
176
185
  case "destructive":
177
186
  break;
178
187
  }
@@ -6,7 +6,6 @@ export const Body: React.FC<BodyProps> = ({
6
6
  size = "lg",
7
7
  element = "p",
8
8
  align = "left",
9
- weight,
10
9
  color,
11
10
  truncate = false,
12
11
  lineClamp,
@@ -34,13 +33,7 @@ export const Body: React.FC<BodyProps> = ({
34
33
  break;
35
34
  }
36
35
 
37
- let fontWeightValue = parseInt(tokenSet.fontWeight);
38
- if (weight) {
39
- if (weight === "normal") fontWeightValue = 400;
40
- else if (weight === "medium") fontWeightValue = 500;
41
- else if (weight === "semibold") fontWeightValue = 600;
42
- else if (weight === "bold") fontWeightValue = 700;
43
- }
36
+ const fontWeightValue = parseInt(tokenSet.fontWeight);
44
37
 
45
38
  const baseStyles: React.CSSProperties = {
46
39
  fontFamily: tokenSet.fontFamily,
@@ -6,7 +6,6 @@ export const Display: React.FC<DisplayProps> = ({
6
6
  size = "2xl",
7
7
  element = "h1",
8
8
  align = "left",
9
- weight,
10
9
  color,
11
10
  truncate = false,
12
11
  lineClamp,
@@ -21,13 +20,7 @@ export const Display: React.FC<DisplayProps> = ({
21
20
  const tokenSet =
22
21
  size === "2xl" ? typographyTokens.display2xl : typographyTokens.displayXl;
23
22
 
24
- let fontWeightValue = parseInt(tokenSet.fontWeight);
25
- if (weight) {
26
- if (weight === "normal") fontWeightValue = 400;
27
- else if (weight === "medium") fontWeightValue = 500;
28
- else if (weight === "semibold") fontWeightValue = 600;
29
- else if (weight === "bold") fontWeightValue = 700;
30
- }
23
+ const fontWeightValue = parseInt(tokenSet.fontWeight);
31
24
 
32
25
  const baseStyles: React.CSSProperties = {
33
26
  fontFamily: tokenSet.fontFamily,
@@ -1,19 +1,19 @@
1
1
  import React from "react";
2
2
  import typographyTokens from "../../styles/tokens/typography";
3
- import { HeadingProps, TypographyWeight } from "../../types/Typography";
3
+ import { HeadingProps } from "../../types/Typography";
4
4
 
5
5
  type HeadingTokenKey =
6
6
  | "headingXl"
7
7
  | "headingLg"
8
8
  | "headingMd"
9
9
  | "headingSm"
10
- | "headingXs";
10
+ | "headingXs"
11
+ | "heading2xs";
11
12
 
12
13
  export const Heading: React.FC<HeadingProps> = ({
13
14
  size = "xl",
14
15
  element = "h2",
15
16
  align = "left",
16
- weight,
17
17
  color,
18
18
  truncate = false,
19
19
  lineClamp,
@@ -31,13 +31,12 @@ export const Heading: React.FC<HeadingProps> = ({
31
31
  md: "headingMd",
32
32
  sm: "headingSm",
33
33
  xs: "headingXs",
34
+ "2xs": "heading2xs",
34
35
  };
35
36
 
36
37
  const tokenSet = typographyTokens[tokenKeyMap[size]];
37
38
 
38
- const fontWeightValue = weight
39
- ? parseInt(typographyTokens.weights[weight])
40
- : parseInt(tokenSet.fontWeight);
39
+ const fontWeightValue = parseInt(tokenSet.fontWeight);
41
40
 
42
41
  const baseStyles: React.CSSProperties = {
43
42
  fontFamily: tokenSet.fontFamily,
@@ -90,6 +89,7 @@ export const Heading: React.FC<HeadingProps> = ({
90
89
  md: "h3",
91
90
  sm: "h4",
92
91
  xs: "h5",
92
+ "2xs": "h6",
93
93
  };
94
94
 
95
95
  const defaultElement = element === "h2" ? headingElementMap[size] : element;
@@ -6,7 +6,6 @@ export const Utility: React.FC<UtilityProps> = ({
6
6
  variant = "button",
7
7
  element,
8
8
  align = "left",
9
- weight,
10
9
  color,
11
10
  truncate = false,
12
11
  lineClamp,
@@ -46,13 +45,7 @@ export const Utility: React.FC<UtilityProps> = ({
46
45
  break;
47
46
  }
48
47
 
49
- let fontWeightValue = parseInt(tokenSet.fontWeight);
50
- if (weight) {
51
- if (weight === "normal") fontWeightValue = 400;
52
- else if (weight === "medium") fontWeightValue = 500;
53
- else if (weight === "semibold") fontWeightValue = 600;
54
- else if (weight === "bold") fontWeightValue = 700;
55
- }
48
+ const fontWeightValue = parseInt(tokenSet.fontWeight);
56
49
 
57
50
  const baseStyles: React.CSSProperties = {
58
51
  fontFamily: tokenSet.fontFamily,
@@ -61,7 +61,8 @@ export const typographyTokens = {
61
61
  fontFamily: tokens.HEADING_SM_FONT_FAMILY,
62
62
  fontSize: pxToNumber(tokens.HEADING_SM_FONT_SIZE),
63
63
  fontWeight: normalizeFontWeight(tokens.HEADING_SM_FONT_WEIGHT),
64
- lineHeight: pxToNumber(tokens.LINE_HEIGHT_XL),
64
+ // Correct line-height to the specific Heading SM token (36px) per design spec
65
+ lineHeight: pxToNumber(tokens.HEADING_SM_LINE_HEIGHT),
65
66
  color: tokens.TEXT_HEADER,
66
67
  letterSpacing: tokens.HEADING_SM_LETTER_SPACING,
67
68
  textDecoration: tokens.HEADING_SM_TEXT_DECORATION,
@@ -77,6 +78,16 @@ export const typographyTokens = {
77
78
  textDecoration: tokens.HEADING_XS_TEXT_DECORATION,
78
79
  textCase: tokens.HEADING_XS_TEXT_CASE,
79
80
  },
81
+ heading2xs: {
82
+ fontFamily: tokens.HEADING_2XS_FONT_FAMILY,
83
+ fontSize: pxToNumber(tokens.HEADING_2XS_FONT_SIZE),
84
+ fontWeight: normalizeFontWeight(tokens.HEADING_2XS_FONT_WEIGHT),
85
+ lineHeight: pxToNumber(tokens.HEADING_2XS_LINE_HEIGHT),
86
+ color: tokens.TEXT_HEADER,
87
+ letterSpacing: tokens.HEADING_2XS_LETTER_SPACING,
88
+ textDecoration: tokens.HEADING_2XS_TEXT_DECORATION,
89
+ textCase: tokens.HEADING_2XS_TEXT_CASE,
90
+ },
80
91
 
81
92
  // Body text variants
82
93
  bodyXl: {
@@ -171,13 +182,7 @@ export const typographyTokens = {
171
182
  textCase: tokens.UTILITY_CAPTION_TEXT_CASE,
172
183
  },
173
184
 
174
- // Weights mapping for custom weight overrides
175
- weights: {
176
- normal: "400", // Regular weight
177
- medium: normalizeFontWeight(tokens.MEDIUM),
178
- semibold: normalizeFontWeight(tokens.SEMI_BOLD),
179
- bold: "700", // Bold weight (not directly defined in tokens)
180
- },
185
+ // Removed weights mapping (font-weight locked to tokens)
181
186
  };
182
187
 
183
188
  export default typographyTokens;
@@ -16,6 +16,8 @@ export interface ButtonProps {
16
16
  icon?: string;
17
17
  fullWidth?: boolean;
18
18
  style?: React.CSSProperties;
19
+ /** Ghost buttons are underlined by default; set to false to remove underline */
20
+ ghostUnderline?: boolean;
19
21
  accessibilityLabel?: string;
20
22
  testID?: string;
21
23
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
@@ -2,12 +2,14 @@ import React from "react";
2
2
 
3
3
  export type TypographyAlign = "left" | "center" | "right";
4
4
 
5
- export type TypographyWeight = "normal" | "medium" | "semibold" | "bold";
5
+ // Removed adjustable weight overrides for Display & Heading to enforce Figma design tokens.
6
+ // If needed in other components, reintroduce with narrower scope.
7
+ export type TypographyWeight = never; // no external weight override
6
8
 
7
9
  export interface BaseTypographyProps {
8
10
  element?: React.ElementType;
9
11
  align?: TypographyAlign;
10
- weight?: TypographyWeight;
12
+ // weight removed to stick to token-defined font-weight for semantic typography
11
13
  color?: string;
12
14
  truncate?: boolean;
13
15
  lineClamp?: number;
@@ -22,7 +24,7 @@ export interface DisplayProps extends BaseTypographyProps {
22
24
  size: "2xl" | "xl";
23
25
  }
24
26
  export interface HeadingProps extends BaseTypographyProps {
25
- size: "xl" | "lg" | "md" | "sm" | "xs";
27
+ size: "xl" | "lg" | "md" | "sm" | "xs" | "2xs";
26
28
  }
27
29
 
28
30
  export interface BodyProps extends BaseTypographyProps {