-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c910cd1
commit b4d6280
Showing
6 changed files
with
201 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
namespace Pure.Blazor.Components.Layout; | ||
|
||
internal class FlexMap | ||
{ | ||
internal const string Row = "row"; | ||
internal const string RowReverse = "row-reverse"; | ||
internal const string Column = "column"; | ||
internal const string ColumnReverse = "column-reverse"; | ||
|
||
internal static FlexDirection GetFlexDirection(string value) | ||
{ | ||
return value switch | ||
{ | ||
Row => FlexDirection.Row, | ||
RowReverse => FlexDirection.RowReverse, | ||
Column => FlexDirection.Col, | ||
ColumnReverse => FlexDirection.ColReverse, | ||
_ => FlexDirection.Row | ||
}; | ||
} | ||
|
||
internal static string GetFlexDirection(FlexDirection value) | ||
{ | ||
return value switch | ||
{ | ||
FlexDirection.Row => Row, | ||
FlexDirection.RowReverse => RowReverse, | ||
FlexDirection.Col => Column, | ||
FlexDirection.ColReverse => ColumnReverse, | ||
_ => Row | ||
}; | ||
} | ||
|
||
internal static string GetAlignContent(FlexAlignContent value) | ||
{ | ||
return value switch | ||
{ | ||
FlexAlignContent.Start => "content-start", | ||
FlexAlignContent.End => "content-end", | ||
FlexAlignContent.Center => "content-center", | ||
FlexAlignContent.Between => "content-between", | ||
FlexAlignContent.Around => "content-around", | ||
FlexAlignContent.Evenly => "content-evenly", | ||
_ => "content-stretch" | ||
}; | ||
} | ||
|
||
internal static string GetAlignItems(FlexAlignItems value) | ||
{ | ||
return value switch | ||
{ | ||
FlexAlignItems.Start => "items-start", | ||
FlexAlignItems.End => "items-end", | ||
FlexAlignItems.Center => "items-center", | ||
FlexAlignItems.Baseline => "items-baseline", | ||
FlexAlignItems.Stretch => "items-stretch", | ||
_ => "items-stretch" | ||
}; | ||
} | ||
|
||
internal static string GetJustifyContent(FlexJustifyContent value) | ||
{ | ||
return value switch | ||
{ | ||
FlexJustifyContent.Start => "justify-start", | ||
FlexJustifyContent.End => "justify-end", | ||
FlexJustifyContent.Center => "justify-center", | ||
FlexJustifyContent.Between => "justify-between", | ||
FlexJustifyContent.Around => "justify-around", | ||
FlexJustifyContent.Evenly => "justify-evenly", | ||
_ => "justify-stretch" | ||
}; | ||
} | ||
} | ||
|
||
public enum FlexDirection | ||
{ | ||
Row, | ||
RowReverse, | ||
Col, | ||
ColReverse | ||
} | ||
|
||
public enum FlexWrap | ||
{ | ||
Wrap, | ||
WrapReverse, | ||
NoWrap | ||
} | ||
|
||
public enum FlexAlignItems | ||
{ | ||
Start, | ||
End, | ||
Center, | ||
Baseline, | ||
Stretch | ||
} | ||
|
||
public enum FlexAlignContent | ||
{ | ||
Start, | ||
End, | ||
Center, | ||
Between, | ||
Around, | ||
Evenly | ||
} | ||
|
||
public enum FlexJustifyContent | ||
{ | ||
Start, | ||
End, | ||
Center, | ||
Between, | ||
Around, | ||
Evenly | ||
} | ||
|
||
public enum FlexAlignSelf | ||
{ | ||
Auto, | ||
Start, | ||
End, | ||
Center, | ||
Stretch, | ||
Baseline | ||
} | ||
|
||
public enum FlexGrow | ||
{ | ||
Grow, | ||
Grow0 | ||
} | ||
|
||
public enum FlexShrink | ||
{ | ||
Shrink, | ||
Shrink0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@inherits PureComponent | ||
<div class="flex @FlexMap.GetFlexDirection(Direction) @FlexMap.GetAlignContent(AlignContent) @FlexMap.GetJustifyContent(JustifyContent) @FlexMap.GetAlignItems(AlignItems) @ApplyStyle(Styles)"> | ||
@ChildContent | ||
</div> | ||
|
||
@code { | ||
[Parameter] public FlexDirection Direction { get; set; } | ||
[Parameter] public FlexAlignContent AlignContent { get; set; } | ||
[Parameter] public FlexJustifyContent JustifyContent { get; set; } | ||
[Parameter] public FlexAlignItems AlignItems { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@inherits PureComponent | ||
<div class="@ColumnSpan @ApplyStyle(Styles)"> | ||
@ChildContent | ||
</div> | ||
@code { | ||
protected override void OnParametersSet() | ||
{ | ||
if (Span < 1 || Span > 12) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(Span), "Span must be between 1 and 12"); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The number of columns this element should span. | ||
/// </summary> | ||
[Parameter] | ||
public int Span { get; set; } | ||
|
||
public string ColumnSpan => $"col-span-{Span}"; | ||
|
||
// TODO: use source generator to generate these constants | ||
internal const string ColumnSpan1 = "col-span-1"; | ||
internal const string ColumnSpan2 = "col-span-2"; | ||
internal const string ColumnSpan3 = "col-span-3"; | ||
internal const string ColumnSpan4 = "col-span-4"; | ||
internal const string ColumnSpan5 = "col-span-5"; | ||
internal const string ColumnSpan6 = "col-span-6"; | ||
internal const string ColumnSpan7 = "col-span-7"; | ||
internal const string ColumnSpan8 = "col-span-8"; | ||
internal const string ColumnSpan9 = "col-span-9"; | ||
internal const string ColumnSpan10 = "col-span-10"; | ||
internal const string ColumnSpan11 = "col-span-11"; | ||
internal const string ColumnSpan12 = "col-span-12"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@inherits PureComponent | ||
<div class="grid grid-cols-12 @ApplyStyle(Styles)"> | ||
@ChildContent | ||
</div> | ||
@code { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters