Skip to content

Commit

Permalink
Refactorting modal animations
Browse files Browse the repository at this point in the history
  • Loading branch information
stsrki committed Feb 23, 2024
1 parent 3d3149d commit 13cd603
Show file tree
Hide file tree
Showing 29 changed files with 236 additions and 77 deletions.
8 changes: 1 addition & 7 deletions Source/Blazorise.AntDesign/AntDesignClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -877,13 +877,7 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

public override string Modal() => "ant-modal-root";

public override string ModalFade() => Fade();

public override string ModalFade( bool showing, bool hiding ) => showing
? Show()
: hiding
? Fade()
: null;
public override string ModalFade( bool showing, bool hiding ) => showing || hiding ? Fade() : null;

public override string ModalVisible( bool visible ) => null;

Expand Down
8 changes: 7 additions & 1 deletion Source/Blazorise.AntDesign/AntDesignStyleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ public class AntDesignStyleProvider : StyleProvider

public override int DefaultModalBackdropZIndex => 1000;

public override string ModalShow() => "display: block;";
public override string ModalShow( bool visible ) => visible ? "display: block" : null;

public override string ModalFade( bool showing, bool hiding ) => null;

public override string ModalAnimationDuration( bool animated, int animationDuration ) => animated
? $"--modal-animation-duration: {animationDuration}ms"
: "--modal-animation-duration: 0ms";

int ModalZIndexDiff => DefaultModalZIndex - DefaultModalBackdropZIndex;

Expand Down
6 changes: 2 additions & 4 deletions Source/Blazorise.Bootstrap/BootstrapClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,10 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

public override string Modal() => "modal";

public override string ModalFade() => Fade();

public override string ModalFade( bool showing, bool hiding ) => showing
? Show()
? "showing"
: hiding
? Fade()
? "hiding"
: null;

public override string ModalVisible( bool visible ) => visible ? Show() : null;
Expand Down
8 changes: 7 additions & 1 deletion Source/Blazorise.Bootstrap/BootstrapStyleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ public class BootstrapStyleProvider : StyleProvider

public override int DefaultModalBackdropZIndex => 1040;

public override string ModalShow() => "display: block";
public override string ModalShow( bool visible ) => null;

public override string ModalFade( bool showing, bool hiding ) => null;

public override string ModalAnimationDuration( bool animated, int animationDuration ) => animated
? $"--modal-animation-duration: {animationDuration}ms"
: "--modal-animation-duration: 0ms";

int ModalZIndexDiff => DefaultModalZIndex - DefaultModalBackdropZIndex;

Expand Down
34 changes: 30 additions & 4 deletions Source/Blazorise.Bootstrap/Styles/components/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,38 @@
}
}

&.fade {
transition: opacity var(--modal-animation-duration, 300ms) linear;
display: block;
visibility: hidden;

&:not(.show) {
.modal-dialog {
transition: -webkit-transform var(--modal-animation-duration, 300ms) ease-out;
transition: transform var(--modal-animation-duration, 300ms) ease-out;
opacity: 0;
}
}

&.showing,
&.show {
.modal-dialog {
opacity: 1;
}

visibility: visible;
}

transition-property: opacity visibility;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;

.modal-dialog {
transition-property: opacity visibility transform;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: ease-out;
transform: translate(0,-50px);
}
}

.modal-backdrop.fade {
transition-property: opacity;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;
}
31 changes: 26 additions & 5 deletions Source/Blazorise.Bootstrap/wwwroot/blazorise.bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,13 @@ li.list-group-item-action {
overflow-y: scroll;
}

