-
Notifications
You must be signed in to change notification settings - Fork 0
perf: checkbox optimization — CSS indicators and flattened tree #28
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
Changes from all commits
2929bd8
f48ef2a
993a662
50e7b4b
2ae7797
11817fa
9e280e4
1756962
68fc1f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -35,6 +35,32 @@ describe('Checkbox', () => { | |||||||||||||||||||||||||
| expect(screen.getByTestId('indicator')).toBeInTheDocument(); | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| it('renders default checkbox without icon child elements', () => { | ||||||||||||||||||||||||||
| const { container } = renderWithTheme(<Checkbox.Item defaultChecked />); | ||||||||||||||||||||||||||
| const checkbox = screen.getByRole('checkbox'); | ||||||||||||||||||||||||||
| expect(checkbox).toHaveAttribute('data-checked'); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Flattened path: no LuCheck/LuMinus SVGs | ||||||||||||||||||||||||||
| const svgs = container.querySelectorAll('svg'); | ||||||||||||||||||||||||||
| expect(svgs).toHaveLength(0); | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| it('falls back to nested structure when keepIndicatorMounted is false', () => { | ||||||||||||||||||||||||||
| renderWithTheme( | ||||||||||||||||||||||||||
| <Checkbox.Item keepIndicatorMounted={false} defaultChecked> | ||||||||||||||||||||||||||
| Nested path | ||||||||||||||||||||||||||
| </Checkbox.Item>, | ||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||
| const checkbox = screen.getByRole('checkbox', { name: 'Nested path' }); | ||||||||||||||||||||||||||
| expect(checkbox).toHaveAttribute('data-checked'); | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| it('renders indeterminate state in flattened path', () => { | ||||||||||||||||||||||||||
| renderWithTheme(<Checkbox.Item indeterminate />); | ||||||||||||||||||||||||||
| const checkbox = screen.getByRole('checkbox'); | ||||||||||||||||||||||||||
| expect(checkbox).toHaveAttribute('data-indeterminate'); | ||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||
|
Comment on lines
+58
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Consider combining with existing indeterminate test or adding differentiating assertions. This test is very similar to the existing test at lines 21-26 (
💡 Suggested enhancement to differentiate the test it('renders indeterminate state in flattened path', () => {
- renderWithTheme(<Checkbox.Item indeterminate />);
+ const { container } = renderWithTheme(<Checkbox.Item indeterminate />);
const checkbox = screen.getByRole('checkbox');
expect(checkbox).toHaveAttribute('data-indeterminate');
+ // Flattened path: no LuMinus SVGs, uses CSS pseudo-element
+ expect(container.querySelectorAll('svg')).toHaveLength(0);
});📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| it('applies label position and spread layout attributes', () => { | ||||||||||||||||||||||||||
| renderWithTheme( | ||||||||||||||||||||||||||
| <Checkbox.Item labelPosition="start" layout="spread" defaultChecked> | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // Stub: react-syntax-highlighter is imported transitively via the base-ui | ||
| // barrel (CodeBlock component) but no benchmark uses it. The real package | ||
| // fails in CodSpeed's forked CJS process because refractor is ESM-only. | ||
| export const Prism = () => null; | ||
| export default () => null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lowercase
currentcolorfor Stylelint compliance.Stylelint reports
value-keyword-caseerrors. While bothcurrentColorandcurrentcolorare valid CSS, the project's linting configuration prefers lowercase.🔧 Proposed fix
.Indicator:empty::before { content: ''; display: none; position: absolute; top: 50%; left: 50%; width: 35%; height: 60%; - border-bottom: 2px solid currentColor; - border-right: 2px solid currentColor; + border-bottom: 2px solid currentcolor; + border-right: 2px solid currentcolor; transform: translate(-50%, -60%) rotate(45deg); }.Indicator:empty::after { content: ''; display: none; position: absolute; top: 50%; left: 50%; width: 55%; height: 2px; - background: currentColor; + background: currentcolor; border-radius: 1px; transform: translate(-50%, -50%); }.ControlIndicator::before { content: ''; display: none; position: absolute; top: 50%; left: 50%; width: 35%; height: 60%; - border-bottom: 2px solid currentColor; - border-right: 2px solid currentColor; + border-bottom: 2px solid currentcolor; + border-right: 2px solid currentcolor; transform: translate(-50%, -60%) rotate(45deg); }.ControlIndicator::after { content: ''; display: none; position: absolute; top: 50%; left: 50%; width: 55%; height: 2px; - background: currentColor; + background: currentcolor; border-radius: 1px; transform: translate(-50%, -50%); }Also applies to: 237-237, 276-277, 293-293
🧰 Tools
🪛 Stylelint (17.4.0)
[error] 220-220: Expected "currentColor" to be "currentcolor" (value-keyword-case)
(value-keyword-case)
[error] 221-221: Expected "currentColor" to be "currentcolor" (value-keyword-case)
(value-keyword-case)
🤖 Prompt for AI Agents