onecart-ui 1.0.7 → 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.
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Typography/Body.d.ts.map +1 -1
- package/dist/components/Typography/Display.d.ts.map +1 -1
- package/dist/components/Typography/Heading.d.ts.map +1 -1
- package/dist/components/Typography/Utility.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles/tokens/typography.d.ts +10 -6
- package/dist/styles/tokens/typography.d.ts.map +1 -1
- package/dist/types/Button.d.ts +2 -0
- package/dist/types/Button.d.ts.map +1 -1
- package/dist/types/Typography.d.ts +2 -3
- package/dist/types/Typography.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.tsx +10 -1
- package/src/components/Typography/Body.tsx +1 -8
- package/src/components/Typography/Display.tsx +1 -8
- package/src/components/Typography/Heading.tsx +6 -6
- package/src/components/Typography/Utility.tsx +1 -8
- package/src/styles/tokens/typography.ts +13 -8
- package/src/types/Button.ts +2 -0
- package/src/types/Typography.ts +5 -3
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
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;
|
package/src/types/Button.ts
CHANGED
|
@@ -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>;
|
package/src/types/Typography.ts
CHANGED
|
@@ -2,12 +2,14 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
export type TypographyAlign = "left" | "center" | "right";
|
|
4
4
|
|
|
5
|
-
|
|
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
|
|
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 {
|