-
Notifications
You must be signed in to change notification settings - Fork 19
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
Showing
21 changed files
with
166 additions
and
86 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,7 @@ | ||
namespace BlazorStyled | ||
{ | ||
public interface IGlobalStyles | ||
{ | ||
string this[string globalClassName] { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using BlazorStyled.Stylesheets; | ||
|
||
namespace BlazorStyled | ||
{ | ||
public class GlobalStyles : IGlobalStyles | ||
{ | ||
private string _id; | ||
private IStyleSheet _styleSheet; | ||
|
||
internal GlobalStyles(string id, IStyleSheet styleSheet) | ||
{ | ||
_id = id; | ||
_styleSheet = styleSheet; | ||
} | ||
|
||
public string this[string globalClassName] | ||
{ | ||
get | ||
{ | ||
return _styleSheet.GlobalStyle(_id, globalClassName); | ||
} | ||
|
||
set | ||
{ | ||
_styleSheet.AddOrUpdateGlobalStyle(_id, globalClassName, value); | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace BlazorStyled.Internal | ||
{ | ||
internal class InternalGlobalStyles : IGlobalStyles | ||
{ | ||
private IDictionary<string, string> _globalStyles = new Dictionary<string, string>(); | ||
|
||
public string this[string globalClassName] | ||
{ | ||
get | ||
{ | ||
if(_globalStyles.ContainsKey(globalClassName)) | ||
{ | ||
return _globalStyles[globalClassName]; | ||
} | ||
else | ||
{ | ||
return String.Empty; | ||
} | ||
} | ||
|
||
set | ||
{ | ||
if(_globalStyles.ContainsKey(globalClassName)) | ||
{ | ||
_globalStyles[globalClassName] = value; | ||
} | ||
else | ||
{ | ||
_globalStyles.Add(globalClassName, value); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@page "/globalStyles" | ||
@inject IStyled Styled | ||
|
||
<h1>Global Styles</h1> | ||
|
||
<p> | ||
Global styles allows you to define a style and use it again later in a different component. | ||
Assign a name ("ColorHotPink" in the example below) for the style in the <code>GlobalStyle</code> property in the <code><Styled /></code>. | ||
For example, the below snippet is defined in <code>MainLayout.cs</code>: | ||
</p> | ||
|
||
<PrettyCode CodeFile="_content/SampleCore/globalstyles1.html" Title="MainLayout.cs" /> | ||
|
||
<p>Once the style is defined as a Global Style you may use it in another component by injecting <code>IStyled</code> and | ||
accessing <code>Styled.GlobalStyles</code>. For example:</p> | ||
|
||
<p class="@Styled.GlobalStyles["ColorHotPink"]">This paragraph is hot pink because the it uses a global style that defines it to be hot pink.</p> | ||
|
||
<PrettyCode CodeFile="_content/SampleCore/globalstyles2.html" /> |
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
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,66 +1,6 @@ | ||
@page "/test" | ||
@inject IStyled Styled | ||
|
||
<section class="@_currentSlideClass"> | ||
TEST | ||
</section> | ||
|
||
<Styled @bind-Classname="@_slide"> | ||
label: section; | ||
display: none; | ||
position: absolute; | ||
width: 100%; | ||
padding: 20px 0px; | ||
pointer-events: auto; | ||
z-index: 10; | ||
-webkit-transform-style: flat; | ||
transform-style: flat; | ||
transition: -webkit-transform-origin 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), -webkit-transform 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), visibility 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), opacity 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); | ||
transition: transform-origin 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), transform 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), visibility 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985), opacity 800ms cubic-bezier(0.26, 0.86, 0.44, 0.985); | ||
-webkit-perspective: 600px; | ||
perspective: 600px; | ||
</Styled> | ||
|
||
<Styled @bind-Classname="@_center"> | ||
min-height: 0 !important; | ||
</Styled> | ||
|
||
<Styled @bind-Classname="@_present"> | ||
label: present; | ||
display: block; | ||
z-index: 11; | ||
opacity: 1; | ||
</Styled> | ||
|
||
<Styled @bind-Classname="@_notPresent"> | ||
label: not-present; | ||
pointer-events: none; | ||
opacity: 0; | ||
</Styled> | ||
|
||
<Styled @bind-Classname="@_future"> | ||
label: future; | ||
</Styled> | ||
|
||
<Styled @bind-Classname="@_past"> | ||
label: past; | ||
</Styled> | ||
|
||
<Styled @bind-Classname="@_currentSlideClass" | ||
Compose1="@_slide" | ||
Compose2="@_center" | ||
Compose3="@_present" | ||
Compose4="@_notPresent" | ||
Compose5="@_future" | ||
Compose6="@_past" | ||
Compose3If="@(Index == CurrentSlide)" | ||
Compose4If="@(Index != CurrentSlide)" | ||
Compose5If="@(Index > CurrentSlide)" | ||
Compose6If="@(Index < CurrentSlide)" /> | ||
|
||
@code { | ||
private string _currentSlideClass, _slide, _center, _present, _notPresent, _future, _past; | ||
|
||
public int Index { get; set; } = 5; | ||
public int CurrentSlide { get; set; } = 5; | ||
} | ||
<div class="@Styled.GlobalStyles["ColorRed"]"> | ||
Test | ||
</div> |
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.