Skip to content

Commit

Permalink
1.0.0-preview8-03
Browse files Browse the repository at this point in the history
  • Loading branch information
chanan committed Aug 15, 2019
1 parent 4ca882c commit 176226d
Show file tree
Hide file tree
Showing 65 changed files with 603 additions and 285 deletions.
33 changes: 18 additions & 15 deletions docs/_content/SampleCore/components2.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Styled @bind-Classname="button">
<Styled @bind-Classname="@button">
font-size:16px;
margin:18px;
border:none;
Expand All @@ -11,25 +11,28 @@
color:#fff;
box-shadow:0 4px 6px rgba(50,50,93,.11), 0 1px 3px rgba(0,0,0,.08);
background-color:@Color;
&:hover {
opacity: 0.7;
transform:translateY(-1px);
box-shadow:0 7px 14px rgba(50,50,93,.1), 0 3px 6px rgba(0,0,0,.08);
}
&:focus {
outline:0;
}
&:active {
transform:translateY(1px);
}
</Styled>

<Styled Classname="@button" PseudoClass="PseudoClasses.Hover">
opacity: 0.7;
transform:translateY(-1px);
box-shadow:0 7px 14px rgba(50,50,93,.1), 0 3px 6px rgba(0,0,0,.08);
</Styled>

<Styled Classname="@button" PseudoClass="PseudoClasses.Focus">
outline:0;
</Styled>

<Styled Classname="@button" PseudoClass="PseudoClasses.Active">
transform:translateY(1px);
</Styled>

<button class="@button" @onclick="@OnClick">@ChildContent</button>

@code {
[Parameter] private RenderFragment ChildContent { get; set; }
[Parameter] private EventCallback<UIMouseEventArgs> OnClick { get; set; }
[Parameter] private string Color { get; set; } = "green";
[Parameter] public RenderFragment ChildContent { get; set; }
[Parameter] public EventCallback<UIMouseEventArgs> OnClick { get; set; }
[Parameter] public string Color { get; set; } = "green";

private string button;
}
7 changes: 4 additions & 3 deletions docs/_content/SampleCore/index1.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
&:hover {
color: @color;
}
</Styled>

<Styled Classname="@hover" PseudoClass="PseudoClasses.Hover">
color: @color;
</Styled>

<div class="@hover">
Expand Down
33 changes: 33 additions & 0 deletions docs/_content/SampleCore/install5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
services.AddServerSideBlazor();
services.AddBlazorStyled();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
}
}
19 changes: 19 additions & 0 deletions docs/_content/SampleCore/install6.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@page "/"
@namespace ServerSideSample.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BlazorStyled Server-Side Sample</title>
<base href="~/" />
@(await Html.RenderComponentAsync<BlazorStyled.ServerSideStyled>())
</head>
<body>
<app>@(await Html.RenderComponentAsync<SampleCore.App>())</app>

<script src="_framework/blazor.server.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion docs/_content/SampleCore/keyframes1.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</Styled>

<Styled @bind-Classname="@example">
animation: vlzl-qdd 1s ease infinite;
animation: @bounce 1s ease infinite;
</Styled>

