improvement: enrich selection controls guidelines (Checkbox, Toggle, Radio, Select)#1060
improvement: enrich selection controls guidelines (Checkbox, Toggle, Radio, Select)#1060Cuervino wants to merge 10 commits intodevelopment/1.0from
Conversation
…deployments guideline - FocusBackgroundLevels: swatches + nested diagram for all 4 background levels - FocusRedline: SVG-annotated layout diagram with neutral wireframe palette, zone highlight borders, and dimension brackets for KPI row, toolbar, card header and card body - MDX: new "Background levels and layout" section at bottom of guideline Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Radio, Select) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Hello cuervino,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
Peer approvals must include at least 1 approval from the following list: |
| import { FocusVisibleStyle } from '../buttonv2/Buttonv2.component'; | ||
|
|
||
| const getDotSvgUrl = (color: string) => { | ||
| const encodedColor = color.replace('#', '%23'); |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 10 days ago
In general, to fix this kind of problem you should avoid ad‑hoc string replacement for escaping and instead either (1) use a standard encoder such as encodeURIComponent on the interpolated value, or (2) if you must use replace, use a global regular expression so that all occurrences are handled (/pattern/g), and ensure you also escape backslashes and any other relevant meta‑characters for the target context.
For this specific case, the safest and simplest fix without changing visible functionality is to ensure that every # in color is percent‑encoded before inserting it into the SVG data URL. The minimal change is to replace color.replace('#', '%23') with color.replace(/#/g, '%23'), which will encode all # characters while preserving the overall behavior for standard hex colors. An even more robust alternative would be const encodedColor = encodeURIComponent(color);, but that would also encode characters like (, ), and ,, which might alter behavior if the function is (now or in the future) passed CSS color formats that include those characters; so the least‑intrusive, targeted fix is to just make the existing replacement global.
All changes are confined to src/lib/components/radio/Radio.component.tsx, within the getDotSvgUrl helper. No new imports or additional helper methods are required.
| @@ -5,7 +5,7 @@ | ||
| import { FocusVisibleStyle } from '../buttonv2/Buttonv2.component'; | ||
|
|
||
| const getDotSvgUrl = (color: string) => { | ||
| const encodedColor = color.replace('#', '%23'); | ||
| const encodedColor = color.replace(/#/g, '%23'); | ||
| return `url('data:image/svg+xml,%3Csvg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg"%3E%3Ccircle cx="6.5" cy="6.5" r="3" fill="${encodedColor}"/%3E%3C/svg%3E')`; | ||
| }; | ||
|
|
Summary
Adds and rewrites Storybook guidelines for the four main selection controls, with a new shared page to help choose the right control.
AllStatesandDisabledWithReasonstories, cross-reference to Selection Controls. Playground removed from guideline.