Style Settings #47
Replies: 8 comments 5 replies
-
|
i think the css variable approach is not only very smart, but extremely flexible, i can't wait to use all of this! |
Beta Was this translation helpful? Give feedback.
-
|
Nit, spatial UX, padding/margin/border etc side controls should be arranged spatially in a cross, condensing them to a box for condensing's sakes or dev familiarity(css clockwise usage) isn't great for merchants. |
Beta Was this translation helpful? Give feedback.
-
"css_variable": "--my-gap-variable", // create and set a css variableWouldn't css vars be more for section level decisions then , or how is shopify going to namespace the css-vars for each block |
Beta Was this translation helpful? Give feedback.
-
|
We have to also keep in mind nestable blocks means we could put all/some style based settings in a standalone block dedicated only to styles that then applies to the containing section, or block-siblings or block-children etc. When I have the time I'm working on a prototype of this concept to move advanced-customizations such as animations, grid layouts, responsive behavior, or overrides to an advanced-block; that advanced-block also would serve as an opt-in indicator when a merchant/theme has gone past basic support. |
Beta Was this translation helpful? Give feedback.
-
|
Hey, thanks for the clear examples and great progress. How can we use CSS variables with design tokens if they're only in |
Beta Was this translation helpful? Give feedback.
-
|
@adrocknaphobia — I am late to the party here but I have been thinking about css variables and grid systems this whole time. I want blocks to set themselves up according to the surrounding theme settings. I also want to give merchants the ability to overwrite any style at a granular level. I think css variables are the right interface for this, but what I really want is something like this: {
"type": "style.range",
"label": "Gap",
"id": "gap",
"max": 100,
"default": "--gap", // read-write interface
"units": ["px", "em"]
}The value of Letting |
Beta Was this translation helpful? Give feedback.
-
|
Hi @adrocknaphobia, I really like the idea of the css variables, but I´m wondering if there will be an option for it not to be set. I normally have a related checkbox setting to determine if the individual setting should be used or not, but I imagine that won´t work with the css variable setup? In general it would be nice to have more options for blank values, so we can use the setting only if it has a value and not having to add the additional checkbox setting. I`m imagining a css variable solution would work for our purpose if we were able to set the padding setting to blank, which then should not set the css variable. It could also be a solution where you can disable settings so the setting would just return blank even though you have a value in the setting. Really looking forward to what you come up with 🥳 |
Beta Was this translation helpful? Give feedback.
-
|
I agree with the other contributors who mentioned that they need support for design tokens and systems that require more than just a pixel value in a CSS variable. Setting font sizes in pixels is harmful to accessibility and merchants don't know what an em or a rem is, so if the solution basically makes editing pixel values easy, but requires theme developers to take on the burden of working with other units that might pose a better experience, that would be far from ideal. I would really want a system like to to be able to support arbitrary values, like a select that lets you change values at different breakpoints, as there needs to be a way to support the internationalization case. Some key things to consider, are that the directions for the margin/padding tokens must be reversed in RTL language. Code that supports RTL is probably using things like or 'text-align: start' under the hood, but the current text_alignment setting only outputs left, center and right, which means the theme developer has to be in charge of translating that into a less rigid system. Showing 'start', 'center' or 'end' is not ideal as merchants won't understand what that is. Another use case would be the display property, it's not uncommon for merchants to want to show or hide different sections on mobile or desktop, and I think being able to show them a label other than 'None' or 'Block' would be vital to making it feel good and usable. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone. Thanks again for all the feedback on our latest developer preview. We’re circling back here to share some of the ideas that have been refined through discussion here as well as through live conversations with several of you. We’re breaking up the various topics into individual threads so that we can post updates more quickly and create a more focused discussion. Please remember, these are just ideas of how we might implement a solution. We’re looking for your feedback to help mold the final product. In this thread, we want to dive into style settings.
In today's themes, it’s common to duplicate settings in order to set different customizations for mobile and desktop breakpoints. This leads to a lot of visual clutter for merchants in the sidebar. It can also create confusion when a merchant changes a mobile setting while previewing the desktop and vice versa.
With style settings, we’re introducing the ability to only show a single setting for customizations, and allow merchants to toggle between different breakpoints in the theme editor to edit the value of these settings for different breakpoints.
As part of the developer preview, we’ve shown how you can use the
| class_listfilter to catch style panel settings in Liquid, but we are also going to allow you to read the values of style settings in Liquid as you do other input settings. Style settings can hold multiple values, so you need to retrieve the values for each breakpoint.While this approach will work, it can be quite verbose to manually catch these settings in liquid, as you can see below. Even if they all share the same values, these inline styles get repeated across each instance of the block, so this can negatively impact the storefront performance of your theme.
To make it easier to apply settings, we’re exploring how we might make it possible for you to specify the CSS variable that you would like to use and Shopify will ensure it is populated with the right value based on the breakpoint. This will allow you to use the full expressiveness of CSS to achieve advanced use-cases, such as using calc, clamp, minmax, and more, without having to write a ton of boilerplate code.
// blocks/group.liquid {% stylesheet %} .my-class { gap: calc( var(--my-gap-variable) * 2); } {% endstylesheet %} <div class="my-class"> {% content_for "blocks" %} </div> {% schema %} { "name": "Group", "settings": [ { "type": "style.range", "label": "Gap", "id": "gap", "css_variable": "--my-gap-variable", // create and set a css variable "min": 0, "max": 100, "default": 20, "units": ["px", "em"] } ] } {% endschema %}In the example above, setting the
css_variableproperty to--my-gap-variablewill instruct Shopify to generate a CSS var in the linked stylesheet with the value of the gap setting. You may then rely on that variable throughout your theme.We hope this level of control and the minimal size of the generated CSS will be helpful to theme developers.
New Specialized Input Settings
Finally, we plan on introducing new specialized input settings for common controls – think margin, padding and more. So it’s not just panels, but individual settings that you can incorporate a la carte. They will be available with breakpoint aware
style.paddingand as plain settings with no breakpoint interactionpadding.{ "type": "padding", "label": "Padding", "id": "my_padding" }{ "type": "style.padding", "label": "Padding", "id": "my_padding" }As always, thanks for feedback and please let us know what you think. Keep in mind these are directional. The code isn't final but we want to share early and hear feedback.
Beta Was this translation helpful? Give feedback.
All reactions