<div class="@example">Some bouncing text!</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/_content/SampleCore/media1.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Styled @bind-Classname="@p1">
font-size: 30px;
@@media (min-width: 420px) {
@@media (min-width: 480px) {
font-size: 50px;
}
</Styled>
Expand Down
2 changes: 1 addition & 1 deletion docs/_content/SampleCore/media2.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

private int[] breakpoints = new int[] { 576, 768, 992, 1200 };

protected override void OnInit()
protected override void OnInitialized()
{
var mq = (from b in breakpoints
select $"@media (min-width: {b}px)").ToArray();
Expand Down
13 changes: 13 additions & 0 deletions docs/_content/SampleCore/media4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Styled @bind-Classname="@p1">
font-size: 30px;
</Styled>

<Styled Classname="@p1" MediaQuery="MediaQueries.LargerThanMobile">
font-size: 50px;
</Styled>

<p class="@p1">Some text!</p>

@code {
private string p1;
}
4 changes: 2 additions & 2 deletions docs/_content/SampleCore/nested1.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Styled @bind-Classname="@nested">
color: turquoise;
& a {
border-bottom: 1px solid currentColor;
cursor:pointer;
border-bottom: 1px solid currentColor;
cursor:pointer;
}
</Styled>

Expand Down
2 changes: 1 addition & 1 deletion docs/_content/SampleCore/nested2.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Styled @bind-Classname="@paragraph">
color: turquoise;
header & {
color: green;
color: green;
}
</Styled>

Expand Down
19 changes: 19 additions & 0 deletions docs/_content/SampleCore/nested3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Styled @bind-Classname="@hover">
label: hover-example;
padding: 32px;
background-color: hotpink;
font-size: 24px;
border-radius: 4px;
&:hover {
color: @color;
}
</Styled>

<div class="@hover">
Hover to change color.
</div>

@code {
private string hover;
private string color = "white";
}
2 changes: 1 addition & 1 deletion docs/_content/SampleCore/polished1.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@code {
private string arrow, gradient;

protected override void OnInit()
protected override void OnInitialized()
{
arrow = Styled.Css(Mixins.Triangle(new TriangleConfiguration
{
Expand Down
2 changes: 1 addition & 1 deletion docs/_content/SampleCore/theming1.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@code {
private string example;

protected override void OnInit()
protected override void OnInitialized()
{
//Normally this would be defined else where such as in MainLayout.cs
Styled.Theme.Values.Add("colors.primary", "hotpink");
Expand Down
Binary file modified docs/_framework/_bin/BlazorPrettyCode.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/BlazorStyled.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/BlazorStyled.pdb
Binary file not shown.
Binary file modified docs/_framework/_bin/BlazorTypography.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/ClientSideSample.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/ClientSideSample.pdb
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.AspNetCore.Authorization.dll
Binary file not shown.
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.AspNetCore.Blazor.dll
Binary file not shown.
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.AspNetCore.Components.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.AspNetCore.Metadata.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.Bcl.AsyncInterfaces.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.Extensions.Options.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.Extensions.Primitives.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/Microsoft.JSInterop.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/Mono.Security.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/Mono.WebAssembly.Interop.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/SampleCore.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/SampleCore.pdb
Binary file not shown.
Binary file modified docs/_framework/_bin/System.ComponentModel.Annotations.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/System.Core.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/System.Net.Http.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/System.Runtime.CompilerServices.Unsafe.dll
Binary file not shown.
Binary file not shown.
Binary file modified docs/_framework/_bin/System.Text.Json.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/System.dll
Binary file not shown.
Binary file modified docs/_framework/_bin/mscorlib.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_framework/blazor.boot.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"main":"ClientSideSample.dll","entryPoint":"Sample.Program::Main","assemblyReferences":["BlazorPrettyCode.dll","BlazorStyled.dll","BlazorTypography.dll","CSHTMLTokenizer.dll","Microsoft.AspNetCore.Authorization.dll","Microsoft.AspNetCore.Blazor.dll","Microsoft.AspNetCore.Components.Browser.dll","Microsoft.AspNetCore.Components.dll","Microsoft.AspNetCore.Metadata.dll","Microsoft.Bcl.AsyncInterfaces.dll","Microsoft.Extensions.DependencyInjection.Abstractions.dll","Microsoft.Extensions.DependencyInjection.dll","Microsoft.Extensions.Logging.Abstractions.dll","Microsoft.Extensions.Options.dll","Microsoft.Extensions.Primitives.dll","Microsoft.JSInterop.dll","Mono.Security.dll","Mono.WebAssembly.Interop.dll","mscorlib.dll","Newtonsoft.Json.dll","Polished.net.dll","SampleCore.dll","Stateless.dll","System.Buffers.dll","System.ComponentModel.Annotations.dll","System.Core.dll","System.Data.dll","System.dll","System.Memory.dll","System.Net.Http.dll","System.Numerics.dll","System.Numerics.Vectors.dll","System.Runtime.CompilerServices.Unsafe.dll","System.Runtime.Serialization.dll","System.Text.Json.dll","System.Threading.Tasks.Extensions.dll","System.Xml.dll","System.Xml.Linq.dll","BlazorStyled.pdb","ClientSideSample.pdb","SampleCore.pdb"],"cssReferences":[],"jsReferences":[],"linkerEnabled":true}
{"main":"ClientSideSample.dll","entryPoint":"Sample.Program::Main","assemblyReferences":["BlazorPrettyCode.dll","BlazorStyled.dll","BlazorTypography.dll","CSHTMLTokenizer.dll","Microsoft.AspNetCore.Authorization.dll","Microsoft.AspNetCore.Blazor.dll","Microsoft.AspNetCore.Blazor.HttpClient.dll","Microsoft.AspNetCore.Components.dll","Microsoft.AspNetCore.Components.Web.dll","Microsoft.AspNetCore.Metadata.dll","Microsoft.Bcl.AsyncInterfaces.dll","Microsoft.Extensions.DependencyInjection.Abstractions.dll","Microsoft.Extensions.DependencyInjection.dll","Microsoft.Extensions.Logging.Abstractions.dll","Microsoft.Extensions.Options.dll","Microsoft.Extensions.Primitives.dll","Microsoft.JSInterop.dll","Mono.Security.dll","Mono.WebAssembly.Interop.dll","mscorlib.dll","Polished.net.dll","SampleCore.dll","Stateless.dll","System.Buffers.dll","System.ComponentModel.Annotations.dll","System.Core.dll","System.dll","System.Memory.dll","System.Net.Http.dll","System.Numerics.Vectors.dll","System.Runtime.CompilerServices.Unsafe.dll","System.Text.Encodings.Web.dll","System.Text.Json.dll","System.Threading.Tasks.Extensions.dll","BlazorStyled.pdb","ClientSideSample.pdb","SampleCore.pdb"],"cssReferences":[],"jsReferences":[],"linkerEnabled":true}
6 changes: 3 additions & 3 deletions docs/_framework/blazor.server.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/_framework/blazor.webassembly.js

Large diffs are not rendered by default.

325 changes: 166 additions & 159 deletions docs/_framework/wasm/mono.js

Large diffs are not rendered by default.

Binary file modified docs/_framework/wasm/mono.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion src/BlazorStyled/BlazorStyled.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<LangVersion>8.0</LangVersion>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<PackageId>BlazorStyled</PackageId>
<Version>1.0.0-preview8-02</Version>
<Version>1.0.0-preview8-03</Version>
<Authors>Chanan Braunstein</Authors>
<Title>BlazorStyled</Title>
<Description>CSS in Blazor Components</Description>
Expand Down
2 changes: 1 addition & 1 deletion src/BlazorStyled/ClientSideStyled.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

@foreach (var cssClass in StyleSheet)
{
<CssClass Css="@cssClass.ToString()" />
<CssClass @key="@cssClass.Hash" Css="@cssClass.ToString()" />
}
28 changes: 27 additions & 1 deletion src/BlazorStyled/Internal/BaseRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace BlazorStyled.Internal
{
internal abstract class BaseRule : IRule
internal abstract class BaseRule : IRule, IEqualityComparer<IRule>, IEquatable<IRule>
{
protected readonly Hash _hashService = new Hash();
private readonly List<Declaration> _declarations = new List<Declaration>();
Expand Down Expand Up @@ -65,5 +65,31 @@ public virtual void SetClassname()
{
//ignored
}

public bool Equals(IRule x, IRule y)
{
Console.WriteLine("Equals");
if (object.ReferenceEquals(x, y))
{
return true;
}

if (x is null || y == null)
{
return false;
}

return x.Hash == y.Hash;
}

public int GetHashCode(IRule obj)
{
return Hash.GetHashCode();
}

public bool Equals(IRule other)
{
return Equals(this, other);
}
}
}
1 change: 1 addition & 0 deletions src/BlazorStyled/Internal/ImportUri.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public ImportUri(string uri)
{
_uri = uri;
AddDeclaration(new Declaration { Property = "@import", Value = uri });
SetHash();
Selector = Hash;
}

Expand Down
2 changes: 1 addition & 1 deletion src/BlazorStyled/Styled.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private string GetMediaQuery()
};
}

private string RenderAsString()
private string RenderAsString()
{
string result = string.Empty;
try
Expand Down
4 changes: 3 additions & 1 deletion src/BlazorStyled/StyledBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace BlazorStyled
public class StyledBase : ComponentBase, IObserver<IStyleSheet>, IDisposable
{
[Inject] protected IStyleSheet StyleSheet { get; private set; }
protected IStyleSheet CurrentStylesheet { get; private set; }
private string _hashCode = null;
private bool _shouldRender = true;

Expand Down Expand Up @@ -35,9 +36,10 @@ public void OnError(Exception error)
public void OnNext(IStyleSheet value)
{
//Only call state has changed if the stylesheet really changed
string newHashCode = StyleSheet.GetHashCodes();
string newHashCode = value.GetHashCodes();
if (_hashCode != newHashCode)
{
CurrentStylesheet = value;
_shouldRender = true;
InvokeAsync(StateHasChanged);
_hashCode = newHashCode;
Expand Down
Loading

0 comments on commit 176226d

Please sign in to comment.