Introduction
We have begun implementing a new pattern for customizing and generating CSS properties in Clay CSS. It uses the mixin, clay-css, that accepts a Sass map as a parameter to generate CSS properties and values for a selector. The valid property names are listed in the link.
Implications
In the past, we have followed the pattern of mapping a Sass variable to to a single CSS property. We are converting to using maps instead. The name of the Sass map variable will refer to the CSS selector of the component. For example the variables:
have been combined into a single map:
The variable name will resemble the CSS selector; $alert-close
maps to .alert .close
. The main motivation behind this change was to reduce the number of variables we had to define and increase the number of properties we could customize.
We will be deprecating most variables that map to a single CSS property. We encourage updating your variable themes to this new map pattern where ever possible. It will make future upgrades easier and less time consuming.
Variable Key Names
We are converting key names like bg
, bg-image
, padding-x
, padding-y
, margin-x
, and margin-y
to match the CSS property they are referencing. They are now background-color
and background-image
. The keys padding-x
and padding-y
have been split into padding-left
, padding-right
, padding-bottom
, and padding-top
. The same goes for margin-x
and margin-y
.
Key names like hover-bg
, focus-border-color
, active-focus-box-shadow
, and disabled-opacity
have been nested inside maps with keys with the same name as the pseudo classes they represent. An example:
The old key names are still valid and will win over new key names. One quirk that may arise from using the new key names is if you are extending a variable theme that still uses the old keys or if Clay CSS forgot to convert a map to the new keys. The old keys will win even if you did everything right. An example:
Unset Properties
Properties can be unset in maps by setting the value to $clay-unset
or $c-unset
. The variable $clay-unset
contains the key word clay-unset
. Clay functions and mixins will return null
when it encounters that key word. This is a workaround for Sass outputting properties like background-color: null;
. Example below:
Conclusion
We believe these updates will provide more value. It enables a developer to add, remove, and replace CSS properties inside clay.css instead of duplicating and overwriting them. We won't be removing compatibility for any of the old variables or key names any time soon. We understand upgrading is a difficult process and want to make any transitions as smooth as possible.