_drawing.scss
ASCII text
1// generic drawing of more complex things 2 3@use "sass:list"; 4@use "../../theme"; 5@use "../../theme-color"; 6 7// 8// Ripple keyframes 9// 10 11@keyframes ripple { 12to { 13background-size: 1000% 1000%; 14} 15} 16 17@keyframes ripple-on-slider { 18to { 19background-size: auto, 1000% 1000%; 20} 21} 22 23@keyframes ripple-on-headerbar { 24from { 25background-image: radial-gradient(circle, theme-color.$primary 0%, transparent 0%); 26} 27 28to { 29background-image: radial-gradient(circle, theme-color.$primary 100%, transparent 0%); 30} 31} 32 33 34@mixin entry($t, $fc: theme-color.$primary) { 35// 36// entry 37// 38// $t: entry type 39// $fc: focus color 40// 41 42@if $t == normal { 43transition: theme.$transition, border-image theme.$ripple-fade-in-duration theme.$ease-out; 44border-image: 45radial-gradient( 46circle closest-corner at center calc(100% - 1px), 47$fc 0%, 48transparent 0% 49) 2 / 0 0 0; 50box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 51background-color: theme-color.entry-fill(theme-color.$on-surface); 52color: theme-color.$on-surface; 53caret-color: $fc; 54} 55 56@if $t == hover { 57box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 58background-color: theme-color.hover-overlay(theme-color.$on-surface, $on: theme-color.entry-fill(theme-color.$on-surface), $alt: true); 59} 60 61@if $t == focus { 62box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 63background-color: theme-color.focus-overlay(theme-color.$on-surface, $on: theme-color.entry-fill(theme-color.$on-surface)); 64} 65 66@if $t == checked { 67border-image: 68radial-gradient( 69circle closest-corner at center calc(100% - 1px), 70$fc 100%, 71transparent 0% 72) 2 / 0 0 2px; 73box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc); 74background-color: theme-color.focus-overlay(theme-color.$on-surface, $on: theme-color.entry-fill(theme-color.$on-surface)); 75} 76 77@if $t == disabled { 78box-shadow: inset 0 -1px theme-color.disabled-stroke(theme-color.$on-surface); 79background-color: theme-color.entry-fill(theme-color.$on-surface); 80color: theme-color.disabled(theme-color.$on-surface); 81} 82 83@if $t == raised-normal { 84transition: theme.$transition; 85border-image: none; 86box-shadow: theme.$shadow-z1; 87background-color: if($fc == theme-color.$primary, theme-color.$surface-z8, $fc); 88color: if($fc == theme-color.$primary, theme-color.$on-surface, theme-color.on($fc)); 89caret-color: if($fc == theme-color.$primary, $fc, theme-color.on($fc)); 90} 91 92@if $t == raised-hover { 93box-shadow: theme.$shadow-z3; 94} 95 96@if $t == raised-focus { 97border-image: none; 98box-shadow: theme.$shadow-z3; 99} 100 101@if $t == raised-disabled { 102box-shadow: theme.$shadow-z1; 103background-color: theme-color.$surface-z1; 104color: theme-color.disabled(theme-color.$on-surface); 105} 106} 107 108 109$ripple-transition-property: all, border-image, background-size, background-image; 110$ripple-transition-duration: theme.$duration, theme.$ripple-fade-in-duration, theme.$ripple-fade-out-duration, theme.$ripple-fade-out-opacity-duration; 111$ripple-active-transition-duration: theme.$duration, theme.$ripple-fade-in-duration, 0ms, 0ms; 112 113%ripple { 114transition-property: $ripple-transition-property; 115transition-duration: $ripple-transition-duration; 116transition-timing-function: theme.$ease-out; 117outline: none; 118background-image: radial-gradient(circle, transparent 10%, transparent 0%); 119background-repeat: no-repeat; 120background-position: center; 121background-size: 1000% 1000%; 122 123&:active { 124transition-duration: $ripple-active-transition-duration; 125animation: ripple theme.$ripple-fade-in-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: theme.$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: theme.$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: theme.$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: theme.$shadow-z8; 179} 180 181background-image: radial-gradient(circle, theme-color.pressed-overlay($color, $opacity-modifier: $opacity-modifier) 10%, transparent 0%); 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($side) { 195$valid-sides: top, bottom, left, right; 196 197@if not list.index($valid-sides, $side) { 198@error "#{$side} is not a valid side. Expected one of #{$valid-sides}."; 199} 200 201$_position: center $side; 202 203@if $side == left or $side == right { 204$_position: $side center; 205} 206 207background-image: 208-gtk-gradient( 209radial, 210$_position, 0, 211$_position, .75, 212to(rgba(theme-color.$primary, .24)), 213to(transparent) 214); 215 216background-repeat: no-repeat; 217background-position: $_position; 218 219background-color: transparent; // reset some properties to be sure to not inherit them somehow 220border: none; // 221box-shadow: none; // 222} 223 224 225@mixin undershoot($side) { 226$valid-sides: top, bottom, left, right; 227 228@if not list.index($valid-sides, $side) { 229@error "#{$side} is not a valid side. Expected one of #{$valid-sides}."; 230} 231 232$_undershoot_color_dark: theme-color.stroke(theme-color.$on-surface); 233$_undershoot_color_light: transparent; 234 235$_gradient_dir: left; 236$_dash_bg_size: 12px 1px; 237$_gradient_repeat: repeat-x; 238$_bg_pos: left $side; 239 240@if $side == left or $side == right { 241$_gradient_dir: top; 242$_dash_bg_size: 1px 12px; 243$_gradient_repeat: repeat-y; 244$_bg_pos: $side top; 245} 246 247background-color: transparent; // shouldn't be needed, but better to be sure 248 249background-image: linear-gradient(to $_gradient_dir, // this is the dashed line 250$_undershoot_color_light 50%, 251$_undershoot_color_dark 50%); 252 253padding-#{$side}: 1px; 254background-size: $_dash_bg_size; 255background-repeat: $_gradient_repeat; 256background-origin: content-box; 257background-position: $_bg_pos; 258} 259