GithubHelp home page GithubHelp logo

lookbook's Introduction

Lookbook

UI preview framework for Dioxus


/// To-Do Task.
#[preview]
pub fn TaskPreview(
    /// Label of the task.
    #[lookbook(default = "Ice skating")]
    label: String,

    /// Content of the task.
    #[lookbook(default = "Central Park")]
    content: String,

    /// List of tags.
    #[lookbook(default = vec![String::from("A")])]
    tags: Json<Vec<String>>,
) -> Element {
    rsx!(
        div {
            h4 { "{label}" }
            p { "{content}" }
            div { { tags.0.iter().map(|tag| rsx!(li { "{tag}" })) } }
        }
    )
}

#[component]
fn app() -> Element {
    rsx!(LookBook {
        home: |()| rsx!("Home"),
        previews: [TaskPreview]
    })
}

fn main() {
    dioxus::launch(app)
}

Usage

First add Lookbook as a dependency to your project.

cargo add lookbook --git https://github.com/matthunz/lookbook

Then create a preview like the one above and add it to a lookbook.

fn app(cx: Scope) -> Element {
    rsx!(LookBook {
        home: |cx| rsx!("Home"),
        previews: [TaskPreview]
    })
}

fn main() {
    dioxus_web::launch(app)
}

Run with dx serve!

Running examples

Run the examples with dx serve --example {name}.

lookbook's People

Contributors

matthunz avatar

Stargazers

Niels Gouman avatar James Flynn avatar Rishi Jindal avatar Tyler Sengia avatar Niclas Overby โ“ƒ avatar Ted Feng avatar invisageable avatar Johan avatar Jung Woong Park avatar Weru avatar Chiru B avatar Brandon Pollack avatar Stuart Gilliland  avatar Lynn Dylan Hurley avatar Kevin Klingelhoefer avatar  avatar John Skottis avatar  avatar WolfSkin avatar Manuel Bichler avatar  avatar  avatar Corey Rusko avatar Andrejs Agejevs avatar Evan Almloff avatar Jay avatar Jonathan Kelley avatar Marc Espin avatar

Watchers

 avatar  avatar

lookbook's Issues

How is this supposed to run in relation to my app?

I'm new to rust so I apologize if these are stupid questions.

In the README example, you have the dioxus_web::launch(app) in the main function of what looks like the app.

But shouldn't the main function of my app be used to actually run my app?

I checked the dioxus-material app, and it looks like the lookbook directory is a separate app from the main one. This makes sense, but it doesn't look like the lookbook app is able to directly reference the components in the main dioxus_material package. It seems to be loading them from github. If this is the case, then wouldn't that mean that the changes would need to be pushed up to github and reinstalled before they could be observed in lookbook?

So my question is, what is the best way to set up lookbook so that I can observe the changes in real time and have my actual app running concurrently with the lookbook interface?

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.