An open source design system that's fully customizable and agent ready
TypeScript
fix xdstext weight (#989)
Andrey Godere96b6234a53c
diff --git a/packages/core/src/Text/XDSText.tsx b/packages/core/src/Text/XDSText.tsxindex 2907188b50..2b70db57e1 100644--- a/packages/core/src/Text/XDSText.tsx+++ b/packages/core/src/Text/XDSText.tsx@@ -13,7 +13,6 @@* - /apps/storybook/stories/Text.stories.tsx (storybook stories)*/-import {lazy, Suspense, useCallback, useRef, type ReactNode} from 'react';import * as stylex from '@stylexjs/stylex';import type {StyleXStyles} from '@stylexjs/stylex';@@ -28,6 +27,7 @@ import type {} from '../theme/types';import {colorStyles,+ defaultWeightByTypeStyles,weightStyles,displayStyles,truncationStyles,@@ -267,6 +267,7 @@ export function XDSText({xdsClassName('text', {type, color: resolvedColor}),stylex.props(colorStyles[resolvedColor],+ defaultWeightByTypeStyles[type],weight && weightStyles[weight],// Display: use truncation styles when maxLines > 0maxLines === 1diff --git a/packages/core/src/Text/text.stylex.ts b/packages/core/src/Text/text.stylex.tsindex c583803685..617869edca 100644--- a/packages/core/src/Text/text.stylex.ts+++ b/packages/core/src/Text/text.stylex.ts@@ -9,7 +9,7 @@*/import * as stylex from '@stylexjs/stylex';-import {colorVars, fontWeightVars} from '../theme/tokens.stylex';+import {colorVars, fontWeightVars, typeScaleVars} from '../theme/tokens.stylex';// =============================================================================// Color Styles@@ -55,6 +55,37 @@ export const weightStyles = stylex.create({},});+// =============================================================================+// Default Weight by Type (matches theme type-scale tokens)+// =============================================================================++export const defaultWeightByTypeStyles = stylex.create({+ body: {+ fontWeight: typeScaleVars['--text-body-weight'],+ },+ large: {+ fontWeight: typeScaleVars['--text-large-weight'],+ },+ label: {+ fontWeight: typeScaleVars['--text-label-weight'],+ },+ code: {+ fontWeight: typeScaleVars['--text-code-weight'],+ },+ supporting: {+ fontWeight: typeScaleVars['--text-supporting-weight'],+ },+ 'display-1': {+ fontWeight: typeScaleVars['--text-display-1-weight'],+ },+ 'display-2': {+ fontWeight: typeScaleVars['--text-display-2-weight'],+ },+ 'display-3': {+ fontWeight: typeScaleVars['--text-display-3-weight'],+ },+});+// =============================================================================// Display Styles// =============================================================================diff --git a/packages/core/src/theme/expandTypeScale.ts b/packages/core/src/theme/expandTypeScale.tsindex 89c2b1b1dd..2ccb6e2805 100644--- a/packages/core/src/theme/expandTypeScale.ts+++ b/packages/core/src/theme/expandTypeScale.ts@@ -395,7 +395,6 @@ export function generateTypeScaleComponents(textRules[`type:${type}`] = {fontFamily: TEXT_FONT_FAMILIES[type],fontSize: `var(--text-${type}-size)`,- fontWeight: `var(--text-${type}-weight)`,lineHeight: `var(--text-${type}-leading)`,};}