|
1 | 1 | @import "./fab.vars";
|
| 2 | +@import "../fab-list/fab-list.vars"; |
2 | 3 |
|
3 | 4 | // Floating Action Button Container
|
4 | 5 | // --------------------------------------------------
|
5 | 6 |
|
6 | 7 | :host {
|
7 | 8 | position: absolute;
|
8 | 9 |
|
| 10 | + width: fit-content; |
| 11 | + height: fit-content; |
| 12 | + |
9 | 13 | z-index: $z-index-fixed-content;
|
10 | 14 | }
|
11 | 15 |
|
|
14 | 18 | // --------------------------------------------------
|
15 | 19 |
|
16 | 20 | :host(.fab-horizontal-center) {
|
17 |
| - @include position(null, null, null, 50%); |
18 |
| - @include margin-horizontal(-$fab-size * 0.5, null); |
| 21 | + @include position(null, 0px, null, 0px); |
| 22 | + @include margin(null, auto); |
19 | 23 | }
|
20 | 24 |
|
21 | 25 | :host(.fab-horizontal-start) {
|
|
38 | 42 | top: $fab-content-margin;
|
39 | 43 | }
|
40 | 44 |
|
| 45 | +/** |
| 46 | + * Reset the top value since edge |
| 47 | + * styles use margin-top. |
| 48 | + */ |
41 | 49 | :host(.fab-vertical-top.fab-edge) {
|
42 |
| - top: -$fab-size * 0.5; |
| 50 | + top: 0; |
| 51 | +} |
| 52 | + |
| 53 | +/** |
| 54 | + * We need to adjust the parent FAB button up by half |
| 55 | + * its height so that half of it sits on the header. As a result, |
| 56 | + * we target the slotted ion-fab-button instead of targeting the host. |
| 57 | + */ |
| 58 | +:host(.fab-vertical-top.fab-edge) ::slotted(ion-fab-button) { |
| 59 | + margin-top: -50%; |
| 60 | +} |
| 61 | + |
| 62 | +/** |
| 63 | + * The small FAB button adds top and bottom margin. We need to account for |
| 64 | + * that margin when we adjust the FAB button for edge styles since we |
| 65 | + * are overriding the margin-top value below. |
| 66 | + */ |
| 67 | +:host(.fab-vertical-top.fab-edge) ::slotted(ion-fab-button.fab-button-small) { |
| 68 | + margin-top: calc((-100% + $fab-button-small-margin * 2) / 2); |
| 69 | +} |
| 70 | + |
| 71 | +/** |
| 72 | + * Since we are adjusting the FAB button we also need |
| 73 | + * to adjust the sibling ion-fab-list otherwise there will be |
| 74 | + * a gap between the parent FAB button and the associated list. |
| 75 | + */ |
| 76 | +:host(.fab-vertical-top.fab-edge) ::slotted(ion-fab-list.fab-list-side-start), |
| 77 | +:host(.fab-vertical-top.fab-edge) ::slotted(ion-fab-list.fab-list-side-end) { |
| 78 | + @include margin(-50%, null, null, null); |
43 | 79 | }
|
44 | 80 |
|
| 81 | +:host(.fab-vertical-top.fab-edge) ::slotted(ion-fab-list.fab-list-side-top), |
| 82 | +:host(.fab-vertical-top.fab-edge) ::slotted(ion-fab-list.fab-list-side-bottom) { |
| 83 | + @include margin(calc(50% + #{$fab-list-margin}) null, null, null); |
| 84 | +} |
45 | 85 |
|
46 | 86 | :host(.fab-vertical-bottom) {
|
47 | 87 | bottom: $fab-content-margin;
|
48 | 88 | }
|
49 | 89 |
|
| 90 | +/** |
| 91 | + * Reset the bottom value since edge |
| 92 | + * styles use margin-bottom. |
| 93 | + */ |
50 | 94 | :host(.fab-vertical-bottom.fab-edge) {
|
51 |
| - bottom: -$fab-size * 0.5; |
| 95 | + bottom: 0; |
52 | 96 | }
|
53 | 97 |
|
| 98 | +/** |
| 99 | + * We need to adjust the parent FAB button down by half |
| 100 | + * its height so that half of it sits on the footer. As a result, |
| 101 | + * we target the slotted ion-fab-button instead of targeting the host. |
| 102 | + */ |
| 103 | +:host(.fab-vertical-bottom.fab-edge) ::slotted(ion-fab-button) { |
| 104 | + margin-bottom: -50%; |
| 105 | +} |
54 | 106 |
|
55 |
| -:host(.fab-vertical-center) { |
56 |
| - @include margin(-$fab-size * 0.5, null, null, null); |
| 107 | +/** |
| 108 | + * The small FAB button adds top and bottom margin. We need to account for |
| 109 | + * that margin when we adjust the FAB button for edge styles since we |
| 110 | + * are overriding the margin-bottom value below. |
| 111 | + */ |
| 112 | +:host(.fab-vertical-bottom.fab-edge) ::slotted(ion-fab-button.fab-button-small) { |
| 113 | + margin-bottom: calc((-100% + $fab-button-small-margin * 2) / 2); |
| 114 | +} |
| 115 | + |
| 116 | +/** |
| 117 | + * Since we are adjusting the FAB button we also need |
| 118 | + * to adjust the sibling ion-fab-list otherwise there will be |
| 119 | + * a gap between the parent FAB button and the associated list. |
| 120 | + */ |
| 121 | +:host(.fab-vertical-bottom.fab-edge) ::slotted(ion-fab-list.fab-list-side-start), |
| 122 | +:host(.fab-vertical-bottom.fab-edge) ::slotted(ion-fab-list.fab-list-side-end) { |
| 123 | + @include margin(null, null, -50%, null); |
| 124 | +} |
| 125 | + |
| 126 | +:host(.fab-vertical-bottom.fab-edge) ::slotted(ion-fab-list.fab-list-side-top), |
| 127 | +:host(.fab-vertical-bottom.fab-edge) ::slotted(ion-fab-list.fab-list-side-bottom) { |
| 128 | + @include margin(null, null, calc(50% + #{$fab-list-margin}) null); |
| 129 | +} |
57 | 130 |
|
58 |
| - top: 50%; |
| 131 | +:host(.fab-vertical-center) { |
| 132 | + @include position(0px, null, 0px, null); |
| 133 | + @include margin(auto, null); |
59 | 134 | }
|
0 commit comments