-
Notifications
You must be signed in to change notification settings - Fork 113
refactor: improve linear-weight-sum
performance
#1216
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 8227b08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Pull Request Overview
This PR refactors the handling of linear-weight-sum
by removing the JS fallback for zero values and moving that logic into CSS, using a clamp-based calculation to default the sum to 1 when it's zero.
- Simplified
transformLynxStyles.ts
by always emitting the raw value for--lynx-linear-weight-sum
- Updated
linear.css
to use nestedcalc
+clamp
to avoid division by zero at runtime - Bumped versions via a changeset
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
packages/web-platform/web-style-transformer/src/transformLynxStyles.ts | Remove JS check and override for 0 values on linear-weight-sum |
packages/web-platform/web-elements/src/common-css/linear.css | Add nested calc + clamp to default zero sum to 1 in CSS |
.changeset/hungry-hoops-sin.md | Version patch bump for the refactor |
linearWeightSum = '1'; | ||
} | ||
childStyle.push(['--lynx-linear-weight-sum', linearWeightSum]); | ||
childStyle.push(['--lynx-linear-weight-sum', value]); |
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.
Passing values like '0 !important' directly into the custom property will break CSS arithmetic (e.g., clamp
and multiplication). Consider stripping out !important
from the value and setting it via the style priority argument instead.
childStyle.push(['--lynx-linear-weight-sum', value]); | |
const important = value.includes('!important'); | |
const sanitizedValue = value.replace('!important', '').trim(); | |
childStyle.push(['--lynx-linear-weight-sum', sanitizedValue]); | |
// Optionally handle `important` if needed in the future |
Copilot uses AI. Check for mistakes.
@@ -285,7 +285,13 @@ list-item { | |||
list-item { | |||
flex-shrink: 0; |
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.
[nitpick] The nested calc
+ clamp
expression to default zero sums to 1 is non-obvious. Add a brief comment explaining the multiplier and clamp hack to help future maintainers understand the intent.
flex-shrink: 0; | |
flex-shrink: 0; | |
/* The following `calc` and `clamp` logic ensures that if | |
`--lynx-linear-weight-sum` is zero, it defaults to 1. This prevents | |
division by zero and ensures consistent behavior. */ |
Copilot uses AI. Check for mistakes.
CodSpeed Performance ReportMerging #1216 will not alter performanceComparing Summary
|
React Example#2510 Bundle Size — 234.7KiB (0%).8227b08(current) vs 4097b3f main#2501(baseline) Bundle metrics
|
Current #2510 |
Baseline #2501 |
|
---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
153 |
153 |
|
61 |
61 |
|
45.85% |
45.85% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
Current #2510 |
Baseline #2501 |
|
---|---|---|
145.76KiB |
145.76KiB |
|
88.94KiB |
88.94KiB |
Bundle analysis report Branch PupilTong:p/hw/weight-use-rename Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#2501 Bundle Size — 259.22KiB (~+0.01%).8227b08(current) vs 4097b3f main#2492(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch PupilTong:p/hw/weight-use-rename Project dashboard Generated by RelativeCI Documentation Report issue |
ccc1bd9
to
ac25977
Compare
ac25977
to
8227b08
Compare
No description provided.