diff --git a/leptos_components/src/components/buttons.rs b/leptos_components/src/components/buttons.rs new file mode 100644 index 0000000..1598e14 --- /dev/null +++ b/leptos_components/src/components/buttons.rs @@ -0,0 +1,46 @@ +use leptos::prelude::*; +use leptos::logging; + +pub enum ButtonStyle { + Primary, + Secondary, + Success, + Danger, + Warning +} + +#[component] +pub fn Button( + #[prop(optional)] + style: Option, + children: Children, +) -> impl IntoView { + let style_type; + if style.is_none() { + style_type = ButtonStyle::Primary; + } else { + style_type = style.unwrap(); + } + let mut stylestring = ""; + match style_type { + ButtonStyle::Primary => { + stylestring = "bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"; + }, + ButtonStyle::Secondary => { + stylestring = "bg-gray-300 hover:bg-gray-500 text-black font-semibold py-2 px-4 rounded"; + }, + ButtonStyle::Success => { + stylestring = "bg-green-500 hover:bg-green-700 text-white font-bold py-2 px-4 rounded"; + }, + ButtonStyle::Danger => { + stylestring = "bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded"; + }, + ButtonStyle::Warning => { + stylestring = "bg-yellow-500 hover:bg-yellow-700 text-black font-semibold py-2 px-4 rounded"; + } + } + logging::log!("{}", stylestring); + view! { + + } +} \ No newline at end of file diff --git a/leptos_components/src/components/mod.rs b/leptos_components/src/components/mod.rs new file mode 100644 index 0000000..5f96a44 --- /dev/null +++ b/leptos_components/src/components/mod.rs @@ -0,0 +1 @@ +pub mod buttons; \ No newline at end of file diff --git a/leptos_components/src/lib.rs b/leptos_components/src/lib.rs index bbcb4e2..6f59cdd 100644 --- a/leptos_components/src/lib.rs +++ b/leptos_components/src/lib.rs @@ -1,11 +1,2 @@ -use leptos::prelude::*; +pub mod components; - -#[component] -pub fn Button( - children: Children, -) -> impl IntoView { - view! { - - } -} \ No newline at end of file diff --git a/website/Cargo.toml b/website/Cargo.toml index 1119705..6fedfed 100644 --- a/website/Cargo.toml +++ b/website/Cargo.toml @@ -56,7 +56,11 @@ site-root = "target/site" site-pkg-dir = "pkg" # [Optional] The source CSS file. If it ends with .sass or .scss then it will be compiled by dart-sass into CSS. The CSS is optimized by Lightning CSS before being written to //app.css -style-file = "style/main.scss" +#style-file = "style/tailwind.css" + +# Optional, Activates the tailwind build +tailwind-input-file = "style/tailwind.css" + # Assets source dir. All files found here will be copied and synchronized to site-root. # The assets-dir cannot have a sub directory with the same name/path as site-pkg-dir. # @@ -64,10 +68,10 @@ style-file = "style/main.scss" assets-dir = "public" # The IP and port (ex: 127.0.0.1:3000) where the server serves the content. Use it in your server setup. -site-addr = "127.0.0.1:3000" +site-addr = "127.0.0.1:5000" # The port to use for automatic reload monitoring -reload-port = 3001 +reload-port = 5001 # [Optional] Command to use when running end2end tests. It will run in the end2end dir. # [Windows] for non-WSL use "npx.cmd playwright test" diff --git a/website/src/app.rs b/website/src/app.rs index 1c357c0..8349451 100644 --- a/website/src/app.rs +++ b/website/src/app.rs @@ -4,7 +4,7 @@ use leptos_router::{ components::{Route, Router, Routes}, StaticSegment, }; -use leptos_components::Button; +use leptos_components::components::buttons::Button; pub fn shell(options: LeptosOptions) -> impl IntoView { view! { @@ -57,7 +57,7 @@ fn HomePage() -> impl IntoView { view! {

"Welcome to Leptos!"

- - + + } } diff --git a/website/tailwind.config.js b/website/tailwind.config.js index a691adb..47e9204 100644 --- a/website/tailwind.config.js +++ b/website/tailwind.config.js @@ -1,7 +1,7 @@ /** @type {import('tailwindcss').Config} */ module.exports = { content: { - files: ["*.html", "./src/**/*.rs"], + files: ["*.html", "./src/**/*.rs", "../leptos_components/src/**/*.rs"], transform: { rs: (content) => content.replace(/(?:^|\s)class:/g, ' '), },