chanan / blazorous Goto Github PK
View Code? Open in Web Editor NEWMaintainable CSS with Blazor
Home Page: https://chanan.github.io/Blazorous/
License: The Unlicense
Maintainable CSS with Blazor
Home Page: https://chanan.github.io/Blazorous/
License: The Unlicense
Add to the API a way to append multiple rules at once. Something like:
css.AddRules("font-size", "2.4em", "margin-top", 10);
<Dynamic TagName="div" debug="true" />
Will output debug information to the console
From Glamorous:
const Alert = glamorous.div('alert', props => `alert-${props.type}`);
This will result in:
<div class="alert alert-danger">...</div>
The following does not work correctly:
Css secondPre = Css.CreateNew()
.AddRule("position", "relative")
.AddRule("padding", 20)
.OpenSelector(":before")
.AddRule("position", "absolute")
.AddRule("top", 0)
.AddRule("opacity", 0.6)
.AddRule("left", "7px")
.AddRule("font-size", "0.8rem")
.CloseSelector()
.AddDynamicRule((css, attributes) =>
{
var lang = attributes.GetStringAttribute("language");
var isHtml = "html" == lang;
css.OpenSelector(":before")
.AddRule("content", $"\\\"{lang}\\\"")
.CloseSelector();
if (isHtml)
{
css.AddRule("background-color", "#0c1e35")
.AddRule("color", "white");
}
});
When converted to json, :before isn't merged, its overwritten.
From: https://glamorous.rocks/getting-started/
The following does not work in Blazorous:
const ListItem = glamorous.li({
':before': {
content: '"๐"',
}
})
The error:
MonoPlatform.ts:70 Uncaught (in promise) Error: Microsoft.AspNetCore.Blazor.Browser.Interop.JavaScriptException: Unexpected token * in JSON at position 26
SyntaxError: Unexpected token ๐ in JSON at position 26
at JSON.parse (<anonymous>)
Add to Css API something like:
ICss css = Css.CreateNew().ApplyThemeSnippet("Some snippet name");
ICss css2 = Css.CreateNew().AddRule("Color" "{Some var name}");
<Dynamic TagName="div" ref="divRef" />
The above does not currently work right.
From glamor readme:
there are two methods by which the library adds styles to the document -
as a compromise, we enable the former 'speedy' mode NODE_ENV=production, and disable it otherwise. You can manually toggle this with the speedy() function.
Example from Glamorous:
<glamorous.Div maxWidth={600} margin="70px auto" fontSize={24} />
Convert "Unknown" attributes that match css properties to a css style.
So this:
<Dynamic TagName="div" maxWidth="600" margin="70px auto" fontSize="24" />
Should be equivalent to:
<Dynamic TagName="div"css="@css" />
@functions {
Css css = Css.CreateNew().AddRule("max-width", 600).AddRule("margin", "70px auto").AddRule("font-size", 24);
}
Provide a way to allow for themes and context,
Would require to register a class in DI?
Due to the fact that Glamorous has been deprecated, I am deprecating Blazorous as well. However, I wrote a new library that does not rely on any JS framework that has similar functionality although a different API: https://chanan.github.io/BlazorStyled/ (https://github.com/chanan/BlazorStyled).
Consider adding something like so:
<Dynamic TagName="a" hover="@hover">Link with a red hover</Dynamic>
ICss hover = Css.CreateNew().AddRule("color", "red");
deprecate OpenSelector
, CloseSelector
Change to use AddChildSelector(string name, Action<Css> css)
Consider making a library of pre made components for each html tag such as:
<Dynamic TagName="h1" ...>@ChildContent</Dynamic>
Give it a standard name such as BlazorousH1 that can then be used in the site:
<BlazorousH1>Heading 1</BlazorousH1>
The heading can then be styled like other Dynamic
tags either with the css prop or if css style attributes are implemented.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.