.modal {
display: block;
visibility: hidden;
transition-property: opacity visibility;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;
}
.modal .modal-fullscreen {
width: 100vw;
max-width: none;
Expand All @@ -846,12 +853,26 @@ li.list-group-item-action {
.modal .modal-fullscreen .modal-footer {
border-radius: 0;
}
.modal.fade {
transition: opacity var(--modal-animation-duration, 300ms) linear;
.modal:not(.show) .modal-dialog {
opacity: 0;
}
.modal.showing, .modal.show {
visibility: visible;
}
.modal.showing .modal-dialog, .modal.show .modal-dialog {
opacity: 1;
}
.modal.fade .modal-dialog {
transition: -webkit-transform var(--modal-animation-duration, 300ms) ease-out;
transition: transform var(--modal-animation-duration, 300ms) ease-out;
.modal .modal-dialog {
transition-property: opacity visibility transform;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: ease-out;
transform: translate(0, -50px);
}

.modal-backdrop.fade {
transition-property: opacity;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;
}

.offcanvas, .offcanvas-xl, .offcanvas-lg, .offcanvas-md, .offcanvas-sm {
Expand Down

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions Source/Blazorise.Bootstrap5/Bootstrap5ClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,10 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

public override string Modal() => "modal";

public override string ModalFade() => Fade();

public override string ModalFade( bool showing, bool hiding ) => showing
? Show()
? "showing"
: hiding
? Fade()
? "hiding"
: null;

public override string ModalVisible( bool visible ) => visible ? Show() : null;
Expand Down
8 changes: 7 additions & 1 deletion Source/Blazorise.Bootstrap5/Bootstrap5StyleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ public class Bootstrap5StyleProvider : StyleProvider

public override int DefaultModalBackdropZIndex => 1050;

public override string ModalShow() => "display: block;";
public override string ModalShow( bool visible ) => null;

public override string ModalFade( bool showing, bool hiding ) => null;

public override string ModalAnimationDuration( bool animated, int animationDuration ) => animated
? $"--modal-animation-duration: {animationDuration}ms"
: "--modal-animation-duration: 0ms";

int ModalZIndexDiff => DefaultModalZIndex - DefaultModalBackdropZIndex;

Expand Down
34 changes: 30 additions & 4 deletions Source/Blazorise.Bootstrap5/Styles/components/_modal.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
.modal {
&.fade {
transition: opacity var(--modal-animation-duration, 300ms) linear;
display: block;
visibility: hidden;

&:not(.show) {
.modal-dialog {
transition: -webkit-transform var(--modal-animation-duration, 300ms) ease-out;
transition: transform var(--modal-animation-duration, 300ms) ease-out;
opacity: 0;
}
}

&.showing,
&.show {
.modal-dialog {
opacity: 1;
}

visibility: visible;
}

transition-property: opacity visibility;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;

.modal-dialog {
transition-property: opacity visibility transform;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: ease-out;
transform: translate(0,-50px);
}
}

.modal-backdrop.fade {
transition-property: opacity;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;
}
31 changes: 26 additions & 5 deletions Source/Blazorise.Bootstrap5/wwwroot/blazorise.bootstrap5.css
Original file line number Diff line number Diff line change
Expand Up @@ -986,12 +986,33 @@ li.list-group-item-action {
flex: 1;
}

.modal.fade {
transition: opacity var(--modal-animation-duration, 300ms) linear;
.modal {
display: block;
visibility: hidden;
transition-property: opacity visibility;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;
}
.modal:not(.show) .modal-dialog {
opacity: 0;
}
.modal.showing, .modal.show {
visibility: visible;
}
.modal.fade .modal-dialog {
transition: -webkit-transform var(--modal-animation-duration, 300ms) ease-out;
transition: transform var(--modal-animation-duration, 300ms) ease-out;
.modal.showing .modal-dialog, .modal.show .modal-dialog {
opacity: 1;
}
.modal .modal-dialog {
transition-property: opacity visibility transform;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: ease-out;
transform: translate(0, -50px);
}

.modal-backdrop.fade {
transition-property: opacity;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: linear;
}

.offcanvas-footer {
Expand Down

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions Source/Blazorise.Bulma/BulmaClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -908,13 +908,7 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

public override string Modal() => "modal";

public override string ModalFade() => Fade();

public override string ModalFade( bool showing, bool hiding ) => showing
? Show()
: hiding
? Fade()
: null;
public override string ModalFade( bool showing, bool hiding ) => showing || hiding ? Fade() : null;

public override string ModalVisible( bool visible ) => visible ? Active() : null;

Expand Down
8 changes: 7 additions & 1 deletion Source/Blazorise.Bulma/BulmaStyleProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ public class BulmaStyleProvider : StyleProvider

public override int DefaultModalBackdropZIndex => 0;

public override string ModalShow() => null;
public override string ModalShow( bool visible ) => null;

public override string ModalFade( bool showing, bool hiding ) => null;

public override string ModalAnimationDuration( bool animated, int animationDuration ) => animated
? $"--modal-animation-duration: {animationDuration}ms"
: "--modal-animation-duration: 0ms";

int ModalZIndexDiff => DefaultModalZIndex - DefaultModalBackdropZIndex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,8 +1015,6 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

public override string Modal() => "fui-DialogSurface";

public override string ModalFade() => "fui-DialogSurface-fade";

public override string ModalFade( bool showing, bool hiding ) => showing || hiding ? "fui-DialogSurface-fade" : null;

public override string ModalVisible( bool visible ) => visible ? "fui-DialogSurface-show" : "fui-DialogSurface-hide";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ public class FluentUI2StyleProvider : StyleProvider

public override int DefaultModalBackdropZIndex => 1050;

public override string ModalShow() => null;
public override string ModalShow( bool visible ) => null;

public override string ModalFade( bool showing, bool hiding ) => null;

public override string ModalAnimationDuration( bool animated, int animationDuration ) => animated
? $"--modal-animation-duration: {animationDuration}ms"
: "--modal-animation-duration: 0ms";

int ModalZIndexDiff => DefaultModalZIndex - DefaultModalBackdropZIndex;

Expand Down
33 changes: 30 additions & 3 deletions Source/Blazorise.Material/Styles/components/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,41 @@
}
}

display: block;
visibility: hidden;

&:not(.show) {
.modal-dialog {
opacity: 0;
}
}

&.showing,
&.show {
.modal-dialog {
opacity: 1;
}

visibility: visible;
}

.modal-dialog {
transition-property: opacity visibility transform;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: cubic-bezier(0,0,.2,1);
transform: scale(.8)
}

&.fade {
transition: opacity var(--modal-animation-duration, 300ms) cubic-bezier(0,0,.2,1);
}

&.show {
.modal-dialog {
transition: opacity,-webkit-transform var(--modal-animation-duration, 300ms) cubic-bezier(0,0,.2,1);
transition: opacity,transform var(--modal-animation-duration, 300ms) cubic-bezier(0,0,.2,1);
transition-property: opacity visibility transform;
transition-duration: var(--modal-animation-duration, 300ms);
transition-timing-function: cubic-bezier(0,0,.2,1);
transform: scale(1);
}
}

Expand All @@ -52,4 +79,4 @@
max-width: $dialog-width-xl;
}
}
}
}
Loading

0 comments on commit 13cd603

Please sign in to comment.