Skip to content

Commit

Permalink
feat: add modal mixin, sidebar mask now has transition effect just li…
Browse files Browse the repository at this point in the history
…ke modal
  • Loading branch information
kitian616 committed Dec 2, 2018
1 parent 6222a74 commit 0bbbb26
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
2 changes: 1 addition & 1 deletion _sass/common/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $spacers: (
5: map-get($base, spacer) * 3
);

$z-index: (
$z-indexes: (
actions: 996,
mask: 997,
sidebar: 998,
Expand Down
34 changes: 24 additions & 10 deletions _sass/common/components/_modal.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
.modal {
@mixin modal($z-index: default, $color: default, $background-color: default) {
@if $z-index == default {
$z-index: map-get($z-indexes, modal);
}
@if $color == default {
$color: $text-color-theme-dark;
}
@if $background-color == default {
$background-color: $mask-color;
}
position: fixed;
top: 0;
left: 0;
z-index: map-get($z-index, modal);
z-index: $z-index;
width: 100%;
height: 100%;
color: $text-color-theme-dark;
color: $color;
touch-action: none;
background-color: $mask-color;
background-color: $background-color;
opacity: 0;
@include transform(translate(100%, 0));
@include transition(#{opacity map-get($animation, duration) map-get($animation, timing-function),
transform 0s map-get($animation, duration) map-get($animation, timing-function)});
}

.modal--overflow {
@include overflow(auto);
}

.modal--show {
@mixin modal--show() {
opacity: 1;
@include transform(translate(0, 0));
@include transition(#{opacity map-get($animation, duration) map-get($animation, timing-function)});
}

.modal {
@include modal();
}
.modal--show {
@include modal--show();
}
.modal--overflow {
@include overflow(auto);
}
15 changes: 4 additions & 11 deletions _sass/layout/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
position: fixed;
bottom: map-get($spacers, 5);
left: map-get($spacers, 3);
z-index: map-get($z-index, actions);
z-index: map-get($z-indexes, actions);
display: none;
}

Expand All @@ -23,7 +23,7 @@
}

.page__sidebar {
z-index: map-get($z-index, sidebar);
z-index: map-get($z-indexes, sidebar);
display: block;
width: 80%;
max-width: map-get($layout, sidebar-width);
Expand All @@ -38,15 +38,8 @@
}

.page__mask {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: map-get($z-index, mask);
display: none;
@include modal(map-get($z-indexes, mask));
cursor: pointer;
background-color: $mask-color;
}
&.layout--page--sidebar {
.page__main {
Expand Down Expand Up @@ -146,7 +139,7 @@
@include transform(translate(0));
}
.page__mask {
display: block;
@include modal--show();
}
}
}
Expand Down

0 comments on commit 0bbbb26

Please sign in to comment.