An open source design system that's fully customizable and agent ready
TypeScript
fix(CodeEditor): draw the border and gutter divider its styles declare (#9427)
Christopher Chedeau168011f26fcc
diff --git a/packages/build/src/babel.test.mjs b/packages/build/src/babel.test.mjsindex e8dc177853..c7947d3ed2 100644--- a/packages/build/src/babel.test.mjs+++ b/packages/build/src/babel.test.mjs@@ -4,17 +4,28 @@* @file babel.test.mjs* @description Verifies that the Astryx babel wrapper applies the configured* library StyleX class-name prefix to Astryx library files. The prefix- * defaults to `astryx` and remains configurable.+ * defaults to `astryx` and remains configurable. Its strict default+ * validation compiles every Core and Lab StyleX module, as the README's+ * webpack setup does.*/import {describe, it, expect} from 'vitest';+import * as fs from 'node:fs';import {createRequire} from 'node:module';+import * as path from 'node:path';+import {fileURLToPath} from 'node:url';const require = createRequire(import.meta.url);const babel = require('@babel/core');+const {globSync} = require('fast-glob');const astryxBabelPlugin = require('./babel.js');const {stylexOptions: buildStylexOptions} = require('./config.js');+const repoRoot = path.resolve(+ path.dirname(fileURLToPath(import.meta.url)),+ '../../..',+);+const SOURCE = `import * as stylex from '@stylexjs/stylex';export const styles = stylex.create({@@ -109,3 +120,51 @@ describe('Astryx babel wrapper -- library StyleX prefix', () => {).toBe('warn');});});++describe('Astryx babel wrapper -- Astryx source under the strict default', () => {+ // The README's webpack setup compiles Core and Lab source through this+ // plugin with its default `propertyValidationMode: 'throw'`, so a shorthand+ // StyleX rejects anywhere in them fails that app's build.+ it('compiles every Core and Lab StyleX module', () => {+ const core = path.join(repoRoot, 'packages/core/src');+ const failures = [];+ let compiled = 0;+ for (const name of ['core', 'lab']) {+ const files = globSync('**/*.{ts,tsx}', {+ cwd: path.join(repoRoot, 'packages', name, 'src'),+ absolute: true,+ ignore: ['**/*.test.*', '**/*.d.ts', '**/__tests__/**'],+ });+ for (const file of files) {+ const source = fs.readFileSync(file, 'utf8');+ if (!source.includes('@stylexjs/stylex')) continue;+ compiled += 1;+ try {+ babel.transformSync(source, {+ filename: file,+ babelrc: false,+ configFile: false,+ parserOpts: {plugins: ['typescript', 'jsx']},+ plugins: [+ [+ astryxBabelPlugin,+ {+ aliases: {+ '@astryxdesign/core/*': [path.join(core, '*')],+ '@astryxdesign/core': [core],+ },+ unstable_moduleResolution: {type: 'commonJS'},+ },+ ],+ ],+ });+ } catch (error) {+ failures.push(error.message.split('\n')[0]);+ }+ }+ }+ // Present first: the walk reached both packages' StyleX modules.+ expect(compiled).toBeGreaterThan(250);+ expect(failures).toEqual([]);+ }, 120_000);+});diff --git a/packages/lab/src/CodeEditor/CodeEditor.tsx b/packages/lab/src/CodeEditor/CodeEditor.tsxindex 4ca4fe5a9a..aeb8043f14 100644--- a/packages/lab/src/CodeEditor/CodeEditor.tsx+++ b/packages/lab/src/CodeEditor/CodeEditor.tsx@@ -58,7 +58,9 @@ const styles = stylex.create({display: 'flex',borderRadius: radiusVars['--radius-element'],backgroundColor: colorVars['--color-background-muted'],- border: `${borderVars['--border-width']} solid ${colorVars['--color-border']}`,+ borderWidth: borderVars['--border-width'],+ borderStyle: 'solid',+ borderColor: colorVars['--color-border'],overflow: 'hidden',},rootFocused: {@@ -73,7 +75,9 @@ const styles = stylex.create({textAlign: 'end',userSelect: 'none',color: colorVars['--color-text-disabled'],- borderRight: `${borderVars['--border-width']} solid ${colorVars['--color-border']}`,+ borderRightWidth: borderVars['--border-width'],+ borderRightStyle: 'solid',+ borderRightColor: colorVars['--color-border'],},gutterLine: {fontFamily: typographyVars['--font-family-code'],