-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
17 changed files
with
502 additions
and
23 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProLayout/BitCascadingValue.cs
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,44 @@ | ||
namespace Bit.BlazorUI; | ||
|
||
/// <summary> | ||
/// The cascading value to be provided using the <see cref="BitCascadingValueProvider"/> component. | ||
/// </summary> | ||
public class BitCascadingValue | ||
{ | ||
/// <summary> | ||
/// The optional name of the cascading value. | ||
/// </summary> | ||
public string? Name { get; set; } | ||
|
||
/// <summary> | ||
/// The value to be provided. | ||
/// </summary> | ||
public object? Value { get; set; } | ||
|
||
/// <summary> | ||
/// If true, indicates that <see cref="Value"/> will not change. | ||
/// </summary> | ||
public bool IsFixed { get; set; } | ||
|
||
|
||
|
||
public BitCascadingValue() { } | ||
public BitCascadingValue(object? value, string? name = null) : this(value, name, false) { } | ||
public BitCascadingValue(object? value, bool isFixed) : this(value, null, isFixed) { } | ||
public BitCascadingValue(object? value, string? name, bool isFixed) | ||
{ | ||
Value = value; | ||
Name = name; | ||
IsFixed = isFixed; | ||
} | ||
|
||
|
||
|
||
public static implicit operator BitCascadingValue(int value) => new(value); | ||
public static implicit operator BitCascadingValue(int? value) => new(value); | ||
public static implicit operator BitCascadingValue(bool value) => new(value); | ||
public static implicit operator BitCascadingValue(bool? value) => new(value); | ||
public static implicit operator BitCascadingValue(string value) => new(value); | ||
public static implicit operator BitCascadingValue(BitDir? value) => new(value); | ||
public static implicit operator BitCascadingValue(RouteData value) => new(value); | ||
} |
69 changes: 69 additions & 0 deletions
69
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProLayout/BitCascadingValueProvider.cs
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,69 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Bit.BlazorUI; | ||
|
||
/// <summary> | ||
/// A component that provides a list of cascading values to all descendant components. | ||
/// </summary> | ||
public class BitCascadingValueProvider : ComponentBase | ||
{ | ||
/// <summary> | ||
/// The content to which the values should be provided. | ||
/// </summary> | ||
[Parameter] public RenderFragment? ChildContent { get; set; } | ||
|
||
/// <summary> | ||
/// The cascading values to be provided for the children. | ||
/// </summary> | ||
[Parameter] public IEnumerable<BitCascadingValue>? Values { get; set; } | ||
|
||
|
||
|
||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] | ||
private Type _cascadingValueType = typeof(CascadingValue<>); | ||
|
||
|
||
|
||
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(BitCascadingValue))] | ||
protected override void BuildRenderTree(RenderTreeBuilder builder) | ||
{ | ||
var seq = 0; | ||
RenderFragment? rf = ChildContent; | ||
|
||
foreach (var value in Values ?? []) | ||
{ | ||
if (value.Value is null) continue; | ||
|
||
var r = rf; | ||
var s = seq; | ||
var v = value; | ||
|
||
rf = b => { CreateCascadingValue(b, s, v.Name, v.Value, v.IsFixed, r); }; | ||
|
||
seq += v.Name.HasValue() ? 5 : 4; | ||
} | ||
|
||
builder.AddContent(seq, rf); | ||
} | ||
|
||
|
||
private void CreateCascadingValue(RenderTreeBuilder builder, | ||
int seq, | ||
string? name, | ||
object value, | ||
bool isFixed, | ||
RenderFragment? childContent) | ||
{ | ||
#pragma warning disable IL2055 // Either the type on which the MakeGenericType is called can't be statically determined, or the type parameters to be used for generic arguments can't be statically determined. | ||
builder.OpenComponent(seq, _cascadingValueType.MakeGenericType(value.GetType())); | ||
#pragma warning restore IL2055 // Either the type on which the MakeGenericType is called can't be statically determined, or the type parameters to be used for generic arguments can't be statically determined. | ||
if (string.IsNullOrEmpty(name) is false) | ||
{ | ||
builder.AddComponentParameter(++seq, "Name", name); | ||
} | ||
builder.AddComponentParameter(++seq, "Value", value); | ||
builder.AddComponentParameter(++seq, "IsFixed", isFixed); | ||
builder.AddComponentParameter(++seq, "ChildContent", childContent); | ||
builder.CloseComponent(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProLayout/BitProLayout.razor
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,23 @@ | ||
@namespace Bit.BlazorUI | ||
@inherits BitComponentBase | ||
|
||
<div @ref="RootElement" | ||
@attributes="HtmlAttributes" | ||
id="@_Id" | ||
style="@StyleBuilder.Value" | ||
class="@ClassBuilder.Value" | ||
dir="@Dir?.ToString().ToLower()"> | ||
<div style="@Styles?.Top" class="bit-ply-top @Classes?.Top" /> | ||
<div style="@Styles?.Center" | ||
class="bit-ply-center @Classes?.Center" | ||
dir="@Dir?.ToString().ToLower()"> | ||
<div style="@Styles?.Left" class="bit-ply-left @Classes?.Left"></div> | ||
<div style="@Styles?.Main" class="bit-ply-main @Classes?.Main"> | ||
<BitCascadingValueProvider Values="CascadingValues"> | ||
@ChildContent | ||
</BitCascadingValueProvider> | ||
</div> | ||
<div style="@Styles?.Right" class="bit-ply-right @Classes?.Right"></div> | ||
</div> | ||
<div style="@Styles?.Bottom" class="bit-ply-bottom @Classes?.Bottom"></div> | ||
</div> |
38 changes: 38 additions & 0 deletions
38
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProLayout/BitProLayout.razor.cs
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,38 @@ | ||
namespace Bit.BlazorUI; | ||
|
||
public partial class BitProLayout : BitComponentBase | ||
{ | ||
/// <summary> | ||
/// The cascading values to be provided for the children of the layout. | ||
/// </summary> | ||
[Parameter] public IEnumerable<BitCascadingValue>? CascadingValues { get; set; } | ||
|
||
/// <summary> | ||
/// The content of the layout. | ||
/// </summary> | ||
[Parameter] public RenderFragment? ChildContent { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes for different parts of the layout. | ||
/// </summary> | ||
[Parameter] public BitProLayoutClassStyles? Classes { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS styles for different parts of the layout. | ||
/// </summary> | ||
[Parameter] public BitProLayoutClassStyles? Styles { get; set; } | ||
|
||
|
||
|
||
protected override string RootElementClass => "bit-ply"; | ||
|
||
protected override void RegisterCssClasses() | ||
{ | ||
ClassBuilder.Register(() => Classes?.Root); | ||
} | ||
|
||
protected override void RegisterCssStyles() | ||
{ | ||
StyleBuilder.Register(() => Styles?.Root); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProLayout/BitProLayout.scss
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,54 @@ | ||
@import '../../Styles/extra-variables.scss'; | ||
@import '../../../Bit.BlazorUI/Styles/functions.scss'; | ||
|
||
.bit-ply { | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
background-color: $clr-bg-pri; | ||
} | ||
|
||
.bit-ply-top { | ||
width: 100%; | ||
z-index: 999999; | ||
height: $bit-env-inset-top; | ||
background-color: $clr-bg-pri; | ||
} | ||
|
||
.bit-ply-bottom { | ||
width: 100%; | ||
z-index: 999999; | ||
height: $bit-env-inset-bottom; | ||
background-color: $clr-bg-pri; | ||
} | ||
|
||
.bit-ply-center { | ||
width: 100%; | ||
display: flex; | ||
height: calc(100% - $bit-env-inset-top - $bit-env-inset-bottom); | ||
} | ||
|
||
.bit-ply-main { | ||
height: 100%; | ||
display: flex; | ||
overflow: auto; | ||
position: relative; | ||
scroll-behavior: smooth; | ||
overscroll-behavior: none; | ||
width: calc(100% - $bit-env-inset-left - $bit-env-inset-right); | ||
} | ||
|
||
.bit-ply-left { | ||
height: 100%; | ||
z-index: 999999; | ||
width: $bit-env-inset-left; | ||
background-color: $clr-bg-pri; | ||
} | ||
|
||
.bit-ply-right { | ||
height: 100%; | ||
z-index: 999999; | ||
width: $bit-env-inset-right; | ||
background-color: $clr-bg-pri; | ||
} |
39 changes: 39 additions & 0 deletions
39
src/BlazorUI/Bit.BlazorUI.Extras/Components/ProLayout/BitProLayoutClassStyles.cs
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,39 @@ | ||
namespace Bit.BlazorUI; | ||
|
||
public class BitProLayoutClassStyles | ||
{ | ||
/// <summary> | ||
/// Custom CSS classes/styles for the root of the BitProLayout. | ||
/// </summary> | ||
public string? Root { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the top area of the BitProLayout. | ||
/// </summary> | ||
public string? Top { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the center area of the BitProLayout. | ||
/// </summary> | ||
public string? Center { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the left area of the BitProLayout. | ||
/// </summary> | ||
public string? Left { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the main area of the BitProLayout. | ||
/// </summary> | ||
public string? Main { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the right area of the BitProLayout. | ||
/// </summary> | ||
public string? Right { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the bottom area of the BitProLayout. | ||
/// </summary> | ||
public string? Bottom { 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,4 @@ | ||
window.addEventListener('load', () => { | ||
document.documentElement.style.setProperty('--bit-env-win-width', `${window.innerWidth}px`); | ||
document.documentElement.style.setProperty('--bit-env-win-height', `${window.innerHeight}px`); | ||
}); |
3 changes: 2 additions & 1 deletion
3
src/BlazorUI/Bit.BlazorUI.Extras/Styles/bit.blazorui.extras.scss
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import "components.scss"; | ||
@import "general.scss"; | ||
@import "components.scss"; | ||
@import "fabric.mdl2.bit.blazoui.extras.scss"; |
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
17 changes: 17 additions & 0 deletions
17
src/BlazorUI/Bit.BlazorUI.Extras/Styles/extra-variables.scss
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,17 @@ | ||
$bit-env-inset-top: var(--bit-env-inset-top); | ||
$bit-env-inset-left: var(--bit-env-inset-left); | ||
$bit-env-inset-right: var(--bit-env-inset-right); | ||
$bit-env-inset-bottom: var(--bit-env-inset-bottom); | ||
//-- | ||
$bit-env-width-vw: var(--bit-env-width-vw); | ||
$bit-env-height-vh: var(--bit-env-height-vh); | ||
$bit-env-width-percent: var(--bit-env-width-per); | ||
$bit-env-height-percent: var(--bit-env-height-per); | ||
$bit-env-width-available: var(--bit-env-width-avl); | ||
$bit-env-height-available: var(--bit-env-height-avl); | ||
//-- | ||
$bit-env-inset-inline-start: var(--bit-env-inset-inline-start); | ||
$bit-env-inset-inline-end: var(--bit-env-inset-inline-end); | ||
//-- | ||
$bit-env-window-width: var(--bit-env-win-width); | ||
$bit-env-window-height: var(--bit-env-win-height); |
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,21 @@ | ||
:root { | ||
--bit-env-inset-top: env(safe-area-inset-top, 0px); | ||
--bit-env-inset-left: env(safe-area-inset-left, 0px); | ||
--bit-env-inset-right: env(safe-area-inset-right, 0px); | ||
--bit-env-inset-bottom: env(safe-area-inset-bottom, 0px); | ||
//-- | ||
--bit-env-width-vw: calc(100vw - var(--bit-env-inset-left) - var(--bit-env-inset-right)); | ||
--bit-env-height-vh: calc(100vh - var(--bit-env-inset-top) - var(--bit-env-inset-bottom)); | ||
--bit-env-width-per: calc(100% - var(--bit-env-inset-left) - var(--bit-env-inset-right)); | ||
--bit-env-height-per: calc(100% - var(--bit-env-inset-top) - var(--bit-env-inset-bottom)); | ||
--bit-env-width-avl: calc(var(--bit-env-win-width) - var(--bit-env-inset-left) - var(--bit-env-inset-right)); | ||
--bit-env-height-avl: calc(var(--bit-env-win-height) - var(--bit-env-inset-top) - var(--bit-env-inset-bottom)); | ||
//-- | ||
--bit-env-inset-inline-start: var(--bit-env-inset-left); | ||
--bit-env-inset-inline-end: var(--bit-env-inset-right); | ||
|
||
[dir="rtl"] { | ||
--bit-env-inset-inline-start: var(--bit-env-inset-right); | ||
--bit-env-inset-inline-end: var(--bit-env-inset-left); | ||
} | ||
} |
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
Oops, something went wrong.