forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 9
/
_icon-button.scss
80 lines (65 loc) · 2.82 KB
/
_icon-button.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
@use 'sass:map';
@use 'sass:meta';
@use '@material/ripple/ripple-theme' as mdc-ripple-theme;
@use '../../token-utils';
@use '../../../theming/theming';
@use '../../../theming/inspection';
@use '../../../style/sass-utils';
// The prefix used to generate the fully qualified name for tokens in this file.
$prefix: (mat, icon-button);
// Tokens that can't be configured through Angular Material's current theming API,
// but may be in a future version of the theming API.
@function get-unthemable-tokens() {
@return ();
}
// Tokens that can be configured through Angular Material's color theming API.
@function get-color-tokens($theme) {
$is-dark: inspection.get-theme-type($theme) == dark;
$ripple-opacities: if($is-dark,
mdc-ripple-theme.$light-ink-opacities,
mdc-ripple-theme.$dark-ink-opacities
);
@return (
// Color of the element that shows the hover, focus and pressed states.
state-layer-color: inspection.get-theme-color($theme, foreground, base),
// Color of the element that shows the hover, focus and pressed states while disabled.
disabled-state-layer-color: inspection.get-theme-color($theme, foreground, base),
// Color of the ripple element.
ripple-color: inspection.get-theme-color($theme, foreground, base, 0.1),
// Opacity of the ripple when the button is hovered.
hover-state-layer-opacity: map.get($ripple-opacities, hover),
// Opacity of the ripple when the button is focused.
focus-state-layer-opacity: map.get($ripple-opacities, focus),
// Opacity of the ripple when the button is pressed.
pressed-state-layer-opacity: map.get($ripple-opacities, press),
);
}
// Generates the mapping for the properties that change based on the button palette color.
@function private-get-color-palette-color-tokens($theme, $palette-name) {
$color: inspection.get-theme-color($theme, $palette-name);
@return (
state-layer-color: $color,
ripple-color: if(meta.type-of($color) == color, rgba($color, 0.1), $color),
);
}
// Tokens that can be configured through Angular Material's typography theming API.
@function get-typography-tokens($theme) {
@return ();
}
// Tokens that can be configured through Angular Material's density theming API.
@function get-density-tokens($theme) {
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -3);
@return (
touch-target-display: if($density-scale < -1, none, block),
);
}
// Combines the tokens generated by the above functions into a single map with placeholder values.
// This is used to create token slots.
@function get-token-slots() {
@return sass-utils.deep-merge-all(
get-unthemable-tokens(),
get-color-tokens(token-utils.$placeholder-color-config),
get-typography-tokens(token-utils.$placeholder-typography-config),
get-density-tokens(token-utils.$placeholder-density-config)
);
}