Skip to content

Commit e77eabb

Browse files
committed
add md-theme-property-value mixin
1 parent 7829799 commit e77eabb

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/theme/mixins.scss

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,49 @@
168168
#{$property}: var(--md-theme-#{$md-current-theme}-#{$type}#{$variant}, $value);
169169
}
170170

171+
172+
/**
173+
* Theme a single css property with a value
174+
* ---
175+
* Usage example:
176+
*
177+
* .md-button {
178+
* min-width: 88px;
179+
* height: 40px;
180+
* display: inline-block;
181+
* border-radius: 2px;
182+
* transition: .3s ease;
183+
*
184+
* @include md-theme-component() {
185+
* @include md-theme-property(box-shadow, 0 0 3px, primary);
186+
* }
187+
* }
188+
*
189+
* ---
190+
* @access public
191+
* @param {string} $property —  The css property
192+
* @param {string} $attribute —  The css attribute value
193+
* @param {string} $type —  A palette type
194+
* @param {string} $background —  The background color to analyse contrast
195+
* @param {number} $opacity —  The opacity amount
196+
*/
197+
198+
@mixin md-theme-property-value ($property, $attribute, $type, $background: "", $opacity: "") {
199+
$value: md-theme($type, $background);
200+
$variant: null;
201+
202+
@if $background != "" {
203+
$variant: -on-#{$background};
204+
}
205+
206+
@if $opacity != "" {
207+
$value: rgba($value, $opacity);
208+
}
209+
210+
#{$property}: $attribute $value;
211+
#{$property}: $attribute var(--md-theme-#{$md-current-theme}-#{$type}#{$variant}, $value);
212+
}
213+
171214
/**
172215
* Theme a single css property darkening the color by a certain amount
173216
* ---

0 commit comments

Comments
 (0)