Skip to content

Commit

Permalink
feat(blazorui): add Dir to BitCalendar #7112 (#7113)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrastegari authored Mar 12, 2024
1 parent 5ca2169 commit 8281a97
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<div @ref="RootElement" @attributes="HtmlAttributes"
id="@_Id"
style="@StyleBuilder.Value"
class="@ClassBuilder.Value">
class="@ClassBuilder.Value"
dir="@Dir?.ToString().ToLower()">

<div style="@Styles?.Container" class="bit-cal-cnt @Classes?.Container" disabled=@(IsEnabled is false)>
<div class="bit-cal-sdt" aria-live="polite" aria-atomic="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ protected override void RegisterCssClasses()
{
ClassBuilder.Register(() => Classes?.Root);

ClassBuilder.Register(() => Culture.TextInfo.IsRightToLeft ? $"{RootElementClass}-rtl" : string.Empty);
ClassBuilder.Register(() => (Dir is null && Culture.TextInfo.IsRightToLeft) ? "bit-rtl" : string.Empty);
}

protected override void RegisterCssStyles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
background-color: $color-background-disabled;
}
}

&.bit-rtl {
direction: rtl;

.bit-cal-wnm {
border-right: none;
border-left: $shape-border-width $shape-border-style $color-border-secondary;
}
}
}

.bit-cal-cnt {
Expand Down Expand Up @@ -204,14 +213,15 @@
flex-grow: 1;
cursor: text;
overflow: hidden;
text-align: left;
font-weight: 600;
text-align: start;
position: relative;
white-space: nowrap;
align-items: center;
outline: transparent;
display: inline-block;
text-overflow: ellipsis;
padding: 0 spacing(1.25);
font-size: spacing(1.75);
line-height: spacing(3.5);
animation-fill-mode: both;
Expand All @@ -220,7 +230,6 @@
background-color: transparent;
color: $color-foreground-primary;
border-radius: $shape-border-radius;
padding: 0 spacing(0.5) 0 spacing(1.25);
animation-timing-function: cubic-bezier(0.1, 0.25, 0.75, 0.9);
}

Expand Down Expand Up @@ -400,15 +409,16 @@

.bit-cal-tic {
margin: 0;
padding: spacing(2);
flex: 0.85;
display: flex;
outline: none;
direction: ltr;
gap: spacing(1);
box-shadow: none;
box-sizing: border-box;
padding: spacing(2);
align-items: center;
box-sizing: border-box;
justify-content: center;
flex: 0.85;
gap: spacing(1);
}

.bit-cal-tpr {
Expand Down Expand Up @@ -495,24 +505,3 @@
box-sizing: content-box;
flex-flow: column nowrap;
}

.bit-cal-rtl {
.bit-cal-cnt {
direction: rtl;
}

.bit-cal-wnm {
border-right: none;
border-left: $shape-border-width $shape-border-style $color-border-secondary;
}

.bit-cal-pkt,
.bit-cal-ptb {
text-align: right;
padding: 0 spacing(1.25) 0 spacing(0.5);
}

.bit-cal-twp {
flex-direction: row-reverse;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,12 @@
</div>
</ExamplePreview>
</ComponentExampleBox>

<ComponentExampleBox Title="RTL" RazorCode="@example10RazorCode" Id="example10">
<ExamplePreview>
<div class="example-content">
<BitCalendar Dir="BitDir.Rtl" />
</div>
</ExamplePreview>
</ComponentExampleBox>
</ComponentDemo>
Original file line number Diff line number Diff line change
Expand Up @@ -880,4 +880,7 @@ public class BitCalendarValidationModel
private void HandleValidSubmit() { }
private void HandleInvalidSubmit() { }";

private readonly string example10RazorCode = @"
<BitCalendar Dir=""BitDir.Rtl"" />";
}

0 comments on commit 8281a97

Please sign in to comment.