Skip to content

Commit

Permalink
wip hiding and showing states
Browse files Browse the repository at this point in the history
  • Loading branch information
stsrki committed Feb 23, 2024
1 parent d309be5 commit 3d3149d
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 14 deletions.
6 changes: 5 additions & 1 deletion Source/Blazorise.AntDesign/AntDesignClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,11 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

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

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

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

Expand Down
6 changes: 5 additions & 1 deletion Source/Blazorise.Bootstrap/BootstrapClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,11 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

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

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

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

Expand Down
6 changes: 5 additions & 1 deletion Source/Blazorise.Bootstrap5/Bootstrap5ClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,11 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

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

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

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

Expand Down
6 changes: 5 additions & 1 deletion Source/Blazorise.Bulma/BulmaClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,11 @@ public override string Display( DisplayType displayType, DisplayDefinition displ

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

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

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

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

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

public override string ModalFade( bool animation ) => animation ? "fui-DialogSurface-fade" : null;
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
2 changes: 1 addition & 1 deletion Source/Blazorise.Tailwind/TailwindClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ public override string AlertColor( Color color )

public override string ModalFade() => "b-modal-fade";

public override string ModalFade( bool animation ) => animation ? "b-modal-fade" : null;
public override string ModalFade( bool showing, bool hiding ) => hiding ? "b-modal-fade" : null;

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

Expand Down
23 changes: 18 additions & 5 deletions Source/Blazorise/Components/Modal/Modal.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected override Task OnFirstAfterRenderAsync()
protected override void BuildClasses( ClassBuilder builder )
{
builder.Append( ClassProvider.Modal() );
builder.Append( ClassProvider.ModalFade( Animated ) );
builder.Append( ClassProvider.ModalFade( Animated && State.Showing, Animated && State.Hiding ) );
builder.Append( ClassProvider.ModalVisible( IsVisible ) );

base.BuildClasses( builder );
Expand Down Expand Up @@ -408,11 +408,17 @@ public Task BeginAnimation( bool visible )
{
if ( visible )
{
state = state with { Showing = true };

BackdropVisible = ShowBackdrop;
DirtyStyles();
}
else
DirtyClasses();
{
state = state with { Hiding = true };
}

DirtyClasses();
DirtyStyles();

return InvokeAsync( StateHasChanged );
}
Expand All @@ -421,9 +427,16 @@ public Task BeginAnimation( bool visible )
public Task EndAnimation( bool visible )
{
if ( visible )
DirtyClasses();
{
state = state with { Showing = false };
}
else
DirtyStyles();
{
state = state with { Hiding = false };
}

DirtyClasses();
DirtyStyles();

BackdropVisible = ShowBackdrop && visible;

Expand Down
2 changes: 1 addition & 1 deletion Source/Blazorise/Interfaces/IClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ public interface IClassProvider

string ModalFade();

string ModalFade( bool animation );
string ModalFade( bool showing, bool hiding );

string ModalVisible( bool visible );

Expand Down
2 changes: 1 addition & 1 deletion Source/Blazorise/Providers/ClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ public virtual string Display( DisplayType displayType, IEnumerable<DisplayDefin

public abstract string ModalFade();

public abstract string ModalFade( bool animation );
public abstract string ModalFade( bool showing, bool hiding );

public abstract string ModalVisible( bool visible );

Expand Down
2 changes: 1 addition & 1 deletion Source/Blazorise/Providers/EmptyClassProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ class EmptyClassProvider : IClassProvider

public string ModalFade() => null;

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

public string ModalVisible( bool visible ) => null;

Expand Down
4 changes: 4 additions & 0 deletions Source/Blazorise/States/ModalState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public record ModalState
/// </summary>
public bool Visible { get; init; }

public bool Showing { get; init; }

Check warning on line 13 in Source/Blazorise/States/ModalState.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ModalState.Showing'

public bool Hiding { get; init; }

Check warning on line 15 in Source/Blazorise/States/ModalState.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'ModalState.Hiding'

/// <summary>
/// Defines the open state of the modal dialog.
/// </summary>
Expand Down

0 comments on commit 3d3149d

Please sign in to comment.