-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path_mixins.scss
115 lines (103 loc) · 3.73 KB
/
_mixins.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
////
/// @group avatar
////
@import '~@react-md/icon/dist/mixins';
@import '~@react-md/theme/dist/helpers';
@import '~@react-md/typography/dist/mixins';
@import './variables';
/// Creates the styles for one of the avatar's theme values. This is mostly
/// going to be an internal helper mixin util.
///
/// @param {String} property - The property to set a `rmd-avatar-theme-values`
/// value to.
/// @param {String} theme-style - One of the keys of `rmd-avatar-theme-values`
/// to extract a value from.
/// @param {Color|String|Number} fallback [null] - A fallback value to use if
/// the css variable isn't set somehow. This will default to automatically
/// retrieving the default value from the `rmd-avatar-theme-values` map when
/// `null`.
@mixin rmd-avatar-theme($property, $theme-style: $property, $fallback: null) {
@include rmd-theme-apply-rmd-var(
$property,
$theme-style,
$rmd-avatar-theme-values,
avatar
);
}
/// Updates one of the avatar's theme variables with the new value for the
/// section of your app.
///
/// @param {String} theme-style - The avatar theme style type to update. This
/// should be one of the `$rmd-avatar-theme-values` keys.
/// @param {Color|String|Number} value - The new value to use.
@mixin rmd-avatar-theme-update-var($theme-style, $value) {
@include rmd-theme-update-rmd-var(
$value,
$theme-style,
$rmd-avatar-theme-values,
avatar
);
}
/// A mixin for updating the avatar's theme colors.
///
/// @example scss - Example Usage SCSS
/// .my-red-avatar {
/// @include rmd-avatar-color($rmd-red-500, $rmd-black-base);
/// }
///
/// .my-orange-avatar {
/// @include rmd-avatar-color($rmd-orange-500, $rmd-black-base);
/// }
///
/// @param {Color} background-color - The background color to apply
/// @param {Color} color - The text color to apply
@mixin rmd-avatar-color($background-color, $color) {
@include rmd-avatar-theme-update-var(background-color, $background-color);
@include rmd-avatar-theme-update-var(color, $color);
}
/// A mixin for creating the avatar color suffix class names from a color map.
/// It is not recommended to use this mixin for creating additional colors.
/// Instead use the `rmd-avatar-color` mixin with custom class names instead.
///
/// @param {Map} color-map [$rmd-avatar-colors] a map of color name suffixes and
/// a list of the background-color and color to apply
@mixin rmd-avatar-colors($color-map: $rmd-avatar-colors) {
@each $color-name, $values in $color-map {
@if length($values) != 2 {
@error 'Unable to create an avatar color because the list of values is not of length 2. The first value should be the background-color and the second should be the text color. "#{$values}"';
}
$class-name: 'rmd-avatar--' + $color-name;
.#{$class-name} {
@include rmd-avatar-color(nth($values, 1), nth($values, 2));
}
}
}
/// Creates all the styles for the avatar package as well as the root css
/// variable theme.
@mixin react-md-avatar {
@include rmd-theme-create-root-theme($rmd-avatar-theme-values, avatar);
.rmd-avatar {
@include rmd-typography-base;
@include rmd-icon-theme-update-var(color, currentColor);
@include rmd-avatar-theme(border-radius);
@include rmd-avatar-theme(font-size);
@include rmd-avatar-theme(height, size);
@include rmd-avatar-theme(width, size);
@include rmd-avatar-theme(border-color);
@include rmd-avatar-theme(background-color);
@include rmd-avatar-theme(color);
align-items: center;
border: 1px solid;
display: inline-flex;
flex-shrink: 0;
justify-content: center;
line-height: $rmd-avatar-line-height;
overflow: hidden;
&__image {
height: 100%;
width: auto;
}
}
// stylelint-disable order/order
@include rmd-avatar-colors;
}