@xsolla/xui-typography 0.113.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 +70 -8
- package/native/index.js.flow +4 -0
- package/native/index.js.map +1 -1
- package/native/index.mjs +71 -9
- 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 +70 -8
- package/web/index.js.flow +4 -0
- package/web/index.js.map +1 -1
- package/web/index.mjs +71 -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
|
@@ -108,19 +108,79 @@ var getColor = (color, theme) => {
|
|
|
108
108
|
};
|
|
109
109
|
return colorMap[color] || color;
|
|
110
110
|
};
|
|
111
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
112
|
-
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
|
+
}
|
|
113
171
|
switch (variant) {
|
|
114
172
|
case "h1":
|
|
115
|
-
return { fontSize:
|
|
173
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
116
174
|
case "h2":
|
|
117
|
-
return { fontSize:
|
|
175
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
118
176
|
case "h3":
|
|
119
|
-
return { fontSize:
|
|
177
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
120
178
|
case "h4":
|
|
121
|
-
return { fontSize: 24, fontWeight: "
|
|
179
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
180
|
+
case "h5":
|
|
181
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
122
182
|
case "display":
|
|
123
|
-
return { fontSize:
|
|
183
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
124
184
|
case "bodyLg":
|
|
125
185
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
126
186
|
case "bodyLgAccent":
|
|
@@ -159,10 +219,12 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
159
219
|
marginBottom = 0,
|
|
160
220
|
marginTop = 0,
|
|
161
221
|
as,
|
|
222
|
+
productContext,
|
|
162
223
|
...rest
|
|
163
224
|
}, ref) => {
|
|
164
225
|
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
165
|
-
const
|
|
226
|
+
const typographyTokens = productContext ? (0, import_xui_core.getTypographyTokens)(productContext) : theme.typographyTokens;
|
|
227
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
166
228
|
const colorValue = getColor(color, theme);
|
|
167
229
|
const themefonts = theme.fonts;
|
|
168
230
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
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 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;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;AACr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AEC;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;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,+BAAW,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,MACT,eAAe;AAAA,IACjB;AAAA,IACA,cAAc;AAAA,MACZ,eAAe;AAAA,IACjB;AAAA,EACF;AAEA,QAAM,oBAAoB,OAAO,QAAQ,IAAI,IA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ACA,GAAG;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,MAAM,QAAI,iCAAgB;AAGlC,UAAM,mBAAmB,qBACrB,qCAAoB,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;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
|
@@ -68,7 +68,7 @@ var Text = ({
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
// src/Typography.tsx
|
|
71
|
-
import { useDesignSystem } from "@xsolla/xui-core";
|
|
71
|
+
import { useDesignSystem, getTypographyTokens } from "@xsolla/xui-core";
|
|
72
72
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
73
73
|
var getColor = (color, theme) => {
|
|
74
74
|
if (color === "inherit") return void 0;
|
|
@@ -85,19 +85,79 @@ var getColor = (color, theme) => {
|
|
|
85
85
|
};
|
|
86
86
|
return colorMap[color] || color;
|
|
87
87
|
};
|
|
88
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
89
|
-
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
|
+
}
|
|
90
148
|
switch (variant) {
|
|
91
149
|
case "h1":
|
|
92
|
-
return { fontSize:
|
|
150
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
93
151
|
case "h2":
|
|
94
|
-
return { fontSize:
|
|
152
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
95
153
|
case "h3":
|
|
96
|
-
return { fontSize:
|
|
154
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
97
155
|
case "h4":
|
|
98
|
-
return { fontSize: 24, fontWeight: "
|
|
156
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
157
|
+
case "h5":
|
|
158
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
99
159
|
case "display":
|
|
100
|
-
return { fontSize:
|
|
160
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
101
161
|
case "bodyLg":
|
|
102
162
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
103
163
|
case "bodyLgAccent":
|
|
@@ -136,10 +196,12 @@ var Typography = forwardRef(
|
|
|
136
196
|
marginBottom = 0,
|
|
137
197
|
marginTop = 0,
|
|
138
198
|
as,
|
|
199
|
+
productContext,
|
|
139
200
|
...rest
|
|
140
201
|
}, ref) => {
|
|
141
202
|
const { theme } = useDesignSystem();
|
|
142
|
-
const
|
|
203
|
+
const typographyTokens = productContext ? getTypographyTokens(productContext) : theme.typographyTokens;
|
|
204
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
143
205
|
const colorValue = getColor(color, theme);
|
|
144
206
|
const themefonts = theme.fonts;
|
|
145
207
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
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 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,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;AAAA,EACL,GACA,QACG;AACH,UAAM,EAAE,MAAM,IAAI,gBAAgB;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,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"]}
|
|
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,a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AAA,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
|
@@ -88,19 +88,79 @@ var getColor = (color, theme) => {
|
|
|
88
88
|
};
|
|
89
89
|
return colorMap[color] || color;
|
|
90
90
|
};
|
|
91
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
92
|
-
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
|
+
}
|
|
93
151
|
switch (variant) {
|
|
94
152
|
case "h1":
|
|
95
|
-
return { fontSize:
|
|
153
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
96
154
|
case "h2":
|
|
97
|
-
return { fontSize:
|
|
155
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
98
156
|
case "h3":
|
|
99
|
-
return { fontSize:
|
|
157
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
100
158
|
case "h4":
|
|
101
|
-
return { fontSize: 24, fontWeight: "
|
|
159
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
160
|
+
case "h5":
|
|
161
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
102
162
|
case "display":
|
|
103
|
-
return { fontSize:
|
|
163
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
104
164
|
case "bodyLg":
|
|
105
165
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
106
166
|
case "bodyLgAccent":
|
|
@@ -139,10 +199,12 @@ var Typography = (0, import_react.forwardRef)(
|
|
|
139
199
|
marginBottom = 0,
|
|
140
200
|
marginTop = 0,
|
|
141
201
|
as,
|
|
202
|
+
productContext,
|
|
142
203
|
...rest
|
|
143
204
|
}, ref) => {
|
|
144
205
|
const { theme } = (0, import_xui_core.useDesignSystem)();
|
|
145
|
-
const
|
|
206
|
+
const typographyTokens = productContext ? (0, import_xui_core.getTypographyTokens)(productContext) : theme.typographyTokens;
|
|
207
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
146
208
|
const colorValue = getColor(color, theme);
|
|
147
209
|
const themefonts = theme.fonts;
|
|
148
210
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
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 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,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,eAAe;AAAA,EACf,GAAG;AACL,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;;;ADrCA,sBAAgC;AAgG1B,IAAAC,sBAAA;AA7FN,IAAM,WAAW,CACf,OACA,UACuB;AACvB,MAAI,UAAU,UAAW,QAAO;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AA,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":["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,OA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_runtime"]}
|
package/web/index.mjs
CHANGED
|
@@ -35,7 +35,7 @@ var Text = ({
|
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// src/Typography.tsx
|
|
38
|
-
import { useDesignSystem } from "@xsolla/xui-core";
|
|
38
|
+
import { useDesignSystem, getTypographyTokens } from "@xsolla/xui-core";
|
|
39
39
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
40
40
|
var getColor = (color, theme) => {
|
|
41
41
|
if (color === "inherit") return void 0;
|
|
@@ -52,19 +52,79 @@ var getColor = (color, theme) => {
|
|
|
52
52
|
};
|
|
53
53
|
return colorMap[color] || color;
|
|
54
54
|
};
|
|
55
|
-
var isHeadingVariant = (variant) => variant === "h1" || variant === "h2" || variant === "h3" || variant === "h4" || variant === "display";
|
|
56
|
-
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
|
+
}
|
|
57
115
|
switch (variant) {
|
|
58
116
|
case "h1":
|
|
59
|
-
return { fontSize:
|
|
117
|
+
return { fontSize: 56, fontWeight: "400", lineHeight: "68px" };
|
|
60
118
|
case "h2":
|
|
61
|
-
return { fontSize:
|
|
119
|
+
return { fontSize: 48, fontWeight: "400", lineHeight: "58px" };
|
|
62
120
|
case "h3":
|
|
63
|
-
return { fontSize:
|
|
121
|
+
return { fontSize: 32, fontWeight: "400", lineHeight: "38px" };
|
|
64
122
|
case "h4":
|
|
65
|
-
return { fontSize: 24, fontWeight: "
|
|
123
|
+
return { fontSize: 24, fontWeight: "400", lineHeight: "28px" };
|
|
124
|
+
case "h5":
|
|
125
|
+
return { fontSize: 20, fontWeight: "600", lineHeight: "24px" };
|
|
66
126
|
case "display":
|
|
67
|
-
return { fontSize:
|
|
127
|
+
return { fontSize: 64, fontWeight: "400", lineHeight: "78px" };
|
|
68
128
|
case "bodyLg":
|
|
69
129
|
return { fontSize: 18, fontWeight: "400", lineHeight: "24px" };
|
|
70
130
|
case "bodyLgAccent":
|
|
@@ -103,10 +163,12 @@ var Typography = forwardRef(
|
|
|
103
163
|
marginBottom = 0,
|
|
104
164
|
marginTop = 0,
|
|
105
165
|
as,
|
|
166
|
+
productContext,
|
|
106
167
|
...rest
|
|
107
168
|
}, ref) => {
|
|
108
169
|
const { theme } = useDesignSystem();
|
|
109
|
-
const
|
|
170
|
+
const typographyTokens = productContext ? getTypographyTokens(productContext) : theme.typographyTokens;
|
|
171
|
+
const variantStyles = getVariantStyles(variant, typographyTokens);
|
|
110
172
|
const colorValue = getColor(color, theme);
|
|
111
173
|
const themefonts = theme.fonts;
|
|
112
174
|
const fontFamily = isHeadingVariant(variant) ? themefonts?.heading : themefonts?.body;
|
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 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,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,eAAe;AAAA,EACf,GAAG;AACL,MAAM;AACJ,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAEJ;;;ADrCA,SAAS,uBAAuB;AAgG1B,gBAAAA,YAAA;AA7FN,IAAM,WAAW,CACf,OACA,UACuB;AACvB,MAAI,UAAU,UAAW,QAAO;AAEhC,QAAM,WAAmC;AAAA,IACvC,SAAS,OAAO,QAAQ,SAAS;AAAA,IACjC,WAAW,OAAO,QAAQ,SAAS;AAAA,IACnC,UAAU,OAAO,QAAQ,SAAS;AAAA,IAClC,OAAO,OAAO,QAA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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,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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