Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
@inherits AppComponentBase

<section>
<BitStack FitHeight>
<BitButton Class="close-btn"
OnClick="CloseModal"
Color="BitColor.Tertiary"
Variant="BitVariant.Text"
IconName="@BitIconName.ChromeClose" />
<SignInPanel OnSuccess="OnSuccess"
ReturnUrlQueryString="@ReturnUrl"
SignInPanelType="SignInPanelType.OtpOnly" />
<BitStack Gap="0">
<BitStack Horizontal FitHeight Class="header-stack">
<BitSpacer />
<BitButton OnClick="CloseModal"
Color="BitColor.Tertiary"
Variant="BitVariant.Text"
IconName="@BitIconName.ChromeClose" />
</BitStack>
<BitStack Class="stack" FitHeight>
<SignInPanel OnSuccess="OnSuccess"
ReturnUrlQueryString="@ReturnUrl"
SignInPanelType="SignInPanelType.Otp" />
</BitStack>
</BitStack>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

section {
height: 100%;
padding: 3rem;
overflow: auto;
position: relative;
max-height: $bit-env-height-available;

@include lt-sm {
Expand All @@ -23,9 +21,13 @@ section {
}
}

.close-btn {
top: 1rem;
position: absolute;
inset-inline-end: 1rem;
.header-stack {
padding-top: 1rem;
padding-inline-end: 1rem;
}

.stack {
padding: 3rem;
padding-top: 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
Placeholder="@Localizer[nameof(AppStrings.PhoneNumberPlaceholder)]" />
<ValidationMessage For="@(() => model.PhoneNumber)" />
}
@if (internalSignInPanelType is SignInPanelType.Full or SignInPanelType.PasswordOnly)
@if (internalSignInPanelType is SignInPanelType.Full or SignInPanelType.Password)
{
<br />
<BitTextField @bind-Value="model.Password"
Expand Down Expand Up @@ -97,32 +97,41 @@
}
</BitStack>

@if (internalSignInPanelType is SignInPanelType.Full or SignInPanelType.PasswordOnly)
@if (internalSignInPanelType is SignInPanelType.Full or SignInPanelType.Password)
{
<BitButton IsLoading="isWaiting" IsEnabled="isWaiting is false" ButtonType="BitButtonType.Submit">
@Localizer[nameof(AppStrings.Continue)]
</BitButton>
<BitStack Alignment="BitAlignment.Center" FitHeight FillContent>
<BitText Typography="BitTypography.Body2" Align="BitTextAlign.Center">
<b>@Localizer[nameof(AppStrings.SignInPasswordMessage1)]</b>
<br />
@Localizer[nameof(AppStrings.SignInPasswordMessage2)]
</BitText>
<BitButton IsLoading="isWaiting"
IsEnabled="isWaiting is false"
ButtonType="BitButtonType.Submit">
@Localizer[nameof(AppStrings.Continue)]
</BitButton>
</BitStack>
}

@if (internalSignInPanelType is SignInPanelType.Full or SignInPanelType.OtpOnly)
@if (internalSignInPanelType is SignInPanelType.Full or SignInPanelType.Otp)
{
<BitButton IsLoading="isWaiting"
ButtonType="BitButtonType.Button"
OnClick="WrapHandled(() => SendOtp(resend: true))"
Variant="@(internalSignInPanelType is SignInPanelType.OtpOnly ? BitVariant.Fill : BitVariant.Outline)"
Variant="@(internalSignInPanelType is SignInPanelType.Otp ? BitVariant.Fill : BitVariant.Outline)"
IsEnabled="@(isWaiting is false && (model.Email is not null || model.PhoneNumber is not null))">
@(currentTab == SignInPanelTab.Email ? Localizer[nameof(AppStrings.SendMagicLinkButtonText)] : Localizer[nameof(AppStrings.SendOtpButtonText)])
</BitButton>
}

@if (internalSignInPanelType is SignInPanelType.OtpOnly)
@if (internalSignInPanelType is SignInPanelType.Otp)
{
<BitLink OnClick="() => ChangeSignInPanelType(SignInPanelType.PasswordOnly)">@Localizer[nameof(AppStrings.SignInByPassword)]</BitLink>
<BitLink OnClick="() => ChangeSignInPanelType(SignInPanelType.Password)">@Localizer[nameof(AppStrings.SignInByPassword)]</BitLink>
}

@if (internalSignInPanelType is SignInPanelType.PasswordOnly)
@if (internalSignInPanelType is SignInPanelType.Password)
{
<BitLink OnClick="() => ChangeSignInPanelType(SignInPanelType.OtpOnly)">@Localizer[nameof(AppStrings.SignInByOtp)]</BitLink>
<BitLink OnClick="() => ChangeSignInPanelType(SignInPanelType.Otp)">@Localizer[nameof(AppStrings.SignInByOtp)]</BitLink>
}

@if (internalSignInPanelType is SignInPanelType.Full)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ await identityController

private void CleanModel()
{
if (internalSignInPanelType is SignInPanelType.OtpOnly)
if (internalSignInPanelType is SignInPanelType.Otp)
{
model.Password = null;
validatorRef?.EditContext.NotifyFieldChanged(validatorRef.EditContext.Field(nameof(SignInRequestDto.Password)));
}
else if (internalSignInPanelType is SignInPanelType.PasswordOnly && isOtpSent is false)
else if (internalSignInPanelType is SignInPanelType.Password && isOtpSent is false)
{
model.Otp = null;
validatorRef?.EditContext.NotifyFieldChanged(validatorRef.EditContext.Field(nameof(SignInRequestDto.Otp)));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
namespace Boilerplate.Client.Core.Components.Pages.Identity.SignIn;

public enum SignInPanelType // Check out SignInModalService for more details
/// <summary>
/// The layout type of the SignIn panel UI. Check out <see cref="SignInModalService"/> for more details
/// </summary>
public enum SignInPanelType
{
Full, // Shows email,phone and password fields alongside with sign-in, send otp and sign-up buttons.
PasswordOnly, // Shows email,phone and password fields alongside with sign-in button only.
OtpOnly // Shows email,phone and send otp button only.
/// <summary>
/// Shows email, phone and password fields alongside with sign-in, send otp and sign-up buttons.
/// </summary>
Full,

/// <summary>
/// Shows email, phone and password fields alongside with sign-in button.
/// </summary>
Password,

/// <summary>
/// Shows email, phone and send otp button.
/// </summary>
Otp
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public async Task<bool> SignIn(string? returnUrl = null)
};
var modalParameters = new BitModalParameters()
{
Draggable = true,
DragElementSelector = ".header-stack",
OnOverlayClick = EventCallback.Factory.Create<MouseEventArgs>(this, () => signInModalTcs.SetResult(false))
};

Expand Down
Loading
Loading