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