RESOLVED FIXED 168172
Web Inspector: provide a way to show current value of CSS variables in style rules
https://bugs.webkit.org/show_bug.cgi?id=168172
Summary Web Inspector: provide a way to show current value of CSS variables in style ...
Blaze Burg
Reported 2017-02-11 09:14:01 PST
As we adopt more variables, it should be really easy to see the resolved values while tweaking rules. Two ideas i have: 1. Replace variables with their values when Shift or Option is held down 2. Show a popover with the value or variable declaration when hovering a variable token
Attachments
Patch (16.02 KB, patch)
2017-02-13 17:09 PST, Devin Rousso
no flags
[Image] After Patch is applied (28.05 KB, image/png)
2017-02-13 17:09 PST, Devin Rousso
no flags
Patch (16.19 KB, patch)
2017-02-13 17:56 PST, Devin Rousso
no flags
[Image] After Patch is applied (29.67 KB, image/png)
2017-02-13 17:58 PST, Devin Rousso
no flags
Radar WebKit Bug Importer
Comment 1 2017-02-11 09:14:36 PST
Nikita Vasilyev
Comment 2 2017-02-13 15:46:26 PST
I agree that seeing variable values would be very useful. Tangentially, I often want to see a computed value in the Rules panel. A couple of examples: font-size: 1.2em; // 16px top: calc(5vh - 12px); // 321px Switching to "Styles — Computed" and glancing over through the list of all properties is tedious.
Matt Baker
Comment 3 2017-02-13 16:40:54 PST
Over IRC Devin and I discussed some possible UI. Currently we're considering an equals sign swatch [=] immediately before the "var" token, similar to the editing swatches shown for the Bezier curves. Clicking the swatch would compute the value of the variable and display it in a popover. In the future, we could replace the "var(...)" text with the computed value, and allow live editing of the variable.
Devin Rousso
Comment 4 2017-02-13 17:09:04 PST
Devin Rousso
Comment 5 2017-02-13 17:09:21 PST
Created attachment 301421 [details] [Image] After Patch is applied
Devin Rousso
Comment 6 2017-02-13 17:56:10 PST
Devin Rousso
Comment 7 2017-02-13 17:58:56 PST
Created attachment 301431 [details] [Image] After Patch is applied
WebKit Commit Bot
Comment 8 2017-02-13 18:31:15 PST
Comment on attachment 301430 [details] Patch Clearing flags on attachment: 301430 Committed r212273: <http://trac.webkit.org/changeset/212273>
WebKit Commit Bot
Comment 9 2017-02-13 18:31:19 PST
All reviewed patches have been landed. Closing bug.
Blaze Burg
Comment 10 2017-02-13 18:58:02 PST
I think the '=' glyph is unintuitive, but better than nothing. Maybe an underline for the thing with a popup with be less awkward. (Tim, can you comment r=me in the bug? I couldn't tell in radar or email what happened to land this)
Joseph Pecoraro
Comment 11 2017-02-14 11:19:37 PST
Comment on attachment 301430 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=301430&action=review Nice! > Source/WebInspectorUI/UserInterface/Images/CSSVariable.svg:1 > +<?xml version="1.0" encoding="utf-8"?> Is there an Images/gtk variant? > Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationTextEditor.js:901 > + const dontCreateIfMissing = true; Nit: I find "doNot" to be much clearer than "dont" > Source/WebInspectorUI/UserInterface/Views/CodeMirrorTextMarkers.js:207 > + const variableRegex = /var\((--[\w-]+)\)/g; Technically non-ASCII and escape sequences are allowed in the identifier, not just \w. But That is likely to be so rare its fine to ignore it here for simplicity: https://www.w3.org/TR/css-syntax-3/#ident-token-diagram
Note You need to log in before you can comment on or make changes to this bug.