Repository navigation
refactor(frontend): Replace Tailwind with StyleX #408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
efb0266
build(frontend): add StyleX with Scraps token bindings
nsdeschenes 5c894cf
refactor(frontend): migrate Pill to StyleX
nsdeschenes d55be79
refactor(frontend): let StyleX own Pill line height
nsdeschenes 8369e5f
refactor(frontend): replace Tailwind with StyleX across the app
nsdeschenes c610dd2
chore(frontend): enforce StyleX-only styling
nsdeschenes fcc54ca
refactor(frontend): generate Scraps tokens directly in StyleX
nsdeschenes 329c82c
fix(frontend): restore inline dropdown focus styling
nsdeschenes e792a60
refactor(frontend): adopt latest Preflight reset
nsdeschenes f688eee
fix(frontend): match the former dropdown focus appearance
nsdeschenes e34b654
refactor(frontend): share the dropdown input focus rule
nsdeschenes 10cf3f8
refactor(frontend): set a global input focus default
nsdeschenes 9f95771
fix(frontend): keep error description links inline
nsdeschenes b632686
refactor(frontend): use Scraps tokens for neutral borders
nsdeschenes f209c1d
Restore native input focus and hide downtime spinners
spalmurray ae49ece
chore(repo): merge latest main into nd/stylex-pill
nsdeschenes a6a4e76
fix(frontend): restore date chip click target
nsdeschenes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| export default { | ||
| meta: { | ||
| type: 'problem', | ||
| schema: [], | ||
| messages: { | ||
| className: | ||
| 'Define styles with StyleX and pass a typed style prop or spread stylex.props on a host element.', | ||
| inlineStyle: | ||
| 'Define host styles with stylex.create and apply them with stylex.props.', | ||
| cssProperties: 'Component style props must accept StyleXStyles, not CSSProperties.', | ||
| hostProps: | ||
| 'Pass StyleX styles to application components instead of spreading generated DOM props.', | ||
| }, | ||
| }, | ||
| create(context) { | ||
| function applicationComponent(node) { | ||
| const name = node.type === 'JSXMemberExpression' ? node.object : node; | ||
| if (name.type !== 'JSXIdentifier' || !/^[A-Z]/.test(name.name)) return false; | ||
| let scope = context.sourceCode.getScope(node); | ||
| while (scope && !scope.set.has(name.name)) scope = scope.upper; | ||
| const variable = scope?.set.get(name.name); | ||
| const imported = variable?.defs.find(def => def.type === 'ImportBinding'); | ||
| if (!imported) { | ||
| return Boolean( | ||
| variable?.defs.some( | ||
| def => | ||
| def.type === 'FunctionName' || | ||
| (def.type === 'Variable' && | ||
| ['ArrowFunctionExpression', 'FunctionExpression'].includes( | ||
| def.node.init?.type | ||
| )) | ||
| ) | ||
| ); | ||
| } | ||
| const source = imported.parent.source.value; | ||
| return ( | ||
| source.startsWith('components/') || | ||
| source.startsWith('./') || | ||
| source.startsWith('../') | ||
| ); | ||
| } | ||
|
|
||
| function initializer(node) { | ||
| if (node.type !== 'Identifier') return node; | ||
| let scope = context.sourceCode.getScope(node); | ||
| while (scope && !scope.set.has(node.name)) scope = scope.upper; | ||
| return scope?.set.get(node.name)?.defs.find(def => def.type === 'Variable')?.node | ||
| .init; | ||
| } | ||
|
|
||
| function spreadValues(node, seen = new Set()) { | ||
| if (!node || seen.has(node)) return []; | ||
| seen.add(node); | ||
| if ( | ||
| node.type === 'TSAsExpression' || | ||
| node.type === 'TSSatisfiesExpression' || | ||
| node.type === 'TSNonNullExpression' | ||
| ) { | ||
| return spreadValues(node.expression, seen); | ||
| } | ||
| if (node.type === 'Identifier') return spreadValues(initializer(node), seen); | ||
| if (node.type === 'ObjectExpression') { | ||
| return node.properties.flatMap(property => | ||
| property.type === 'SpreadElement' | ||
| ? spreadValues(property.argument, seen) | ||
| : [property] | ||
| ); | ||
| } | ||
| if ( | ||
| node.type === 'CallExpression' && | ||
| node.callee.type === 'MemberExpression' && | ||
| node.callee.object.name === 'stylex' && | ||
| node.callee.property.name === 'props' | ||
| ) { | ||
| return [node]; | ||
| } | ||
| return []; | ||
| } | ||
|
|
||
| return { | ||
| JSXAttribute(node) { | ||
| if (node.name.name === 'className') | ||
| context.report({node, messageId: 'className'}); | ||
| if ( | ||
| node.name.name === 'classNames' && | ||
| !context.filename.endsWith('/components/Calendar.tsx') | ||
| ) { | ||
| context.report({node, messageId: 'className'}); | ||
| } | ||
| if ( | ||
| node.name.name === 'style' && | ||
| (!applicationComponent(node.parent.name) || | ||
| node.value?.expression?.type === 'ObjectExpression') | ||
| ) { | ||
| context.report({node, messageId: 'inlineStyle'}); | ||
| } | ||
| }, | ||
| TSTypeReference(node) { | ||
| const name = | ||
| node.typeName.type === 'TSQualifiedName' | ||
| ? node.typeName.right.name | ||
| : node.typeName.name; | ||
| if (name === 'CSSProperties') context.report({node, messageId: 'cssProperties'}); | ||
| }, | ||
| AssignmentExpression(node) { | ||
| if ( | ||
| node.left.type === 'MemberExpression' && | ||
| node.left.object.type === 'MemberExpression' && | ||
| node.left.object.property.name === 'style' | ||
| ) { | ||
| context.report({node, messageId: 'inlineStyle'}); | ||
| } | ||
| }, | ||
| JSXSpreadAttribute(node) { | ||
| const host = node.parent.name; | ||
| const values = spreadValues(node.argument); | ||
| for (const value of values) { | ||
| if (value.type !== 'Property' || value.computed) continue; | ||
| const key = value.key.name ?? value.key.value; | ||
| if (key === 'className' || key === 'classNames') { | ||
| context.report({node: value, messageId: 'className'}); | ||
| } | ||
| if ( | ||
| key === 'style' && | ||
| (!applicationComponent(host) || value.value.type === 'ObjectExpression') | ||
| ) { | ||
| context.report({node: value, messageId: 'inlineStyle'}); | ||
| } | ||
| } | ||
| if (!values.some(value => value.type === 'CallExpression')) return; | ||
| if (applicationComponent(host)) { | ||
| context.report({node, messageId: 'hostProps'}); | ||
| } | ||
| }, | ||
| }; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.