@xsolla/xui-typography 0.112.0 → 0.114.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/README.md +56 -5
- package/native/index.d.mts +4 -2
- package/native/index.d.ts +4 -2
- package/native/index.js +102 -11
- package/native/index.js.flow +4 -0
- package/native/index.js.map +1 -1
- package/native/index.mjs +107 -13
- package/native/index.mjs.map +1 -1
- package/package.json +3 -3
- package/web/index.d.mts +4 -2
- package/web/index.d.ts +4 -2
- package/web/index.js +72 -8
- package/web/index.js.flow +4 -0
- package/web/index.js.map +1 -1
- package/web/index.mjs +73 -9
- package/web/index.mjs.map +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,7 @@ import { Typography } from '@xsolla/xui-typography';
|
|
|
83
83
|
marginTop={0} // Top margin
|
|
84
84
|
marginBottom={0} // Bottom margin
|
|
85
85
|
as="p" // HTML element to render
|
|
86
|
+
productContext="b2c" // Override product context (optional)
|
|
86
87
|
>
|
|
87
88
|
Text content
|
|
88
89
|
</Typography>
|
|
@@ -158,6 +159,43 @@ export default function AccentText() {
|
|
|
158
159
|
}
|
|
159
160
|
```
|
|
160
161
|
|
|
162
|
+
### Product Context Override
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import * as React from 'react';
|
|
166
|
+
import { Typography } from '@xsolla/xui-typography';
|
|
167
|
+
import { XUIProvider } from '@xsolla/xui-core';
|
|
168
|
+
|
|
169
|
+
export default function ProductContextOverride() {
|
|
170
|
+
return (
|
|
171
|
+
// Root provider sets B2B context
|
|
172
|
+
<XUIProvider initialProductContext="b2b">
|
|
173
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
174
|
+
{/* Uses B2B context from provider (56px, weight 400) */}
|
|
175
|
+
<Typography variant="h1">
|
|
176
|
+
Default B2B Heading
|
|
177
|
+
</Typography>
|
|
178
|
+
|
|
179
|
+
{/* Override to B2C context (40px, weight 700) */}
|
|
180
|
+
<Typography variant="h1" productContext="b2c">
|
|
181
|
+
B2C Marketing Headline
|
|
182
|
+
</Typography>
|
|
183
|
+
|
|
184
|
+
{/* Override to PayStation context for compact UI (28px, weight 700) */}
|
|
185
|
+
<Typography variant="h1" productContext="paystation">
|
|
186
|
+
Payment Form Title
|
|
187
|
+
</Typography>
|
|
188
|
+
|
|
189
|
+
{/* Override to Presentation context for large displays (56px, weight 700) */}
|
|
190
|
+
<Typography variant="h1" productContext="presentation">
|
|
191
|
+
Presentation Display
|
|
192
|
+
</Typography>
|
|
193
|
+
</div>
|
|
194
|
+
</XUIProvider>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
161
199
|
## API Reference
|
|
162
200
|
|
|
163
201
|
### Typography
|
|
@@ -174,6 +212,7 @@ export default function AccentText() {
|
|
|
174
212
|
| marginTop | `number` | `0` | Top margin in pixels. |
|
|
175
213
|
| marginBottom | `number` | `0` | Bottom margin in pixels. |
|
|
176
214
|
| as | `ElementType` | - | HTML element to render. |
|
|
215
|
+
| productContext | `ProductContext` | - | Override product context (`"b2c"` \| `"b2b"` \| `"paystation"` \| `"presentation"`). Uses provider context if not specified. |
|
|
177
216
|
|
|
178
217
|
**VariantType:**
|
|
179
218
|
|
|
@@ -217,13 +256,16 @@ type ColorType =
|
|
|
217
256
|
|
|
218
257
|
## Variant Specifications
|
|
219
258
|
|
|
259
|
+
The values below are for **B2B context** (the default when no context is specified). These values change based on the product context. See the [Product Context documentation](/docs/product-context.md) for complete specifications for each context.
|
|
260
|
+
|
|
220
261
|
| Variant | Size | Weight | Line Height |
|
|
221
262
|
| :------ | :--- | :----- | :---------- |
|
|
222
|
-
| display |
|
|
223
|
-
| h1 |
|
|
224
|
-
| h2 |
|
|
225
|
-
| h3 |
|
|
226
|
-
| h4 | 24px |
|
|
263
|
+
| display | 64px | 400 | 78px |
|
|
264
|
+
| h1 | 56px | 400 | 68px |
|
|
265
|
+
| h2 | 48px | 400 | 58px |
|
|
266
|
+
| h3 | 32px | 400 | 38px |
|
|
267
|
+
| h4 | 24px | 400 | 28px |
|
|
268
|
+
| h5 | 20px | 600 | 24px |
|
|
227
269
|
| bodyLg | 18px | 400 | 24px |
|
|
228
270
|
| bodyLgAccent | 18px | 500 | 24px |
|
|
229
271
|
| bodyLgParagraph | 18px | 400 | 26px |
|
|
@@ -236,3 +278,12 @@ type ColorType =
|
|
|
236
278
|
| bodyXs | 12px | 400 | 16px |
|
|
237
279
|
| bodyXsAccent | 12px | 500 | 16px |
|
|
238
280
|
| bodyXsParagraph | 12px | 400 | 18px |
|
|
281
|
+
|
|
282
|
+
### Product Contexts
|
|
283
|
+
|
|
284
|
+
Product contexts allow switching between different typographic scales (and in the future, component variations):
|
|
285
|
+
|
|
286
|
+
- **b2c**: Consumer-facing (moderate sizes, bold headings)
|
|
287
|
+
- **b2b**: Business/enterprise (larger sizes, lighter headings) - *Default*
|
|
288
|
+
- **paystation**: Compact for payments (smaller sizes)
|
|
289
|
+
- **presentation**: Large displays (largest sizes)
|
package/native/index.d.mts
CHANGED
|
@@ -2,9 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ElementType } from 'react';
|
|
3
3
|
|
|
4
4
|
type AlignType = "center" | "inherit" | "justify" | "left" | "right";
|
|
5
|
-
type VariantType = "h1" | "h2" | "h3" | "h4" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
5
|
+
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
6
6
|
type ThemeColorType = "primary" | "secondary" | "tertiary" | "brand" | "brandSecondary" | "success" | "warning" | "alert" | "neutral";
|
|
7
7
|
type ColorType = ThemeColorType | "inherit";
|
|
8
|
+
type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|
|
8
9
|
interface TypographyProps extends Omit<any, "color"> {
|
|
9
10
|
children?: ReactNode;
|
|
10
11
|
align?: AlignType;
|
|
@@ -14,10 +15,11 @@ interface TypographyProps extends Omit<any, "color"> {
|
|
|
14
15
|
marginBottom?: number;
|
|
15
16
|
marginTop?: number;
|
|
16
17
|
as?: ElementType;
|
|
18
|
+
productContext?: ProductContext;
|
|
17
19
|
"aria-hidden"?: boolean;
|
|
18
20
|
"aria-live"?: "polite" | "assertive" | "off";
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
declare const Typography: react.ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & react.RefAttributes<any>>;
|
|
22
24
|
|
|
23
|
-
export { type AlignType, type ColorType, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
|
25
|
+
export { type AlignType, type ColorType, type ProductContext, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
package/native/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ElementType } from 'react';
|
|
3
3
|
|
|
4
4
|
type AlignType = "center" | "inherit" | "justify" | "left" | "right";
|
|
5
|
-
type VariantType = "h1" | "h2" | "h3" | "h4" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
5
|
+
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
6
6
|
type ThemeColorType = "primary" | "secondary" | "tertiary" | "brand" | "brandSecondary" | "success" | "warning" | "alert" | "neutral";
|
|
7
7
|
type ColorType = ThemeColorType | "inherit";
|
|
8
|
+
type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|
|
8
9
|
interface TypographyProps extends Omit<any, "color"> {
|
|
9
10
|
children?: ReactNode;
|
|
10
11
|
align?: AlignType;
|
|
@@ -14,10 +15,11 @@ interface TypographyProps extends Omit<any, "color"> {
|
|
|
14
15
|
marginBottom?: number;
|
|
15
16
|
marginTop?: number;
|
|
16
17
|
as?: ElementType;
|
|
18
|
+
productContext?: ProductContext;
|
|
17
19
|
"aria-hidden"?: boolean;
|
|
18
20
|
"aria-live"?: "polite" | "assertive" | "off";
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
declare const Typography: react.ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & react.RefAttributes<any>>;
|
|
22
24
|
|
|
23
|
-
export { type AlignType, type ColorType, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
|
25
|
+
export { type AlignType, type ColorType, type ProductContext, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
package/native/index.js
CHANGED
|
@@ -37,29 +37,57 @@ var roleMap = {
|
|
|
37
37
|
link: "link",
|
|
38
38
|
text: "text"
|
|
39
39
|
};
|
|
40
|
+
var parseNumericValue = (value) => {
|
|
41
|
+
if (value === void 0) return void 0;
|
|
42
|
+
if (typeof value === "number") return value;
|
|
43
|
+
const parsed = parseFloat(value);
|
|
44
|
+
return isNaN(parsed) ? void 0 : parsed;
|
|
45
|
+
};
|
|
40
46
|
var Text = ({
|
|
41
47
|
children,
|
|
42
48
|
color,
|
|
43
49
|
fontSize,
|
|
44
50
|
fontWeight,
|
|
45
51
|
fontFamily,
|
|
52
|
+
textAlign,
|
|
53
|
+
lineHeight,
|
|
54
|
+
numberOfLines,
|
|
46
55
|
id,
|
|
47
56
|
role,
|
|
57
|
+
style: styleProp,
|
|
48
58
|
...props
|
|
49
59
|
}) => {
|
|
50
60
|
let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
|
|
51
61
|
if (resolvedFontFamily === "Pilat Wide" || resolvedFontFamily === "Pilat Wide Bold" || resolvedFontFamily === "Aktiv Grotesk") {
|
|
52
62
|
resolvedFontFamily = void 0;
|
|
53
63
|
}
|
|
54
|
-
const
|
|
64
|
+
const incomingStyle = import_react_native.StyleSheet.flatten(styleProp);
|
|
65
|
+
const baseStyle = {
|
|
55
66
|
color,
|
|
56
67
|
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
57
68
|
fontWeight,
|
|
58
69
|
fontFamily: resolvedFontFamily,
|
|
59
|
-
textDecorationLine: props.textDecoration
|
|
70
|
+
textDecorationLine: props.textDecoration,
|
|
71
|
+
textAlign: textAlign ?? incomingStyle?.textAlign,
|
|
72
|
+
lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),
|
|
73
|
+
marginTop: parseNumericValue(
|
|
74
|
+
incomingStyle?.marginTop
|
|
75
|
+
),
|
|
76
|
+
marginBottom: parseNumericValue(
|
|
77
|
+
incomingStyle?.marginBottom
|
|
78
|
+
)
|
|
60
79
|
};
|
|
61
80
|
const accessibilityRole = role ? roleMap[role] : void 0;
|
|
62
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
81
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
+
import_react_native.Text,
|
|
83
|
+
{
|
|
84
|
+
style: baseStyle,
|
|
85
|
+
numberOfLines,
|
|
86
|
+
testID: id,
|
|
87
|
+
accessibilityRole,
|
|
88
|
+
children
|
|
89
|
+
}
|
|
90
|
+
);
|
|
63
91
|
};
|
|
64
92
|
|
|
65
93
|
// src/Typography.tsx
|
|
@@ -80,19 +108,79 @@ var getColor = (color, theme) => {
|
|
|
80
108
|
};
|
|
81
109
|
return colorMap[color] || color;
|
|
82
110
|
};
|
|
83
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
84
|
-
var getVariantStyles = (variant) => {
|
|
111
|
+
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "h5" || variant === "display";
|
|
112
|
+
var getVariantStyles = (variant, typographyTokens) => {
|
|
113
|
+
if (typographyTokens) {
|
|
114
|
+
const headingMap = {
|
|
115
|
+
h1: "h1",
|
|
116
|
+
h2: "h2",
|
|
117
|
+
h3: "h3",
|
|
118
|
+
h4: "h4",
|
|
119
|
+
h5: "h5"
|
|
120
|
+
};
|
|
121
|
+
if (headingMap[variant]) {
|
|
122
|
+
const token = typographyTokens.heading[headingMap[variant]];
|
|
123
|
+
if (token) {
|
|
124
|
+
return {
|
|
125
|
+
fontSize: token.fontSize,
|
|
126
|
+
fontWeight: String(token.fontWeight),
|
|
127
|
+
lineHeight: token.lineHeight
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (variant === "display" && typographyTokens.basic?.display) {
|
|
132
|
+
const token = typographyTokens.basic.display;
|
|
133
|
+
return {
|
|
134
|
+
fontSize: token.fontSize,
|
|
135
|
+
fontWeight: String(token.fontWeight),
|
|
136
|
+
lineHeight: token.lineHeight
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
const bodyMap = {
|
|
140
|
+
bodyLg: "body-lg",
|
|
141
|
+
bodyLgAccent: "body-lg",
|
|
142
|
+
bodyLgParagraph: "body-lg",
|
|
143
|
+
bodyMd: "body-md",
|
|
144
|
+
bodyMdAccent: "body-md",
|
|
145
|
+
bodyMdParagraph: "body-md",
|
|
146
|
+
bodySm: "body-sm",
|
|
147
|
+
bodySmAccent: "body-sm",
|
|
148
|
+
bodySmParagraph: "body-sm",
|
|
149
|
+
bodyXs: "body-xs",
|
|
150
|
+
bodyXsAccent: "body-xs",
|
|
151
|
+
bodyXsParagraph: "body-xs"
|
|
152
|
+
};
|
|
153
|
+
const bodyKey = bodyMap[variant];
|
|
154
|
+
if (bodyKey && typographyTokens.basic?.[bodyKey]) {
|
|
155
|
+
const token = typographyTokens.basic[bodyKey];
|
|
156
|
+
let fontWeight = token.fontWeight;
|
|
157
|
+
let lineHeight = token.lineHeight;
|
|
158
|
+
if (variant.includes("Accent") && token.accent) {
|
|
159
|
+
fontWeight = token.accent.fontWeight;
|
|
160
|
+
}
|
|
161
|
+
if (variant.includes("Paragraph") && token.paragraph) {
|
|
162
|
+
lineHeight = token.paragraph.lineHeight;
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
fontSize: token.fontSize,
|
|
166
|
+
fontWeight: String(fontWeight),
|
|
167
|
+
lineHeight
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
85
171
|
switch (variant) {
|
|
86
172
|
case "h1":
|
|
87
|
-
return { fontSize:
|
|
173
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
88
174
|
case "h2":
|
|
89
|
-
return { fontSize:
|
|
175
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
90
176
|
case "h3":
|
|
91
|
-
return { fontSize:
|
|
177
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
92
178
|
case "h4":
|
|
93
|
-
return { fontSize: 24, fontWeight: "
|
|
179
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
180
|
+
case "h5":
|
|
181
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
94
182
|
case "display":
|
|
95
|
-
return { fontSize:
|
|
183
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
96
184
|
case "bodyLg":
|
|
97
185
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
98
186
|
case "bodyLgAccent":
|
|
@@ -131,10 +219,12 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
131
219
|
marginBottom = 0,
|
|
132
220
|
marginTop = 0,
|
|
133
221
|
as,
|
|
222
|
+
productContext,
|
|
134
223
|
...rest
|
|
135
224
|
}, ref) => {
|
|
136
225
|
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
137
|
-
const
|
|
226
|
+
const typographyTokens = productContext ? (0, import_xui_core.getTypographyTokens)(productContext) : theme.typographyTokens;
|
|
227
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
138
228
|
const colorValue = getColor(color, theme);
|
|
139
229
|
const themefonts = theme.fonts;
|
|
140
230
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
|
@@ -148,6 +238,7 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
148
238
|
fontSize: variantStyles.fontSize,
|
|
149
239
|
fontWeight: variantStyles.fontWeight,
|
|
150
240
|
fontFamily,
|
|
241
|
+
numberOfLines: noWrap ? 1 : void 0,
|
|
151
242
|
style: {
|
|
152
243
|
marginTop,
|
|
153
244
|
marginBottom,
|
package/native/index.js.flow
CHANGED
|
@@ -13,6 +13,7 @@ declare type VariantType =
|
|
|
13
13
|
| "h2"
|
|
14
14
|
| "h3"
|
|
15
15
|
| "h4"
|
|
16
|
+
| "h5"
|
|
16
17
|
| "display"
|
|
17
18
|
| "bodyLg"
|
|
18
19
|
| "bodyLgAccent"
|
|
@@ -37,6 +38,7 @@ declare type ThemeColorType =
|
|
|
37
38
|
| "alert"
|
|
38
39
|
| "neutral";
|
|
39
40
|
declare type ColorType = ThemeColorType | "inherit";
|
|
41
|
+
declare type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|
|
40
42
|
declare type TypographyProps = {
|
|
41
43
|
children?: Node,
|
|
42
44
|
align?: AlignType,
|
|
@@ -46,6 +48,7 @@ declare type TypographyProps = {
|
|
|
46
48
|
marginBottom?: number,
|
|
47
49
|
marginTop?: number,
|
|
48
50
|
as?: ElementType,
|
|
51
|
+
productContext?: ProductContext,
|
|
49
52
|
"aria-hidden"?: boolean,
|
|
50
53
|
"aria-live"?: "polite" | "assertive" | "off",
|
|
51
54
|
...
|
|
@@ -57,6 +60,7 @@ declare var Typography: react.ForwardRefExoticComponent<{
|
|
|
57
60
|
export type {
|
|
58
61
|
AlignType,
|
|
59
62
|
ColorType,
|
|
63
|
+
ProductContext,
|
|
60
64
|
ThemeColorType,
|
|
61
65
|
TypographyProps,
|
|
62
66
|
VariantType,
|
package/native/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.tsx","../../src/Typography.tsx","../../../primitives-native/src/Text.tsx"],"sourcesContent":["export * from \"./Typography\";\nexport * from \"./types\";\n","import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType) => {\n switch (variant) {\n case \"h1\":\n return { fontSize: 40, fontWeight: \"700\", lineHeight: \"48px\" };\n case \"h2\":\n return { fontSize: 32, fontWeight: \"700\", lineHeight: \"38px\" };\n case \"h3\":\n return { fontSize: 28, fontWeight: \"700\", lineHeight: \"34px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"700\", lineHeight: \"28px\" };\n case \"display\":\n return { fontSize: 48, fontWeight: \"800\", lineHeight: \"58px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n const variantStyles = getVariantStyles(variant);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport { Text as RNText, TextStyle, AccessibilityRole } from \"react-native\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\n// Map web roles to React Native accessibility roles\nconst roleMap: Record<string, AccessibilityRole> = {\n alert: \"alert\",\n heading: \"header\",\n button: \"button\",\n link: \"link\",\n text: \"text\",\n};\n\nexport const Text: React.FC<TextProps> = ({\n children,\n color,\n fontSize,\n fontWeight,\n fontFamily,\n id,\n role,\n ...props\n}) => {\n // Extract the first font name from a comma-separated list (e.g. for web-style font stacks)\n let resolvedFontFamily = fontFamily\n ? fontFamily.split(\",\")[0].replace(/['\"]/g, \"\").trim()\n : undefined;\n\n // On native, if we don't have the custom font loaded, fall back to the system font\n if (\n resolvedFontFamily === \"Pilat Wide\" ||\n resolvedFontFamily === \"Pilat Wide Bold\" ||\n resolvedFontFamily === \"Aktiv Grotesk\"\n ) {\n resolvedFontFamily = undefined;\n }\n\n const style: TextStyle = {\n color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n fontWeight: fontWeight as TextStyle[\"fontWeight\"],\n fontFamily: resolvedFontFamily,\n textDecorationLine: props.textDecoration as TextStyle[\"textDecorationLine\"],\n };\n\n // Map role to React Native accessibilityRole\n const accessibilityRole = role ? roleMap[role] : undefined;\n\n return (\n <RNText style={style} testID={id} accessibilityRole={accessibilityRole}>\n {children}\n </RNText>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA2B;;;ACC3B,0BAA6D;AAgDzD;AA5CJ,IAAM,UAA6C;AAAA,EACjD,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,EAAE,UAAU,IAAI,YAAY,OAAO,YAAY,OAAO;AAAA,IAC/D,KAAK;AACH,aAAO,EAAE,UAAU,IAAI,YAAY,OAAO,YAAY,OAAO;AAAA,IAC/D;AACE,aAAO,EAAE,UAAU,IAAI,YAAY,OAAO,YAAY,OAAO;AAAA,EACjE;AACF;AAEO,IAAM,iBAAa;AAAA,EACxB,CACE;AAAA,IACE;AAAA,IACA,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,YAAY;AAAA,IACZ;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,MAAM,QAAI,iCAAgB;AAClC,UAAM,gBAAgB,iBAAiB,OAAO;AAC9C,UAAM,aAAa,SAAS,OAAO,KAAK;AACxC,UAAM,aAAa,MAAM;AACzB,UAAM,aAAa,iBAAiB,OAAO,IACvC,YAAY,UACZ,YAAY;AAEhB,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP,UAAU,cAAc;AAAA,QACxB,YAAY,cAAc;AAAA,QAC1B;AAAA,QACA,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,WAAW,UAAU,YAAY,SAAY;AAAA,UAC7C,YAAY,cAAc;AAAA,UAC1B,GAAI,UAAU;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["RNText","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.tsx","../../src/Typography.tsx","../../../primitives-native/src/Text.tsx"],"sourcesContent":["export * from \"./Typography\";\nexport * from \"./types\";\n","import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem, getTypographyTokens } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"h5\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType, typographyTokens?: any) => {\n // If typography tokens are provided from theme, use them\n if (typographyTokens) {\n const headingMap: Record<string, keyof typeof typographyTokens.heading> = {\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n h4: \"h4\",\n h5: \"h5\",\n };\n\n if (headingMap[variant]) {\n const token = typographyTokens.heading[headingMap[variant]];\n if (token) {\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n }\n\n if (variant === \"display\" && typographyTokens.basic?.display) {\n const token = typographyTokens.basic.display;\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n\n // Body variants\n const bodyMap: Record<string, string> = {\n bodyLg: \"body-lg\",\n bodyLgAccent: \"body-lg\",\n bodyLgParagraph: \"body-lg\",\n bodyMd: \"body-md\",\n bodyMdAccent: \"body-md\",\n bodyMdParagraph: \"body-md\",\n bodySm: \"body-sm\",\n bodySmAccent: \"body-sm\",\n bodySmParagraph: \"body-sm\",\n bodyXs: \"body-xs\",\n bodyXsAccent: \"body-xs\",\n bodyXsParagraph: \"body-xs\",\n };\n\n const bodyKey = bodyMap[variant];\n if (bodyKey && typographyTokens.basic?.[bodyKey]) {\n const token = typographyTokens.basic[bodyKey];\n let fontWeight = token.fontWeight;\n let lineHeight = token.lineHeight;\n\n if (variant.includes(\"Accent\") && token.accent) {\n fontWeight = token.accent.fontWeight;\n }\n\n if (variant.includes(\"Paragraph\") && token.paragraph) {\n lineHeight = token.paragraph.lineHeight;\n }\n\n return {\n fontSize: token.fontSize,\n fontWeight: String(fontWeight),\n lineHeight: lineHeight,\n };\n }\n }\n\n // Fallback to default styles (B2B mode for backwards compatibility)\n switch (variant) {\n case \"h1\":\n return { fontSize: 56, fontWeight: \"400\", lineHeight: \"68px\" };\n case \"h2\":\n return { fontSize: 48, fontWeight: \"400\", lineHeight: \"58px\" };\n case \"h3\":\n return { fontSize: 32, fontWeight: \"400\", lineHeight: \"38px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"400\", lineHeight: \"28px\" };\n case \"h5\":\n return { fontSize: 20, fontWeight: \"600\", lineHeight: \"24px\" };\n case \"display\":\n return { fontSize: 64, fontWeight: \"400\", lineHeight: \"78px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n productContext,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n // If productContext is provided, use tokens for that specific context\n // Otherwise, use the tokens from the theme (context)\n const typographyTokens = productContext\n ? getTypographyTokens(productContext)\n : (theme as any).typographyTokens;\n const variantStyles = getVariantStyles(variant, typographyTokens);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n numberOfLines={noWrap ? 1 : undefined}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport {\n Text as RNText,\n TextStyle,\n AccessibilityRole,\n StyleSheet,\n} from \"react-native\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst roleMap: Record<string, AccessibilityRole> = {\n alert: \"alert\",\n heading: \"header\",\n button: \"button\",\n link: \"link\",\n text: \"text\",\n};\n\nconst parseNumericValue = (\n value: string | number | undefined\n): number | undefined => {\n if (value === undefined) return undefined;\n if (typeof value === \"number\") return value;\n const parsed = parseFloat(value);\n return isNaN(parsed) ? undefined : parsed;\n};\n\nexport const Text: React.FC<TextProps> = ({\n children,\n color,\n fontSize,\n fontWeight,\n fontFamily,\n textAlign,\n lineHeight,\n numberOfLines,\n id,\n role,\n style: styleProp,\n ...props\n}) => {\n let resolvedFontFamily = fontFamily\n ? fontFamily.split(\",\")[0].replace(/['\"]/g, \"\").trim()\n : undefined;\n\n if (\n resolvedFontFamily === \"Pilat Wide\" ||\n resolvedFontFamily === \"Pilat Wide Bold\" ||\n resolvedFontFamily === \"Aktiv Grotesk\"\n ) {\n resolvedFontFamily = undefined;\n }\n\n const incomingStyle = StyleSheet.flatten(styleProp) as TextStyle | undefined;\n\n const baseStyle: TextStyle = {\n color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n fontWeight: fontWeight as TextStyle[\"fontWeight\"],\n fontFamily: resolvedFontFamily,\n textDecorationLine: props.textDecoration as TextStyle[\"textDecorationLine\"],\n textAlign: textAlign ?? incomingStyle?.textAlign,\n lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),\n marginTop: parseNumericValue(\n incomingStyle?.marginTop as number | string | undefined\n ),\n marginBottom: parseNumericValue(\n incomingStyle?.marginBottom as number | string | undefined\n ),\n };\n\n const accessibilityRole = role ? roleMap[role] : undefined;\n\n return (\n <RNText\n style={baseStyle}\n numberOfLines={numberOfLines}\n testID={id}\n accessibilityRole={accessibilityRole}\n >\n {children}\n </RNText>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA2B;;;ACC3B,0BAKO;AAmEH;AAhEJ,IAAM,UAA6C;AAAA,EACjD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAA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,UACZ,YAAY;AAEhB,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP,UAAU,cAAc;AAAA,QACxB,YAAY,cAAc;AAAA,QAC1B;AAAA,QACA,eAAe,SAAS,IAAI;AAAA,QAC5B,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,WAAW,UAAU,YAAY,SAAY;AAAA,UAC7C,YAAY,cAAc;AAAA,UAC1B,GAAI,UAAU;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["RNText","import_jsx_runtime"]}
|
package/native/index.mjs
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
|
|
4
4
|
// ../primitives-native/src/Text.tsx
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
Text as RNText,
|
|
7
|
+
StyleSheet
|
|
8
|
+
} from "react-native";
|
|
6
9
|
import { jsx } from "react/jsx-runtime";
|
|
7
10
|
var roleMap = {
|
|
8
11
|
alert: "alert",
|
|
@@ -11,33 +14,61 @@ var roleMap = {
|
|
|
11
14
|
link: "link",
|
|
12
15
|
text: "text"
|
|
13
16
|
};
|
|
17
|
+
var parseNumericValue = (value) => {
|
|
18
|
+
if (value === void 0) return void 0;
|
|
19
|
+
if (typeof value === "number") return value;
|
|
20
|
+
const parsed = parseFloat(value);
|
|
21
|
+
return isNaN(parsed) ? void 0 : parsed;
|
|
22
|
+
};
|
|
14
23
|
var Text = ({
|
|
15
24
|
children,
|
|
16
25
|
color,
|
|
17
26
|
fontSize,
|
|
18
27
|
fontWeight,
|
|
19
28
|
fontFamily,
|
|
29
|
+
textAlign,
|
|
30
|
+
lineHeight,
|
|
31
|
+
numberOfLines,
|
|
20
32
|
id,
|
|
21
33
|
role,
|
|
34
|
+
style: styleProp,
|
|
22
35
|
...props
|
|
23
36
|
}) => {
|
|
24
37
|
let resolvedFontFamily = fontFamily ? fontFamily.split(",")[0].replace(/['"]/g, "").trim() : void 0;
|
|
25
38
|
if (resolvedFontFamily === "Pilat Wide" || resolvedFontFamily === "Pilat Wide Bold" || resolvedFontFamily === "Aktiv Grotesk") {
|
|
26
39
|
resolvedFontFamily = void 0;
|
|
27
40
|
}
|
|
28
|
-
const
|
|
41
|
+
const incomingStyle = StyleSheet.flatten(styleProp);
|
|
42
|
+
const baseStyle = {
|
|
29
43
|
color,
|
|
30
44
|
fontSize: typeof fontSize === "number" ? fontSize : void 0,
|
|
31
45
|
fontWeight,
|
|
32
46
|
fontFamily: resolvedFontFamily,
|
|
33
|
-
textDecorationLine: props.textDecoration
|
|
47
|
+
textDecorationLine: props.textDecoration,
|
|
48
|
+
textAlign: textAlign ?? incomingStyle?.textAlign,
|
|
49
|
+
lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),
|
|
50
|
+
marginTop: parseNumericValue(
|
|
51
|
+
incomingStyle?.marginTop
|
|
52
|
+
),
|
|
53
|
+
marginBottom: parseNumericValue(
|
|
54
|
+
incomingStyle?.marginBottom
|
|
55
|
+
)
|
|
34
56
|
};
|
|
35
57
|
const accessibilityRole = role ? roleMap[role] : void 0;
|
|
36
|
-
return /* @__PURE__ */ jsx(
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
59
|
+
RNText,
|
|
60
|
+
{
|
|
61
|
+
style: baseStyle,
|
|
62
|
+
numberOfLines,
|
|
63
|
+
testID: id,
|
|
64
|
+
accessibilityRole,
|
|
65
|
+
children
|
|
66
|
+
}
|
|
67
|
+
);
|
|
37
68
|
};
|
|
38
69
|
|
|
39
70
|
// src/Typography.tsx
|
|
40
|
-
import { useDesignSystem } from "@xsolla/xui-core";
|
|
71
|
+
import { useDesignSystem, getTypographyTokens } from "@xsolla/xui-core";
|
|
41
72
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
42
73
|
var getColor = (color, theme) => {
|
|
43
74
|
if (color === "inherit") return void 0;
|
|
@@ -54,19 +85,79 @@ var getColor = (color, theme) => {
|
|
|
54
85
|
};
|
|
55
86
|
return colorMap[color] || color;
|
|
56
87
|
};
|
|
57
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
58
|
-
var getVariantStyles = (variant) => {
|
|
88
|
+
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "h5" || variant === "display";
|
|
89
|
+
var getVariantStyles = (variant, typographyTokens) => {
|
|
90
|
+
if (typographyTokens) {
|
|
91
|
+
const headingMap = {
|
|
92
|
+
h1: "h1",
|
|
93
|
+
h2: "h2",
|
|
94
|
+
h3: "h3",
|
|
95
|
+
h4: "h4",
|
|
96
|
+
h5: "h5"
|
|
97
|
+
};
|
|
98
|
+
if (headingMap[variant]) {
|
|
99
|
+
const token = typographyTokens.heading[headingMap[variant]];
|
|
100
|
+
if (token) {
|
|
101
|
+
return {
|
|
102
|
+
fontSize: token.fontSize,
|
|
103
|
+
fontWeight: String(token.fontWeight),
|
|
104
|
+
lineHeight: token.lineHeight
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (variant === "display" && typographyTokens.basic?.display) {
|
|
109
|
+
const token = typographyTokens.basic.display;
|
|
110
|
+
return {
|
|
111
|
+
fontSize: token.fontSize,
|
|
112
|
+
fontWeight: String(token.fontWeight),
|
|
113
|
+
lineHeight: token.lineHeight
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const bodyMap = {
|
|
117
|
+
bodyLg: "body-lg",
|
|
118
|
+
bodyLgAccent: "body-lg",
|
|
119
|
+
bodyLgParagraph: "body-lg",
|
|
120
|
+
bodyMd: "body-md",
|
|
121
|
+
bodyMdAccent: "body-md",
|
|
122
|
+
bodyMdParagraph: "body-md",
|
|
123
|
+
bodySm: "body-sm",
|
|
124
|
+
bodySmAccent: "body-sm",
|
|
125
|
+
bodySmParagraph: "body-sm",
|
|
126
|
+
bodyXs: "body-xs",
|
|
127
|
+
bodyXsAccent: "body-xs",
|
|
128
|
+
bodyXsParagraph: "body-xs"
|
|
129
|
+
};
|
|
130
|
+
const bodyKey = bodyMap[variant];
|
|
131
|
+
if (bodyKey && typographyTokens.basic?.[bodyKey]) {
|
|
132
|
+
const token = typographyTokens.basic[bodyKey];
|
|
133
|
+
let fontWeight = token.fontWeight;
|
|
134
|
+
let lineHeight = token.lineHeight;
|
|
135
|
+
if (variant.includes("Accent") && token.accent) {
|
|
136
|
+
fontWeight = token.accent.fontWeight;
|
|
137
|
+
}
|
|
138
|
+
if (variant.includes("Paragraph") && token.paragraph) {
|
|
139
|
+
lineHeight = token.paragraph.lineHeight;
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
fontSize: token.fontSize,
|
|
143
|
+
fontWeight: String(fontWeight),
|
|
144
|
+
lineHeight
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
59
148
|
switch (variant) {
|
|
60
149
|
case "h1":
|
|
61
|
-
return { fontSize:
|
|
150
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
62
151
|
case "h2":
|
|
63
|
-
return { fontSize:
|
|
152
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
64
153
|
case "h3":
|
|
65
|
-
return { fontSize:
|
|
154
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
66
155
|
case "h4":
|
|
67
|
-
return { fontSize: 24, fontWeight: "
|
|
156
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
157
|
+
case "h5":
|
|
158
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
68
159
|
case "display":
|
|
69
|
-
return { fontSize:
|
|
160
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
70
161
|
case "bodyLg":
|
|
71
162
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
72
163
|
case "bodyLgAccent":
|
|
@@ -105,10 +196,12 @@ var Typography = forwardRef(
|
|
|
105
196
|
marginBottom = 0,
|
|
106
197
|
marginTop = 0,
|
|
107
198
|
as,
|
|
199
|
+
productContext,
|
|
108
200
|
...rest
|
|
109
201
|
}, ref) => {
|
|
110
202
|
const { theme } = useDesignSystem();
|
|
111
|
-
const
|
|
203
|
+
const typographyTokens = productContext ? getTypographyTokens(productContext) : theme.typographyTokens;
|
|
204
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
112
205
|
const colorValue = getColor(color, theme);
|
|
113
206
|
const themefonts = theme.fonts;
|
|
114
207
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
|
@@ -122,6 +215,7 @@ var Typography = forwardRef(
|
|
|
122
215
|
fontSize: variantStyles.fontSize,
|
|
123
216
|
fontWeight: variantStyles.fontWeight,
|
|
124
217
|
fontFamily,
|
|
218
|
+
numberOfLines: noWrap ? 1 : void 0,
|
|
125
219
|
style: {
|
|
126
220
|
marginTop,
|
|
127
221
|
marginBottom,
|
package/native/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Typography.tsx","../../../primitives-native/src/Text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType) => {\n switch (variant) {\n case \"h1\":\n return { fontSize: 40, fontWeight: \"700\", lineHeight: \"48px\" };\n case \"h2\":\n return { fontSize: 32, fontWeight: \"700\", lineHeight: \"38px\" };\n case \"h3\":\n return { fontSize: 28, fontWeight: \"700\", lineHeight: \"34px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"700\", lineHeight: \"28px\" };\n case \"display\":\n return { fontSize: 48, fontWeight: \"800\", lineHeight: \"58px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n const variantStyles = getVariantStyles(variant);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport { Text as RNText, TextStyle, AccessibilityRole } from \"react-native\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\n// Map web roles to React Native accessibility roles\nconst roleMap: Record<string, AccessibilityRole> = {\n alert: \"alert\",\n heading: \"header\",\n button: \"button\",\n link: \"link\",\n text: \"text\",\n};\n\nexport const Text: React.FC<TextProps> = ({\n children,\n color,\n fontSize,\n fontWeight,\n fontFamily,\n id,\n role,\n ...props\n}) => {\n // Extract the first font name from a comma-separated list (e.g. for web-style font stacks)\n let resolvedFontFamily = fontFamily\n ? fontFamily.split(\",\")[0].replace(/['\"]/g, \"\").trim()\n : undefined;\n\n // On native, if we don't have the custom font loaded, fall back to the system font\n if (\n resolvedFontFamily === \"Pilat Wide\" ||\n resolvedFontFamily === \"Pilat Wide Bold\" ||\n resolvedFontFamily === \"Aktiv Grotesk\"\n ) {\n resolvedFontFamily = undefined;\n }\n\n const style: TextStyle = {\n color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n fontWeight: fontWeight as TextStyle[\"fontWeight\"],\n fontFamily: resolvedFontFamily,\n textDecorationLine: props.textDecoration as TextStyle[\"textDecorationLine\"],\n };\n\n // Map role to React Native accessibilityRole\n const accessibilityRole = role ? roleMap[role] : undefined;\n\n return (\n <RNText style={style} testID={id} accessibilityRole={accessibilityRole}>\n {children}\n </RNText>\n );\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACC3B,SAAS,QAAQ,cAA4C;AAgDzD;AA5CJ,IAAM,UAA6C;AAAA,EACjD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AACR;AAEO,IAAM,OAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AAEJ,MAAI,qBAAqB,aACrB,WAAW,MAAM,GAAG,EAAE,CAAC,EAAE,QAAQ,SAAS,EAAE,EAAE,KAAK,IACnD;AAGJ,MACE,uBAAuB,gBACvB,uBAAuB,qBACvB,uBAAuB,iBACvB;AACA,yBAAqB;AAAA,EACvB;AAEA,QAAM,QAAmB;AAAA,IACvB;AAAA,IACA,UAAU,OAAO,aAAa,WAAW,WAAW;AAAA,IACpD;AAAA,IACA,YAAY;AAAA,IACZ,oBAAoB,MAAM;AAAA,EAC5B;AAGA,QAAM,oBAAoB,OAAO,QAAQ,IAAI,IAAI;AAEjD,SACE,oBAAC,UAAO,OAAc,QAAQ,IAAI,mBAC/B,UACH;AAEJ;;;ADlDA,SAAS,uBAAuB;AAgG1B,gBAAAA,YAAA;AA7FN,IAAM,WAAW,CACf,OACA,UACuB;AACvB,MAAI,UAAU,UAAW,QAAO;AAEhC,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A,UACA;AAAA,UACA,WAAW,UAAU,YAAY,SAAY;AAAA,UAC7C,YAAY,cAAc;AAAA,UAC1B,GAAI,UAAU;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Typography.tsx","../../../primitives-native/src/Text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem, getTypographyTokens } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"h5\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType, typographyTokens?: any) => {\n // If typography tokens are provided from theme, use them\n if (typographyTokens) {\n const headingMap: Record<string, keyof typeof typographyTokens.heading> = {\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n h4: \"h4\",\n h5: \"h5\",\n };\n\n if (headingMap[variant]) {\n const token = typographyTokens.heading[headingMap[variant]];\n if (token) {\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n }\n\n if (variant === \"display\" && typographyTokens.basic?.display) {\n const token = typographyTokens.basic.display;\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n\n // Body variants\n const bodyMap: Record<string, string> = {\n bodyLg: \"body-lg\",\n bodyLgAccent: \"body-lg\",\n bodyLgParagraph: \"body-lg\",\n bodyMd: \"body-md\",\n bodyMdAccent: \"body-md\",\n bodyMdParagraph: \"body-md\",\n bodySm: \"body-sm\",\n bodySmAccent: \"body-sm\",\n bodySmParagraph: \"body-sm\",\n bodyXs: \"body-xs\",\n bodyXsAccent: \"body-xs\",\n bodyXsParagraph: \"body-xs\",\n };\n\n const bodyKey = bodyMap[variant];\n if (bodyKey && typographyTokens.basic?.[bodyKey]) {\n const token = typographyTokens.basic[bodyKey];\n let fontWeight = token.fontWeight;\n let lineHeight = token.lineHeight;\n\n if (variant.includes(\"Accent\") && token.accent) {\n fontWeight = token.accent.fontWeight;\n }\n\n if (variant.includes(\"Paragraph\") && token.paragraph) {\n lineHeight = token.paragraph.lineHeight;\n }\n\n return {\n fontSize: token.fontSize,\n fontWeight: String(fontWeight),\n lineHeight: lineHeight,\n };\n }\n }\n\n // Fallback to default styles (B2B mode for backwards compatibility)\n switch (variant) {\n case \"h1\":\n return { fontSize: 56, fontWeight: \"400\", lineHeight: \"68px\" };\n case \"h2\":\n return { fontSize: 48, fontWeight: \"400\", lineHeight: \"58px\" };\n case \"h3\":\n return { fontSize: 32, fontWeight: \"400\", lineHeight: \"38px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"400\", lineHeight: \"28px\" };\n case \"h5\":\n return { fontSize: 20, fontWeight: \"600\", lineHeight: \"24px\" };\n case \"display\":\n return { fontSize: 64, fontWeight: \"400\", lineHeight: \"78px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n productContext,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n // If productContext is provided, use tokens for that specific context\n // Otherwise, use the tokens from the theme (context)\n const typographyTokens = productContext\n ? getTypographyTokens(productContext)\n : (theme as any).typographyTokens;\n const variantStyles = getVariantStyles(variant, typographyTokens);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n numberOfLines={noWrap ? 1 : undefined}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport {\n Text as RNText,\n TextStyle,\n AccessibilityRole,\n StyleSheet,\n} from \"react-native\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst roleMap: Record<string, AccessibilityRole> = {\n alert: \"alert\",\n heading: \"header\",\n button: \"button\",\n link: \"link\",\n text: \"text\",\n};\n\nconst parseNumericValue = (\n value: string | number | undefined\n): number | undefined => {\n if (value === undefined) return undefined;\n if (typeof value === \"number\") return value;\n const parsed = parseFloat(value);\n return isNaN(parsed) ? undefined : parsed;\n};\n\nexport const Text: React.FC<TextProps> = ({\n children,\n color,\n fontSize,\n fontWeight,\n fontFamily,\n textAlign,\n lineHeight,\n numberOfLines,\n id,\n role,\n style: styleProp,\n ...props\n}) => {\n let resolvedFontFamily = fontFamily\n ? fontFamily.split(\",\")[0].replace(/['\"]/g, \"\").trim()\n : undefined;\n\n if (\n resolvedFontFamily === \"Pilat Wide\" ||\n resolvedFontFamily === \"Pilat Wide Bold\" ||\n resolvedFontFamily === \"Aktiv Grotesk\"\n ) {\n resolvedFontFamily = undefined;\n }\n\n const incomingStyle = StyleSheet.flatten(styleProp) as TextStyle | undefined;\n\n const baseStyle: TextStyle = {\n color,\n fontSize: typeof fontSize === \"number\" ? fontSize : undefined,\n fontWeight: fontWeight as TextStyle[\"fontWeight\"],\n fontFamily: resolvedFontFamily,\n textDecorationLine: props.textDecoration as TextStyle[\"textDecorationLine\"],\n textAlign: textAlign ?? incomingStyle?.textAlign,\n lineHeight: parseNumericValue(lineHeight ?? incomingStyle?.lineHeight),\n marginTop: parseNumericValue(\n incomingStyle?.marginTop as number | string | undefined\n ),\n marginBottom: parseNumericValue(\n incomingStyle?.marginBottom as number | string | undefined\n ),\n };\n\n const accessibilityRole = role ? roleMap[role] : undefined;\n\n return (\n <RNText\n style={baseStyle}\n numberOfLines={numberOfLines}\n testID={id}\n accessibilityRole={accessibilityRole}\n >\n {children}\n </RNText>\n );\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACC3B;AAAA,EACE,QAAQ;AAAA,EAGR;AAAA,OACK;AAmEH;AAhEJ,IAAM,UAA6C;AAAA,EACjD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,MAAM;AACR;AAEA,IAAM,oBAAoB,CACxB,UACuB;AACvB,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,SAAS,WAAW,KAAK;AAC/B,SAAO,MAAM,MAAM,IAAI,SAAY;AACrC;AAEO,IAAM,OAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,MAAM;AACJ,MAAI,qBAAqB,aACrB,WAAW,MAAM,GAAG,EAAE,CAAC,EAAE,QAAQ,SAAS,EAAE,EAAE,KAAK,IACnD;AAEJ,MACE,uBAAuB,gBACvB,uBAAuB,qBACvB,uBAAuB,iBACvB;AACA,yBAAqB;AAAA,EACvB;AAEA,QAAM,gBAAgB,WAAW,QAAQ,SAAS;AAElD,QAAM,YAAuB;AAAA,IAC3B;AAAA,IACA,UAAU,OAAO,aAAa,WAAW,WAAW;AAAA,IACpD;AAAA,IACA,YAAY;AAAA,IACZ,oBAAoB,MAAM;AAAA,IAC1B,WAAW,aAAa,eAAe;AAAA,IACvC,YAAY,kBAAkB,cAAc,eAAe,UAAU;AAAA,IACrE,WAAW;AAAA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QAAQ;AAAA,IACR,SAAS;AAAA,IACT,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,MAAM,IAAI,gBAAgB;AAGlC,UAAM,mBAAmB,iBACrB,oBAAoB,cAAc,IACjC,MAAc;AACnB,UAAM,gBAAgB,iBAAiB,SAAS,gBAAgB;AAChE,UAAM,aAAa,SAAS,OAAO,KAAK;AACxC,UAAM,aAAa,MAAM;AACzB,UAAM,aAAa,iBAAiB,OAAO,IACvC,YAAY,UACZ,YAAY;AAEhB,WACE,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA;AAAA,QACA,OAAO;AAAA,QACP,UAAU,cAAc;AAAA,QACxB,YAAY,cAAc;AAAA,QAC1B;AAAA,QACA,eAAe,SAAS,IAAI;AAAA,QAC5B,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,WAAW,UAAU,YAAY,SAAY;AAAA,UAC7C,YAAY,cAAc;AAAA,UAC1B,GAAI,UAAU;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["jsx"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-typography",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.114.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-core": "0.114.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.114.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|
package/web/index.d.mts
CHANGED
|
@@ -2,9 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ElementType } from 'react';
|
|
3
3
|
|
|
4
4
|
type AlignType = "center" | "inherit" | "justify" | "left" | "right";
|
|
5
|
-
type VariantType = "h1" | "h2" | "h3" | "h4" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
5
|
+
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
6
6
|
type ThemeColorType = "primary" | "secondary" | "tertiary" | "brand" | "brandSecondary" | "success" | "warning" | "alert" | "neutral";
|
|
7
7
|
type ColorType = ThemeColorType | "inherit";
|
|
8
|
+
type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|
|
8
9
|
interface TypographyProps extends Omit<any, "color"> {
|
|
9
10
|
children?: ReactNode;
|
|
10
11
|
align?: AlignType;
|
|
@@ -14,10 +15,11 @@ interface TypographyProps extends Omit<any, "color"> {
|
|
|
14
15
|
marginBottom?: number;
|
|
15
16
|
marginTop?: number;
|
|
16
17
|
as?: ElementType;
|
|
18
|
+
productContext?: ProductContext;
|
|
17
19
|
"aria-hidden"?: boolean;
|
|
18
20
|
"aria-live"?: "polite" | "assertive" | "off";
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
declare const Typography: react.ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & react.RefAttributes<any>>;
|
|
22
24
|
|
|
23
|
-
export { type AlignType, type ColorType, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
|
25
|
+
export { type AlignType, type ColorType, type ProductContext, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
package/web/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode, ElementType } from 'react';
|
|
3
3
|
|
|
4
4
|
type AlignType = "center" | "inherit" | "justify" | "left" | "right";
|
|
5
|
-
type VariantType = "h1" | "h2" | "h3" | "h4" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
5
|
+
type VariantType = "h1" | "h2" | "h3" | "h4" | "h5" | "display" | "bodyLg" | "bodyLgAccent" | "bodyLgParagraph" | "bodyMd" | "bodyMdAccent" | "bodyMdParagraph" | "bodySm" | "bodySmAccent" | "bodySmParagraph" | "bodyXs" | "bodyXsAccent" | "bodyXsParagraph";
|
|
6
6
|
type ThemeColorType = "primary" | "secondary" | "tertiary" | "brand" | "brandSecondary" | "success" | "warning" | "alert" | "neutral";
|
|
7
7
|
type ColorType = ThemeColorType | "inherit";
|
|
8
|
+
type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|
|
8
9
|
interface TypographyProps extends Omit<any, "color"> {
|
|
9
10
|
children?: ReactNode;
|
|
10
11
|
align?: AlignType;
|
|
@@ -14,10 +15,11 @@ interface TypographyProps extends Omit<any, "color"> {
|
|
|
14
15
|
marginBottom?: number;
|
|
15
16
|
marginTop?: number;
|
|
16
17
|
as?: ElementType;
|
|
18
|
+
productContext?: ProductContext;
|
|
17
19
|
"aria-hidden"?: boolean;
|
|
18
20
|
"aria-live"?: "polite" | "assertive" | "off";
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
declare const Typography: react.ForwardRefExoticComponent<Omit<TypographyProps, "ref"> & react.RefAttributes<any>>;
|
|
22
24
|
|
|
23
|
-
export { type AlignType, type ColorType, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
|
25
|
+
export { type AlignType, type ColorType, type ProductContext, type ThemeColorType, Typography, type TypographyProps, type VariantType };
|
package/web/index.js
CHANGED
|
@@ -55,6 +55,7 @@ var Text = ({
|
|
|
55
55
|
className,
|
|
56
56
|
id,
|
|
57
57
|
role,
|
|
58
|
+
numberOfLines: _numberOfLines,
|
|
58
59
|
...props
|
|
59
60
|
}) => {
|
|
60
61
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -87,19 +88,79 @@ var getColor = (color, theme) => {
|
|
|
87
88
|
};
|
|
88
89
|
return colorMap[color] || color;
|
|
89
90
|
};
|
|
90
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
91
|
-
var getVariantStyles = (variant) => {
|
|
91
|
+
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "h5" || variant === "display";
|
|
92
|
+
var getVariantStyles = (variant, typographyTokens) => {
|
|
93
|
+
if (typographyTokens) {
|
|
94
|
+
const headingMap = {
|
|
95
|
+
h1: "h1",
|
|
96
|
+
h2: "h2",
|
|
97
|
+
h3: "h3",
|
|
98
|
+
h4: "h4",
|
|
99
|
+
h5: "h5"
|
|
100
|
+
};
|
|
101
|
+
if (headingMap[variant]) {
|
|
102
|
+
const token = typographyTokens.heading[headingMap[variant]];
|
|
103
|
+
if (token) {
|
|
104
|
+
return {
|
|
105
|
+
fontSize: token.fontSize,
|
|
106
|
+
fontWeight: String(token.fontWeight),
|
|
107
|
+
lineHeight: token.lineHeight
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (variant === "display" && typographyTokens.basic?.display) {
|
|
112
|
+
const token = typographyTokens.basic.display;
|
|
113
|
+
return {
|
|
114
|
+
fontSize: token.fontSize,
|
|
115
|
+
fontWeight: String(token.fontWeight),
|
|
116
|
+
lineHeight: token.lineHeight
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const bodyMap = {
|
|
120
|
+
bodyLg: "body-lg",
|
|
121
|
+
bodyLgAccent: "body-lg",
|
|
122
|
+
bodyLgParagraph: "body-lg",
|
|
123
|
+
bodyMd: "body-md",
|
|
124
|
+
bodyMdAccent: "body-md",
|
|
125
|
+
bodyMdParagraph: "body-md",
|
|
126
|
+
bodySm: "body-sm",
|
|
127
|
+
bodySmAccent: "body-sm",
|
|
128
|
+
bodySmParagraph: "body-sm",
|
|
129
|
+
bodyXs: "body-xs",
|
|
130
|
+
bodyXsAccent: "body-xs",
|
|
131
|
+
bodyXsParagraph: "body-xs"
|
|
132
|
+
};
|
|
133
|
+
const bodyKey = bodyMap[variant];
|
|
134
|
+
if (bodyKey && typographyTokens.basic?.[bodyKey]) {
|
|
135
|
+
const token = typographyTokens.basic[bodyKey];
|
|
136
|
+
let fontWeight = token.fontWeight;
|
|
137
|
+
let lineHeight = token.lineHeight;
|
|
138
|
+
if (variant.includes("Accent") && token.accent) {
|
|
139
|
+
fontWeight = token.accent.fontWeight;
|
|
140
|
+
}
|
|
141
|
+
if (variant.includes("Paragraph") && token.paragraph) {
|
|
142
|
+
lineHeight = token.paragraph.lineHeight;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
fontSize: token.fontSize,
|
|
146
|
+
fontWeight: String(fontWeight),
|
|
147
|
+
lineHeight
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
92
151
|
switch (variant) {
|
|
93
152
|
case "h1":
|
|
94
|
-
return { fontSize:
|
|
153
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
95
154
|
case "h2":
|
|
96
|
-
return { fontSize:
|
|
155
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
97
156
|
case "h3":
|
|
98
|
-
return { fontSize:
|
|
157
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
99
158
|
case "h4":
|
|
100
|
-
return { fontSize: 24, fontWeight: "
|
|
159
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
160
|
+
case "h5":
|
|
161
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
101
162
|
case "display":
|
|
102
|
-
return { fontSize:
|
|
163
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
103
164
|
case "bodyLg":
|
|
104
165
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
105
166
|
case "bodyLgAccent":
|
|
@@ -138,10 +199,12 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
138
199
|
marginBottom = 0,
|
|
139
200
|
marginTop = 0,
|
|
140
201
|
as,
|
|
202
|
+
productContext,
|
|
141
203
|
...rest
|
|
142
204
|
}, ref) => {
|
|
143
205
|
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
144
|
-
const
|
|
206
|
+
const typographyTokens = productContext ? (0, import_xui_core.getTypographyTokens)(productContext) : theme.typographyTokens;
|
|
207
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
145
208
|
const colorValue = getColor(color, theme);
|
|
146
209
|
const themefonts = theme.fonts;
|
|
147
210
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
|
@@ -155,6 +218,7 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
155
218
|
fontSize: variantStyles.fontSize,
|
|
156
219
|
fontWeight: variantStyles.fontWeight,
|
|
157
220
|
fontFamily,
|
|
221
|
+
numberOfLines: noWrap ? 1 : void 0,
|
|
158
222
|
style: {
|
|
159
223
|
marginTop,
|
|
160
224
|
marginBottom,
|
package/web/index.js.flow
CHANGED
|
@@ -13,6 +13,7 @@ declare type VariantType =
|
|
|
13
13
|
| "h2"
|
|
14
14
|
| "h3"
|
|
15
15
|
| "h4"
|
|
16
|
+
| "h5"
|
|
16
17
|
| "display"
|
|
17
18
|
| "bodyLg"
|
|
18
19
|
| "bodyLgAccent"
|
|
@@ -37,6 +38,7 @@ declare type ThemeColorType =
|
|
|
37
38
|
| "alert"
|
|
38
39
|
| "neutral";
|
|
39
40
|
declare type ColorType = ThemeColorType | "inherit";
|
|
41
|
+
declare type ProductContext = "b2c" | "b2b" | "paystation" | "presentation";
|
|
40
42
|
declare type TypographyProps = {
|
|
41
43
|
children?: Node,
|
|
42
44
|
align?: AlignType,
|
|
@@ -46,6 +48,7 @@ declare type TypographyProps = {
|
|
|
46
48
|
marginBottom?: number,
|
|
47
49
|
marginTop?: number,
|
|
48
50
|
as?: ElementType,
|
|
51
|
+
productContext?: ProductContext,
|
|
49
52
|
"aria-hidden"?: boolean,
|
|
50
53
|
"aria-live"?: "polite" | "assertive" | "off",
|
|
51
54
|
...
|
|
@@ -57,6 +60,7 @@ declare var Typography: react.ForwardRefExoticComponent<{
|
|
|
57
60
|
export type {
|
|
58
61
|
AlignType,
|
|
59
62
|
ColorType,
|
|
63
|
+
ProductContext,
|
|
60
64
|
ThemeColorType,
|
|
61
65
|
TypographyProps,
|
|
62
66
|
VariantType,
|
package/web/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.tsx","../../src/Typography.tsx","../../../primitives-web/src/Text.tsx"],"sourcesContent":["export * from \"./Typography\";\nexport * from \"./types\";\n","import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType) => {\n switch (variant) {\n case \"h1\":\n return { fontSize: 40, fontWeight: \"700\", lineHeight: \"48px\" };\n case \"h2\":\n return { fontSize: 32, fontWeight: \"700\", lineHeight: \"38px\" };\n case \"h3\":\n return { fontSize: 28, fontWeight: \"700\", lineHeight: \"34px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"700\", lineHeight: \"28px\" };\n case \"display\":\n return { fontSize: 48, fontWeight: \"800\", lineHeight: \"58px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n const variantStyles = getVariantStyles(variant);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA2B;;;ACC3B,+BAAmB;AA8Bf;AA3BJ,IAAM,aAAa,yBAAAA,QAAO;AAAA,WACf,CAAC,UAAU,MAAM,SAAS,SAAS;AAAA,eAC/B,CAAC,UACZ,OAAO,MAAM,aAAa,WACtB,GAAG,MAAM,QAAQ,OACjB,MAAM,YAAY,SAAS;AAAA,iBAClB,CAAC,UAAU,MAAM,cAAc,QAAQ;AAAA,iBACvC,CAAC,UACd,MAAM,cACN,sGAAsG;AAAA,iBACzF,CAAC,UACd,OAAO,MAAM,eAAe,WACxB,GAAG,MAAM,UAAU,OACnB,MAAM,cAAc,SAAS;AAAA,iBACpB,CAAC,UAAU,MAAM,cAAc,QAAQ;AAAA,gBACxC,CAAC,UAAU,MAAM,aAAa,SAAS;AAAA,qBAClC,CAAC,UAAU,MAAM,kBAAkB,MAAM;AAAA;AAGvD,IAAM,OAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;;;ADpCA,sBAAgC;AAgG1B,IAAAC,sBAAA;AA7FN,IAAM,WAAW,CACf,OACA,UACuB;AACvB,MAAI,UAAU,UAAW,QAAO;AAEhC,QAAM,WAAmC;AAAA,IACvC,SAAS,OAAO,QAAQ,SAAS;AAAA,I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c;AAAA,UAC1B,GAAI,UAAU;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["styled","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../../src/index.tsx","../../src/Typography.tsx","../../../primitives-web/src/Text.tsx"],"sourcesContent":["export * from \"./Typography\";\nexport * from \"./types\";\n","import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem, getTypographyTokens } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"h5\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType, typographyTokens?: any) => {\n // If typography tokens are provided from theme, use them\n if (typographyTokens) {\n const headingMap: Record<string, keyof typeof typographyTokens.heading> = {\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n h4: \"h4\",\n h5: \"h5\",\n };\n\n if (headingMap[variant]) {\n const token = typographyTokens.heading[headingMap[variant]];\n if (token) {\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n }\n\n if (variant === \"display\" && typographyTokens.basic?.display) {\n const token = typographyTokens.basic.display;\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n\n // Body variants\n const bodyMap: Record<string, string> = {\n bodyLg: \"body-lg\",\n bodyLgAccent: \"body-lg\",\n bodyLgParagraph: \"body-lg\",\n bodyMd: \"body-md\",\n bodyMdAccent: \"body-md\",\n bodyMdParagraph: \"body-md\",\n bodySm: \"body-sm\",\n bodySmAccent: \"body-sm\",\n bodySmParagraph: \"body-sm\",\n bodyXs: \"body-xs\",\n bodyXsAccent: \"body-xs\",\n bodyXsParagraph: \"body-xs\",\n };\n\n const bodyKey = bodyMap[variant];\n if (bodyKey && typographyTokens.basic?.[bodyKey]) {\n const token = typographyTokens.basic[bodyKey];\n let fontWeight = token.fontWeight;\n let lineHeight = token.lineHeight;\n\n if (variant.includes(\"Accent\") && token.accent) {\n fontWeight = token.accent.fontWeight;\n }\n\n if (variant.includes(\"Paragraph\") && token.paragraph) {\n lineHeight = token.paragraph.lineHeight;\n }\n\n return {\n fontSize: token.fontSize,\n fontWeight: String(fontWeight),\n lineHeight: lineHeight,\n };\n }\n }\n\n // Fallback to default styles (B2B mode for backwards compatibility)\n switch (variant) {\n case \"h1\":\n return { fontSize: 56, fontWeight: \"400\", lineHeight: \"68px\" };\n case \"h2\":\n return { fontSize: 48, fontWeight: \"400\", lineHeight: \"58px\" };\n case \"h3\":\n return { fontSize: 32, fontWeight: \"400\", lineHeight: \"38px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"400\", lineHeight: \"28px\" };\n case \"h5\":\n return { fontSize: 20, fontWeight: \"600\", lineHeight: \"24px\" };\n case \"display\":\n return { fontSize: 64, fontWeight: \"400\", lineHeight: \"78px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n productContext,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n // If productContext is provided, use tokens for that specific context\n // Otherwise, use the tokens from the theme (context)\n const typographyTokens = productContext\n ? getTypographyTokens(productContext)\n : (theme as any).typographyTokens;\n const variantStyles = getVariantStyles(variant, typographyTokens);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n numberOfLines={noWrap ? 1 : undefined}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n numberOfLines: _numberOfLines,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA2B;;;ACC3B,+BAAmB;AA+Bf;AA5BJ,IAAM,aAAa,yBAAAA,QAAO;AAAA,WACf,CAAC,UAAU,MAAM,SAAS,SAAS;AAAA,eAC/B,CAAC,UACZ,OAAO,MAAM,aAAa,WACtB,GAAG,MAAM,QAAQ,OACjB,MAAM,YAAY,SAAS;AAAA,iBAClB,CAAC,UAAU,MAAM,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
|
21
21
|
role,
|
|
22
|
+
numberOfLines: _numberOfLines,
|
|
22
23
|
...props
|
|
23
24
|
}) => {
|
|
24
25
|
return /* @__PURE__ */ jsx(
|
|
@@ -34,7 +35,7 @@ var Text = ({
|
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
// src/Typography.tsx
|
|
37
|
-
import { useDesignSystem } from "@xsolla/xui-core";
|
|
38
|
+
import { useDesignSystem, getTypographyTokens } from "@xsolla/xui-core";
|
|
38
39
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
39
40
|
var getColor = (color, theme) => {
|
|
40
41
|
if (color === "inherit") return void 0;
|
|
@@ -51,19 +52,79 @@ var getColor = (color, theme) => {
|
|
|
51
52
|
};
|
|
52
53
|
return colorMap[color] || color;
|
|
53
54
|
};
|
|
54
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
55
|
-
var getVariantStyles = (variant) => {
|
|
55
|
+
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "h5" || variant === "display";
|
|
56
|
+
var getVariantStyles = (variant, typographyTokens) => {
|
|
57
|
+
if (typographyTokens) {
|
|
58
|
+
const headingMap = {
|
|
59
|
+
h1: "h1",
|
|
60
|
+
h2: "h2",
|
|
61
|
+
h3: "h3",
|
|
62
|
+
h4: "h4",
|
|
63
|
+
h5: "h5"
|
|
64
|
+
};
|
|
65
|
+
if (headingMap[variant]) {
|
|
66
|
+
const token = typographyTokens.heading[headingMap[variant]];
|
|
67
|
+
if (token) {
|
|
68
|
+
return {
|
|
69
|
+
fontSize: token.fontSize,
|
|
70
|
+
fontWeight: String(token.fontWeight),
|
|
71
|
+
lineHeight: token.lineHeight
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (variant === "display" && typographyTokens.basic?.display) {
|
|
76
|
+
const token = typographyTokens.basic.display;
|
|
77
|
+
return {
|
|
78
|
+
fontSize: token.fontSize,
|
|
79
|
+
fontWeight: String(token.fontWeight),
|
|
80
|
+
lineHeight: token.lineHeight
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const bodyMap = {
|
|
84
|
+
bodyLg: "body-lg",
|
|
85
|
+
bodyLgAccent: "body-lg",
|
|
86
|
+
bodyLgParagraph: "body-lg",
|
|
87
|
+
bodyMd: "body-md",
|
|
88
|
+
bodyMdAccent: "body-md",
|
|
89
|
+
bodyMdParagraph: "body-md",
|
|
90
|
+
bodySm: "body-sm",
|
|
91
|
+
bodySmAccent: "body-sm",
|
|
92
|
+
bodySmParagraph: "body-sm",
|
|
93
|
+
bodyXs: "body-xs",
|
|
94
|
+
bodyXsAccent: "body-xs",
|
|
95
|
+
bodyXsParagraph: "body-xs"
|
|
96
|
+
};
|
|
97
|
+
const bodyKey = bodyMap[variant];
|
|
98
|
+
if (bodyKey && typographyTokens.basic?.[bodyKey]) {
|
|
99
|
+
const token = typographyTokens.basic[bodyKey];
|
|
100
|
+
let fontWeight = token.fontWeight;
|
|
101
|
+
let lineHeight = token.lineHeight;
|
|
102
|
+
if (variant.includes("Accent") && token.accent) {
|
|
103
|
+
fontWeight = token.accent.fontWeight;
|
|
104
|
+
}
|
|
105
|
+
if (variant.includes("Paragraph") && token.paragraph) {
|
|
106
|
+
lineHeight = token.paragraph.lineHeight;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
fontSize: token.fontSize,
|
|
110
|
+
fontWeight: String(fontWeight),
|
|
111
|
+
lineHeight
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
56
115
|
switch (variant) {
|
|
57
116
|
case "h1":
|
|
58
|
-
return { fontSize:
|
|
117
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
59
118
|
case "h2":
|
|
60
|
-
return { fontSize:
|
|
119
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
61
120
|
case "h3":
|
|
62
|
-
return { fontSize:
|
|
121
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
63
122
|
case "h4":
|
|
64
|
-
return { fontSize: 24, fontWeight: "
|
|
123
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
124
|
+
case "h5":
|
|
125
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
65
126
|
case "display":
|
|
66
|
-
return { fontSize:
|
|
127
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
67
128
|
case "bodyLg":
|
|
68
129
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
69
130
|
case "bodyLgAccent":
|
|
@@ -102,10 +163,12 @@ var Typography = forwardRef(
|
|
|
102
163
|
marginBottom = 0,
|
|
103
164
|
marginTop = 0,
|
|
104
165
|
as,
|
|
166
|
+
productContext,
|
|
105
167
|
...rest
|
|
106
168
|
}, ref) => {
|
|
107
169
|
const { theme } = useDesignSystem();
|
|
108
|
-
const
|
|
170
|
+
const typographyTokens = productContext ? getTypographyTokens(productContext) : theme.typographyTokens;
|
|
171
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
109
172
|
const colorValue = getColor(color, theme);
|
|
110
173
|
const themefonts = theme.fonts;
|
|
111
174
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
|
@@ -119,6 +182,7 @@ var Typography = forwardRef(
|
|
|
119
182
|
fontSize: variantStyles.fontSize,
|
|
120
183
|
fontWeight: variantStyles.fontWeight,
|
|
121
184
|
fontFamily,
|
|
185
|
+
numberOfLines: noWrap ? 1 : void 0,
|
|
122
186
|
style: {
|
|
123
187
|
marginTop,
|
|
124
188
|
marginBottom,
|
package/web/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Typography.tsx","../../../primitives-web/src/Text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType) => {\n switch (variant) {\n case \"h1\":\n return { fontSize: 40, fontWeight: \"700\", lineHeight: \"48px\" };\n case \"h2\":\n return { fontSize: 32, fontWeight: \"700\", lineHeight: \"38px\" };\n case \"h3\":\n return { fontSize: 28, fontWeight: \"700\", lineHeight: \"34px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"700\", lineHeight: \"28px\" };\n case \"display\":\n return { fontSize: 48, fontWeight: \"800\", lineHeight: \"58px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n const variantStyles = getVariantStyles(variant);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACC3B,OAAO,YAAY;AA8Bf;AA3BJ,IAAM,aAAa,OAAO;AAAA,WACf,CAAC,UAAU,MAAM,SAAS,SAAS;AAAA,eAC/B,CAAC,UACZ,OAAO,MAAM,aAAa,WACtB,GAAG,MAAM,QAAQ,OACjB,MAAM,YAAY,SAAS;AAAA,iBAClB,CAAC,UAAU,MAAM,cAAc,QAAQ;AAAA,iBACvC,CAAC,UACd,MAAM,cACN,sGAAsG;AAAA,iBACzF,CAAC,UACd,OAAO,MAAM,eAAe,WACxB,GAAG,MAAM,UAAU,OACnB,MAAM,cAAc,SAAS;AAAA,iBACpB,CAAC,UAAU,MAAM,cAAc,QAAQ;AAAA,gBACxC,CAAC,UAAU,MAAM,aAAa,SAAS;AAAA,qBAClC,CAAC,UAAU,MAAM,kBAAkB,MAAM;AAAA;AAGvD,IAAM,OAA4B,CAAC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;;;ADpCA,SAAS,uBAAuB;AAgG1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AA,QACP,UAAU,cAAc;AAAA,QACxB,YAAY,cAAc;AAAA,QAC1B;AAAA,QACA,OAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA,WAAW,UAAU,YAAY,SAAY;AAAA,UAC7C,YAAY,cAAc;AAAA,UAC1B,GAAI,UAAU;AAAA,YACZ,UAAU;AAAA,YACV,cAAc;AAAA,YACd,YAAY;AAAA,UACd;AAAA,UACA,GAAG,KAAK;AAAA,QACV;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AAEA,WAAW,cAAc;","names":["jsx"]}
|
|
1
|
+
{"version":3,"sources":["../../src/Typography.tsx","../../../primitives-web/src/Text.tsx"],"sourcesContent":["import { forwardRef } from \"react\";\n// @ts-expect-error - this will be resolved at build time\nimport { Text } from \"@xsolla/xui-primitives\";\nimport { useDesignSystem, getTypographyTokens } from \"@xsolla/xui-core\";\nimport type { ColorType, TypographyProps, VariantType } from \"./types\";\n\nconst getColor = (\n color: ColorType | string,\n theme: any\n): string | undefined => {\n if (color === \"inherit\") return undefined;\n\n const colorMap: Record<string, string> = {\n primary: theme?.colors?.content?.primary,\n secondary: theme?.colors?.content?.secondary,\n tertiary: theme?.colors?.content?.tertiary,\n brand: theme?.colors?.content?.brand?.primary,\n brandSecondary: theme?.colors?.content?.brand?.secondary,\n success: theme?.colors?.content?.success?.primary,\n warning: theme?.colors?.content?.warning?.primary,\n alert: theme?.colors?.content?.alert?.primary,\n neutral: theme?.colors?.content?.neutral?.primary,\n };\n\n return colorMap[color] || color;\n};\n\nconst isHeadingVariant = (variant: VariantType): boolean =>\n variant === \"h1\" ||\n variant === \"h2\" ||\n variant === \"h3\" ||\n variant === \"h4\" ||\n variant === \"h5\" ||\n variant === \"display\";\n\nconst getVariantStyles = (variant: VariantType, typographyTokens?: any) => {\n // If typography tokens are provided from theme, use them\n if (typographyTokens) {\n const headingMap: Record<string, keyof typeof typographyTokens.heading> = {\n h1: \"h1\",\n h2: \"h2\",\n h3: \"h3\",\n h4: \"h4\",\n h5: \"h5\",\n };\n\n if (headingMap[variant]) {\n const token = typographyTokens.heading[headingMap[variant]];\n if (token) {\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n }\n\n if (variant === \"display\" && typographyTokens.basic?.display) {\n const token = typographyTokens.basic.display;\n return {\n fontSize: token.fontSize,\n fontWeight: String(token.fontWeight),\n lineHeight: token.lineHeight,\n };\n }\n\n // Body variants\n const bodyMap: Record<string, string> = {\n bodyLg: \"body-lg\",\n bodyLgAccent: \"body-lg\",\n bodyLgParagraph: \"body-lg\",\n bodyMd: \"body-md\",\n bodyMdAccent: \"body-md\",\n bodyMdParagraph: \"body-md\",\n bodySm: \"body-sm\",\n bodySmAccent: \"body-sm\",\n bodySmParagraph: \"body-sm\",\n bodyXs: \"body-xs\",\n bodyXsAccent: \"body-xs\",\n bodyXsParagraph: \"body-xs\",\n };\n\n const bodyKey = bodyMap[variant];\n if (bodyKey && typographyTokens.basic?.[bodyKey]) {\n const token = typographyTokens.basic[bodyKey];\n let fontWeight = token.fontWeight;\n let lineHeight = token.lineHeight;\n\n if (variant.includes(\"Accent\") && token.accent) {\n fontWeight = token.accent.fontWeight;\n }\n\n if (variant.includes(\"Paragraph\") && token.paragraph) {\n lineHeight = token.paragraph.lineHeight;\n }\n\n return {\n fontSize: token.fontSize,\n fontWeight: String(fontWeight),\n lineHeight: lineHeight,\n };\n }\n }\n\n // Fallback to default styles (B2B mode for backwards compatibility)\n switch (variant) {\n case \"h1\":\n return { fontSize: 56, fontWeight: \"400\", lineHeight: \"68px\" };\n case \"h2\":\n return { fontSize: 48, fontWeight: \"400\", lineHeight: \"58px\" };\n case \"h3\":\n return { fontSize: 32, fontWeight: \"400\", lineHeight: \"38px\" };\n case \"h4\":\n return { fontSize: 24, fontWeight: \"400\", lineHeight: \"28px\" };\n case \"h5\":\n return { fontSize: 20, fontWeight: \"600\", lineHeight: \"24px\" };\n case \"display\":\n return { fontSize: 64, fontWeight: \"400\", lineHeight: \"78px\" };\n case \"bodyLg\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"24px\" };\n case \"bodyLgAccent\":\n return { fontSize: 18, fontWeight: \"500\", lineHeight: \"24px\" };\n case \"bodyLgParagraph\":\n return { fontSize: 18, fontWeight: \"400\", lineHeight: \"26px\" };\n case \"bodyMd\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyMdAccent\":\n return { fontSize: 16, fontWeight: \"500\", lineHeight: \"20px\" };\n case \"bodyMdParagraph\":\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"22px\" };\n case \"bodySm\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"18px\" };\n case \"bodySmAccent\":\n return { fontSize: 14, fontWeight: \"500\", lineHeight: \"18px\" };\n case \"bodySmParagraph\":\n return { fontSize: 14, fontWeight: \"400\", lineHeight: \"20px\" };\n case \"bodyXs\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"16px\" };\n case \"bodyXsAccent\":\n return { fontSize: 12, fontWeight: \"500\", lineHeight: \"16px\" };\n case \"bodyXsParagraph\":\n return { fontSize: 12, fontWeight: \"400\", lineHeight: \"18px\" };\n default:\n return { fontSize: 16, fontWeight: \"400\", lineHeight: \"20px\" };\n }\n};\n\nexport const Typography = forwardRef<any, TypographyProps>(\n (\n {\n children,\n align = \"inherit\",\n noWrap = false,\n variant = \"bodyMd\",\n color = \"inherit\",\n marginBottom = 0,\n marginTop = 0,\n as,\n productContext,\n ...rest\n },\n ref\n ) => {\n const { theme } = useDesignSystem();\n // If productContext is provided, use tokens for that specific context\n // Otherwise, use the tokens from the theme (context)\n const typographyTokens = productContext\n ? getTypographyTokens(productContext)\n : (theme as any).typographyTokens;\n const variantStyles = getVariantStyles(variant, typographyTokens);\n const colorValue = getColor(color, theme);\n const themefonts = theme.fonts as Record<string, string>;\n const fontFamily = isHeadingVariant(variant)\n ? themefonts?.heading\n : themefonts?.body;\n\n return (\n <Text\n {...rest}\n ref={ref}\n as={as}\n color={colorValue}\n fontSize={variantStyles.fontSize}\n fontWeight={variantStyles.fontWeight}\n fontFamily={fontFamily}\n numberOfLines={noWrap ? 1 : undefined}\n style={{\n marginTop,\n marginBottom,\n textAlign: align === \"inherit\" ? undefined : align,\n lineHeight: variantStyles.lineHeight,\n ...(noWrap && {\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }),\n ...rest.style,\n }}\n >\n {children}\n </Text>\n );\n }\n);\n\nTypography.displayName = \"Typography\";\n","import React from \"react\";\nimport styled from \"styled-components\";\nimport { TextProps } from \"@xsolla/xui-primitives-core\";\n\nconst StyledText = styled.span<TextProps>`\n color: ${(props) => props.color || \"inherit\"};\n font-size: ${(props) =>\n typeof props.fontSize === \"number\"\n ? `${props.fontSize}px`\n : props.fontSize || \"inherit\"};\n font-weight: ${(props) => props.fontWeight || \"normal\"};\n font-family: ${(props) =>\n props.fontFamily ||\n '\"Aktiv Grotesk\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif'};\n line-height: ${(props) =>\n typeof props.lineHeight === \"number\"\n ? `${props.lineHeight}px`\n : props.lineHeight || \"inherit\"};\n white-space: ${(props) => props.whiteSpace || \"normal\"};\n text-align: ${(props) => props.textAlign || \"inherit\"};\n text-decoration: ${(props) => props.textDecoration || \"none\"};\n`;\n\nexport const Text: React.FC<TextProps> = ({\n style,\n className,\n id,\n role,\n numberOfLines: _numberOfLines,\n ...props\n}) => {\n return (\n <StyledText\n {...props}\n style={style}\n className={className}\n id={id}\n role={role}\n />\n );\n};\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACC3B,OAAO,YAAY;AA+Bf;AA5BJ,IAAM,aAAa,OAAO;AAAA,WACf,CAAC,UAAU,MAAM,SAAS,SAAS;AAAA,eAC/B,CAAC,UACZ,OAAO,MAAM,aAAa,WACtB,GAAG,MAAM,QAAQ,OACjB,MAAM,YAAY,SAA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