Git Product home page Git Product logo

Comments (7)

SuavePirate avatar SuavePirate commented on June 16, 2024

What are your thoughts on an html/css style relationship with universal Style object and properties on Views. Could be interesting for allowing custom handlers to implement certain styles types on views where you might not expect them rather than putting individual style properties on each view.

For example, a CornerRadius or BorderRadius might not make sense for default Label, but if I wanted to implement a handler for it, I could on my own. Then you could also implement style classes with strongly typed classes. Here's a dumb and simplified example of what I'm getting at:

class Style 
{
    public virtual string Color { get; set; }
    public virtual string BackgroundColor { get; set; }
    public virtual float LetterSpacing { get; set; }
    // and like tons more properties
}

class H1Style : Style
{
    public H1Style()
    {
        Color = "#000000";
    }
}

class View
{
    public Style Style { get; set; }
}


// ...
var myStack = new HStack { new Label { Style = new H1Style() } };

from comet.

Clancey avatar Clancey commented on June 16, 2024

@SuavePirate I am looking into Style stuff. I was thinking more StyleID driven. So you would set the styles up once. https://github.com/Clancey/Comet/tree/material-design I haven't started on H1 type things yet. That is coming. But going this route, it should be nicer since we can do global styles. And have Style.Apply()

from comet.

SuavePirate avatar SuavePirate commented on June 16, 2024

Love it. I suppose you could pretty easily implement H1 type things by just subclassing components with a default StyleID as well. Let me know how I can help!

from comet.

Clancey avatar Clancey commented on June 16, 2024

So here is a current screen shot created from the following code:

 public class TextStylesSample : View
    {
        [Body]
        View body() => new VStack
        {
            new Text("H1").StyleAsH1(),
            new Text("H2").StyleAsH2(),
            new Text("H3").StyleAsH3(),
            new Text("H4").StyleAsH4(),
            new Text("H5").StyleAsH5(),
            new Text("H6").StyleAsH6(),
            new Text("Subtitle 1").StyleAsSubtitle1(),
            new Text("Subtitle 2").StyleAsSubtitle2(),
            new Text("Body 1").StyleAsBody1(),
            new Text("Body 2").StyleAsBody2(),
            new Text("Caption").StyleAsBody2(),
            new Text("OVERLINE").StyleAsOverline(),
        };
    }

image

Added with this Commit

from comet.

SuavePirate avatar SuavePirate commented on June 16, 2024

Are they applied as extension methods? What does creating your own one-off StyleAs methods look like? Love the fluent setup though

from comet.

Clancey avatar Clancey commented on June 16, 2024

So right now all the extension does is assign a StyleId, Then the properties for the style are set to the environment. Thats about all there is too it. I am making a style class so you can easily fill out the default properties, then tell it to apply. It will then auto assign things to the right spot in the environment. https://github.com/Clancey/Comet/blob/material-design/src/Comet/Styles/Style.cs#L168

from comet.

Clancey avatar Clancey commented on June 16, 2024

Done for most basic controls, I will keep going on the rest of them!

from comet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.