Last active
December 29, 2022 23:06
-
-
Save mattdanielbrown/6ac8a74bc67ce489eee9e12d6e2ecc25 to your computer and use it in GitHub Desktop.
SCSS @Mixins for setting color/colors for a property/properties.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Property Variable Definitions | |
| $color-prop : color; | |
| $bd-color-prop : border-color; | |
| $bg-color-prop : background-color; | |
| // Default argument (variable) values for @mxin color-for-props() | |
| $bg-and-bd-color-props : $bd-color-prop, $bg-color-prop; | |
| $bd-color-and-txt-color-props : $bd-color-prop, $color-prop; | |
| // Default argument (variable) values for @mxin color-for-props() | |
| $default-props-to-change : $bg-and-bd-color-props; | |
| $props-for-outline-button : $bd-color-and-txt-color-props; | |
| /** | |
| * @mixin Color For Properties | |
| * Set a single color for one property or a single color-related property pair. | |
| * @param : $color - <string> Color value to set property (property pair) to. | |
| * @param : $properties - <string> Property or property-pair to set value | |
| */ | |
| @mixin color-for-properties($color:$primary, $properties:$bg-and-bd-color-props) { | |
| @each $prop in $props { | |
| #{$prop}: $color; | |
| } | |
| } | |
| /** | |
| * @mixin Set Color For Properties | |
| * Specify a single color for which interaction state versions will be generated | |
| * and set to each of the specified property properties. | |
| * @param : $color - <string> Color value to set property (property pair) to. | |
| * @param : $properties... - <strings> Property or properties to set value | |
| * | |
| * @note: $properties... is a REST variable. | |
| */ | |
| @mixin set-color-for-properties($color:$primary, $properties...) { | |
| $_this-hover-color : hover-color($color); | |
| $_this-focus-color : focus-color($color); | |
| $_this-active-color: active-color($color); | |
| @each $property in $properties { | |
| #{$property}: $color; | |
| &:hover { #{$property} : $_this-hover-color; } | |
| &:focus { #{$property} : $_this-focus-color; } | |
| &:active { #{$property} : $_this-active-color; } | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment