|
| 1 | +@use 'sass:math'; |
| 2 | +@use '@material/theme/index' as theme; |
| 3 | +@use '@material/feature-targeting/index' as feature-targeting; |
| 4 | + |
| 5 | +// Default styles |
| 6 | +$section-height: 56px !default; |
| 7 | +$section-padding-vertical: 16px !default; |
| 8 | +$section-padding-horizontal: 16px !default; |
| 9 | +$fab-diameter: 56px !default; |
| 10 | +$inset-fab-padding: 8px !default; |
| 11 | +$acceleration-curve-timing-function: cubic-bezier(0.4, 0, 1, 1) !default; |
| 12 | + |
| 13 | +@mixin core-styles($query: feature-targeting.all()) { |
| 14 | + $feat-color: feature-targeting.create-target($query, color); |
| 15 | + $feat-structure: feature-targeting.create-target($query, structure); |
| 16 | + |
| 17 | + .smui-bottom-app-bar { |
| 18 | + display: flex; |
| 19 | + flex-direction: row; |
| 20 | + width: 100%; |
| 21 | + |
| 22 | + &.smui-bottom-app-bar--fixed { |
| 23 | + position: fixed; |
| 24 | + bottom: 0; |
| 25 | + left: 0; |
| 26 | + right: 0; |
| 27 | + } |
| 28 | + |
| 29 | + & > .smui-bottom-app-bar__section { |
| 30 | + display: flex; |
| 31 | + flex-direction: row; |
| 32 | + justify-content: center; |
| 33 | + padding: $section-padding-vertical $section-padding-horizontal; |
| 34 | + height: $section-height; |
| 35 | + box-sizing: border-box; |
| 36 | + flex-grow: 1; |
| 37 | + flex-basis: 0; |
| 38 | + overflow: visible; |
| 39 | + |
| 40 | + .mdc-icon-button { |
| 41 | + margin-top: -12px; |
| 42 | + } |
| 43 | + |
| 44 | + .mdc-fab { |
| 45 | + margin-top: -1 * |
| 46 | + ($section-padding-vertical + math.div($fab-diameter, 2)); |
| 47 | + // transform: translateY(-50%); |
| 48 | + } |
| 49 | + |
| 50 | + &:first-child { |
| 51 | + justify-content: start; |
| 52 | + |
| 53 | + .mdc-icon-button:first-child { |
| 54 | + margin-inline-start: -12px; |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + &:last-child { |
| 59 | + justify-content: end; |
| 60 | + |
| 61 | + .mdc-icon-button:last-child { |
| 62 | + margin-inline-end: -12px; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + &.smui-paper.smui-bottom-app-bar__section--fab-inset { |
| 67 | + @include inset-color(theme.$primary, 50%, $query); |
| 68 | + |
| 69 | + &:first-child { |
| 70 | + @include inset-color( |
| 71 | + theme.$primary, |
| 72 | + $section-padding-horizontal + $inset-fab-padding + |
| 73 | + math.div($fab-diameter, 2), |
| 74 | + $query |
| 75 | + ); |
| 76 | + |
| 77 | + .mdc-fab { |
| 78 | + margin-inline-start: $inset-fab-padding; |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + &:last-child { |
| 83 | + @include inset-color( |
| 84 | + theme.$primary, |
| 85 | + calc( |
| 86 | + 100% - |
| 87 | + ( |
| 88 | + $section-padding-horizontal + $inset-fab-padding + |
| 89 | + math.div($fab-diameter, 2) |
| 90 | + ) |
| 91 | + ), |
| 92 | + $query |
| 93 | + ); |
| 94 | + |
| 95 | + .mdc-fab { |
| 96 | + margin-inline-end: $inset-fab-padding; |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + &.smui-paper--color-secondary { |
| 101 | + @include inset-color(theme.$secondary, 50%, $query); |
| 102 | + |
| 103 | + &:first-child { |
| 104 | + @include inset-color( |
| 105 | + theme.$secondary, |
| 106 | + $section-padding-horizontal + $inset-fab-padding + |
| 107 | + math.div($fab-diameter, 2), |
| 108 | + $query |
| 109 | + ); |
| 110 | + } |
| 111 | + |
| 112 | + &:last-child { |
| 113 | + @include inset-color( |
| 114 | + theme.$secondary, |
| 115 | + calc( |
| 116 | + 100% - |
| 117 | + ( |
| 118 | + $section-padding-horizontal + $inset-fab-padding + |
| 119 | + math.div($fab-diameter, 2) |
| 120 | + ) |
| 121 | + ), |
| 122 | + $query |
| 123 | + ); |
| 124 | + } |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | + |
| 130 | + .smui-bottom-app-bar--fixed-adjust { |
| 131 | + padding-bottom: $section-height; |
| 132 | + } |
| 133 | +} |
| 134 | + |
| 135 | +@mixin inset-color($color, $xpos, $query: feature-targeting.all()) { |
| 136 | + $feat-color: feature-targeting.create-target($query, color); |
| 137 | + |
| 138 | + @include feature-targeting.targets($feat-color) { |
| 139 | + background: radial-gradient( |
| 140 | + ($fab-diameter + ($inset-fab-padding * 2)) |
| 141 | + ($fab-diameter + ($inset-fab-padding * 2)) at $xpos 0, |
| 142 | + rgba(0, 0, 0, 0) |
| 143 | + ((math.div($fab-diameter, 2) + $inset-fab-padding) * 0.99), |
| 144 | + $color ((math.div($fab-diameter, 2) + $inset-fab-padding) * 1.01) |
| 145 | + ); |
| 146 | + } |
| 147 | +} |
0 commit comments