-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
13 changed files
with
487 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/BlazorUI/Bit.BlazorUI/Components/Layout/BitLayout.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,48 @@ | ||
@namespace Bit.BlazorUI | ||
@inherits BitComponentBase | ||
|
||
<div @ref="RootElement" | ||
@attributes="HtmlAttributes" | ||
id="@_Id" | ||
style="@StyleBuilder.Value" | ||
class="@ClassBuilder.Value" | ||
dir="@Dir?.ToString().ToLower()"> | ||
|
||
@{ | ||
var headerHeight = HeaderHeight + StatusBarHeight; | ||
var headerHeightStyle = $"{(headerHeight > 0 ? $"height:{headerHeight}px;" : "")}"; | ||
var headerPaddingStyle = $"{(StatusBarHeight > 0 ? $"padding-top:{StatusBarHeight}px;" : "")}"; | ||
var headerStyles = $"{headerHeightStyle}{headerPaddingStyle}{Styles?.Header}"; | ||
var headerClasses = $"bit-lyt-hdr{(FixedHeader ? " bit-lyt-fhd" : "")} {Classes?.Header}"; | ||
|
||
var mainPaddingTopStyle = $"{(headerHeight > 0 ? $"padding-top:{headerHeight}px;" : "")}"; | ||
var mainPaddingBottomStyle = $"{(FooterHeight > 0 ? $"padding-bottom:{FooterHeight}px;" : "")}"; | ||
var mainStyles = $"{mainPaddingTopStyle}{mainPaddingBottomStyle}{Styles?.Main}"; | ||
var mainClasses = $"bit-lyt-man {Classes?.Main}"; | ||
|
||
var footerHeightStyle = $"{(FooterHeight > 0 ? $"height:{FooterHeight}px;" : "")}"; | ||
var footerStyles = $"{footerHeightStyle}{Styles?.Footer}"; | ||
var footerClasses = $"bit-lyt-ftr{(FixedFooter ? " bit-lyt-fft" : "")} {Classes?.Footer}"; | ||
} | ||
|
||
@if (Header is not null) | ||
{ | ||
<header class="@headerClasses" style="@headerStyles"> | ||
@Header | ||
</header> | ||
} | ||
|
||
@if (Main is not null) | ||
{ | ||
<main class="@mainClasses" style="@mainStyles"> | ||
@Main | ||
</main> | ||
} | ||
|
||
@if (Footer is not null) | ||
{ | ||
<footer class="@footerClasses" style="@footerStyles"> | ||
@Footer | ||
</footer> | ||
} | ||
</div> |
67 changes: 67 additions & 0 deletions
67
src/BlazorUI/Bit.BlazorUI/Components/Layout/BitLayout.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,67 @@ | ||
namespace Bit.BlazorUI; | ||
|
||
public partial class BitLayout | ||
{ | ||
/// <summary> | ||
/// Custom CSS classes for different parts of the BitLayout. | ||
/// </summary> | ||
[Parameter] public BitLayoutClassStyles? Classes { get; set; } | ||
|
||
/// <summary> | ||
/// Enables fixed positioning of the header at the top of the viewport. | ||
/// </summary> | ||
[Parameter] public bool FixedHeader { get; set; } | ||
|
||
/// <summary> | ||
/// Enables fixed positioning of the footer at the bottom of the viewport. | ||
/// </summary> | ||
[Parameter] public bool FixedFooter { get; set; } | ||
|
||
/// <summary> | ||
/// The content of the header section. | ||
/// </summary> | ||
[Parameter] public RenderFragment? Header { get; set; } | ||
|
||
/// <summary> | ||
/// The height of the header to calculate heights and paddings. | ||
/// </summary> | ||
[Parameter] public int HeaderHeight { get; set; } | ||
|
||
/// <summary> | ||
/// The content of the main section. | ||
/// </summary> | ||
[Parameter] public RenderFragment? Main { get; set; } | ||
|
||
/// <summary> | ||
/// The content of the footer section. | ||
/// </summary> | ||
[Parameter] public RenderFragment? Footer { get; set; } | ||
|
||
/// <summary> | ||
/// The height of the footer to calculate heights and paddings. | ||
/// </summary> | ||
[Parameter] public int FooterHeight { get; set; } | ||
|
||
/// <summary> | ||
/// The height of the status bar on mobile devices to calculate heights and paddings. | ||
/// </summary> | ||
[Parameter] public int StatusBarHeight { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS styles for different parts of the BitLayout. | ||
/// </summary> | ||
[Parameter] public BitLayoutClassStyles? Styles { get; set; } | ||
|
||
|
||
protected override string RootElementClass => "bit-lyt"; | ||
|
||
protected override void RegisterCssClasses() | ||
{ | ||
ClassBuilder.Register(() => Classes?.Root); | ||
} | ||
|
||
protected override void RegisterCssStyles() | ||
{ | ||
StyleBuilder.Register(() => Styles?.Root); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/BlazorUI/Bit.BlazorUI/Components/Layout/BitLayout.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,45 @@ | ||
@import "../../Styles/functions.scss"; | ||
|
||
.bit-lyt { | ||
margin: 0; | ||
padding: 0; | ||
display: flex; | ||
min-width: 100%; | ||
min-height: 100%; | ||
flex-flow: column; | ||
position: relative; | ||
box-sizing: border-box; | ||
|
||
&.bit-dis { | ||
color: $color-foreground-disabled; | ||
} | ||
} | ||
|
||
.bit-lyt-hdr { | ||
width: 100%; | ||
box-sizing: border-box; | ||
} | ||
|
||
.bit-lyt-fhd { | ||
top: 0; | ||
position: fixed; | ||
z-index: $zindex-base; | ||
} | ||
|
||
.bit-lyt-man { | ||
width: 100%; | ||
flex-grow: 1; | ||
display: flex; | ||
box-sizing: border-box; | ||
} | ||
|
||
.bit-lyt-ftr { | ||
width: 100%; | ||
box-sizing: border-box; | ||
} | ||
|
||
.bit-lyt-fft { | ||
bottom: 0; | ||
position: fixed; | ||
z-index: $zindex-base; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/BlazorUI/Bit.BlazorUI/Components/Layout/BitLayoutClassStyles.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,24 @@ | ||
namespace Bit.BlazorUI; | ||
|
||
public class BitLayoutClassStyles | ||
{ | ||
/// <summary> | ||
/// Custom CSS classes/styles for the root element of the BitLayout. | ||
/// </summary> | ||
public string? Root { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the header section of the BitLayout. | ||
/// </summary> | ||
public string? Header { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the main section of the BitLayout. | ||
/// </summary> | ||
public string? Main { get; set; } | ||
|
||
/// <summary> | ||
/// Custom CSS classes/styles for the footer section of the BitLayout. | ||
/// </summary> | ||
public string? Footer { 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
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
53 changes: 53 additions & 0 deletions
53
...rUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Layout/BitLayoutDemo.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,53 @@ | ||
@page "/components/layout" | ||
|
||
<PageOutlet Url="components/layout" | ||
Title="layout" | ||
Description="layout component of the bit BlazorUI components" /> | ||
|
||
<ComponentDemo ComponentName="Layout" | ||
ComponentDescription="Layout can be used to create a base UI structure for an application." | ||
ComponentParameters="componentParameters" | ||
ComponentSubClasses="componentSubClasses"> | ||
<ComponentExampleBox Title="Basic" RazorCode="@example1RazorCode" Id="example1"> | ||
<ExamplePreview> | ||
<div class="container"> | ||
<BitLayout> | ||
<Header> | ||
<div class="header"> | ||
this is header | ||
</div> | ||
</Header> | ||
<Main> | ||
<div class="main"> | ||
this is main | ||
</div> | ||
</Main> | ||
<Footer> | ||
<div class="footer"> | ||
this is footer | ||
</div> | ||
</Footer> | ||
</BitLayout> | ||
</div> | ||
</ExamplePreview> | ||
</ComponentExampleBox> | ||
|
||
<ComponentExampleBox Title="Classes & Styles" RazorCode="@example2RazorCode" Id="example2"> | ||
<ExamplePreview> | ||
<div class="container"> | ||
<BitLayout Classes="@(new() { Header="header", Main="main", Footer="footer" })" | ||
Styles="@(new() { Main="height:500px" })"> | ||
<Header> | ||
this is header | ||
</Header> | ||
<Main> | ||
this is main | ||
</Main> | ||
<Footer> | ||
this is footer | ||
</Footer> | ||
</BitLayout> | ||
</div> | ||
</ExamplePreview> | ||
</ComponentExampleBox> | ||
</ComponentDemo> |
Oops, something went wrong.