_drawing.scss
ASCII text
1// generic drawing of more complex things 2 3@use "sass:list"; 4@use "../../theme"; 5@use "../../theme-color"; 6@use "../../shadow"; 7 8// 9// Ripple keyframes 10// 11 12@keyframes ripple { 13to { 14background-size: 1000% 1000%; 15} 16} 17 18@keyframes ripple-on-slider { 19to { 20background-size: auto, 1000% 1000%; 21} 22} 23 24@keyframes ripple-on-headerbar { 25from { 26background-image: radial-gradient(circle, theme-color.$primary 0%, transparent 0%); 27} 28 29to { 30background-image: radial-gradient(circle, theme-color.$primary 100%, transparent 100%); 31} 32} 33 34 35@mixin entry($t, $fc: theme-color.$primary) { 36// 37// entry 38// 39// $t: entry type 40// $fc: focus color 41// 42 43@if $t == normal { 44transition: theme.$transition, border-image theme.$ripple-duration theme.$ease-out; 45border-image: 46radial-gradient( 47circle closest-corner at center calc(100% - 1px), 48$fc 0%, 49transparent 0% 50) 2 / 0 0 0px; 51box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 52background-color: theme-color.entry-fill(theme-color.$on-surface); 53color: theme-color.$on-surface; 54caret-color: $fc; 55} 56 57@if $t == hover { 58box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 59background-color: theme-color.hover-overlay(theme-color.$on-surface, $on: theme-color.entry-fill(theme-color.$on-surface), $alt: true); 60} 61 62@if $t == focus { 63box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 64background-color: theme-color.focus-overlay(theme-color.$on-surface, $on: theme-color.entry-fill(theme-color.$on-surface)); 65} 66 67@if $t == checked { 68border-image: 69radial-gradient( 70circle closest-corner at center calc(100% - 1px), 71$fc 100%, 72transparent 100% 73) 2 / 0 0 2px; 74box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 75background-color: theme-color.focus-overlay(theme-color.$on-surface, $on: theme-color.entry-fill(theme-color.$on-surface)); 76} 77 78@if $t == disabled { 79box-shadow: inset 0 -1px theme-color.disabled-stroke(theme-color.$on-surface); 80background-color: theme-color.entry-fill(theme-color.$on-surface); 81color: theme-color.disabled(theme-color.$on-surface); 82} 83 84@if $t == raised-normal { 85transition: theme.$transition; 86border-image: none; 87box-shadow: shadow.$z1; 88background-color: if($fc == theme-color.$primary, theme-color.$surface-z8, $fc); 89color: if($fc == theme-color.$primary, theme-color.$on-surface, theme-color.on($fc)); 90caret-color: if($fc == theme-color.$primary, $fc, theme-color.on($fc)); 91} 92 93@if $t == raised-hover { 94box-shadow: shadow.$z3; 95} 96 97@if $t == raised-focus { 98border-image: none; 99box-shadow: shadow.$z3; 100} 101 102@if $t == raised-disabled { 103box-shadow: shadow.$z1; 104background-color: theme-color.$surface-z1; 105color: theme-color.disabled(theme-color.$on-surface); 106} 107} 108 109 110$ripple-transition-property: all, border-image, background-size, background-image; 111$ripple-transition-duration: theme.$state-duration, theme.$ripple-duration, theme.$ripple-fade-out-duration, theme.$ripple-opacity-fade-out-duration; 112$ripple-active-transition-duration: theme.$state-duration, theme.$ripple-duration, 0ms, 0ms; 113 114%ripple { 115transition-property: $ripple-transition-property; 116transition-duration: $ripple-transition-duration; 117transition-timing-function: theme.$ease-out; 118background-image: radial-gradient(circle, transparent 10%, transparent 10%); 119background-repeat: no-repeat; 120background-position: center; 121background-size: 1000% 1000%; 122 123&:active { 124transition-duration: $ripple-active-transition-duration; 125animation: ripple theme.$ripple-duration theme.$ease-out forwards; 126background-size: 0% 0%; 127} 128} 129 130@mixin ink-color($color, $on: transparent, $button-style: "none", $hover-alt: false, $opacity-modifier: 0) { 131@if $button-style == "raised" { 132$hover-alt: true; 133} 134 135@if $button-style == "flat" { 136box-shadow: none; 137} @else if $button-style == "outlined" { 138box-shadow: inset 0 0 0 1px theme-color.stroke(theme-color.$on-surface); 139} @else if $button-style == "raised" { 140box-shadow: shadow.$z2; 141} 142 143@if $button-style != "none" or $on != transparent { 144background-color: $on; 145} 146 147&:drop(active), 148&:hover { 149@if $button-style == "flat" { 150box-shadow: none; 151} @else if $button-style == "outlined" { 152box-shadow: inset 0 0 0 1px theme-color.stroke(theme-color.$on-surface); 153} @else if $button-style == "raised" { 154box-shadow: shadow.$z4; 155} 156 157background-color: theme-color.hover-overlay($color, $opacity-modifier: $opacity-modifier, $on: $on, $alt: $hover-alt); 158} 159 160&:focus { 161@if $button-style == "flat" { 162box-shadow: none; 163} @else if $button-style == "outlined" { 164box-shadow: inset 0 0 0 1px theme-color.stroke(theme-color.$on-surface); 165} @else if $button-style == "raised" { 166box-shadow: shadow.$z4; 167} 168 169background-color: theme-color.focus-overlay($color, $opacity-modifier: $opacity-modifier, $on: $on); 170} 171 172&:active { 173@if $button-style == "flat" { 174box-shadow: none; 175} @else if $button-style == "outlined" { 176box-shadow: inset 0 0 0 1px theme-color.stroke(theme-color.$on-surface); 177} @else if $button-style == "raised" { 178box-shadow: shadow.$z8; 179} 180 181background-image: radial-gradient(circle, theme-color.pressed-overlay($color, $opacity-modifier: $opacity-modifier) 10%, transparent 10%); 182} 183} 184 185@mixin list-item { 186&:drop(active):not(:active), 187&:hover:not(:active) { 188transition-property: $ripple-transition-property, background-color; 189transition-duration: $ripple-transition-duration, 0ms; 190} 191} 192 193 194@mixin overshoot($position) { 195$valid-positions: top, bottom, left, right; 196 197@if not list.index($valid-positions, $position) { 198@error "#{$position} is not a valid position. Expected one of #{$valid-positions}."; 199} 200 201$background-size: 200% 75%; 202 203@if $position == left or $position == right { 204$background-size: 75% 200%; 205} 206 207background-image: 208radial-gradient( 209farthest-side at $position, 210rgba(theme-color.$primary, .24) 99%, // For better antialiasing 211rgba(theme-color.$primary, 0) 100% // Don't use transparent i.e. rgba(0, 0, 0, 0) 212); 213background-size: $background-size; 214background-repeat: no-repeat; 215background-position: $position; 216} 217 218 219@mixin undershoot($side) { 220$valid-sides: top, bottom, left, right; 221 222@if not list.index($valid-sides, $side) { 223@error "#{$side} is not a valid side. Expected one of #{$valid-sides}."; 224} 225 226$_undershoot_color_dark: theme-color.stroke(theme-color.$on-surface); 227$_undershoot_color_light: transparent; 228 229$_gradient_dir: left; 230$_dash_bg_size: 12px 1px; 231$_gradient_repeat: repeat-x; 232$_bg_pos: left $side; 233 234@if $side == left or $side == right { 235$_gradient_dir: top; 236$_dash_bg_size: 1px 12px; 237$_gradient_repeat: repeat-y; 238$_bg_pos: $side top; 239} 240 241background-color: transparent; // shouldn't be needed, but better to be sure 242 243background-image: linear-gradient(to $_gradient_dir, // this is the dashed line 244$_undershoot_color_light 50%, 245$_undershoot_color_dark 50%); 246 247margin-#{$side}: 1px; 248background-size: $_dash_bg_size; 249background-repeat: $_gradient_repeat; 250background-origin: content-box; 251background-position: $_bg_pos; 252} 253