diff --git a/gui/ui/examples/design-system/Cargo.toml b/gui/ui/examples/design-system/Cargo.toml deleted file mode 100644 index 0c645a43..00000000 --- a/gui/ui/examples/design-system/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "design-system" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -iced = "0.10" -web-sys = "0.3.61" -chrono = "0.4" -liana_ui = { path = "../.." } - -[workspace] diff --git a/gui/ui/examples/design-system/README.md b/gui/ui/examples/design-system/README.md deleted file mode 100644 index c604a44b..00000000 --- a/gui/ui/examples/design-system/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Use WASM - -`trunk serve` - -to build for a directory on a distant server - -`trunk build --public-url /design-system` diff --git a/gui/ui/examples/design-system/index.html b/gui/ui/examples/design-system/index.html deleted file mode 100644 index eec96dd9..00000000 --- a/gui/ui/examples/design-system/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Liana design system - - - - - - - diff --git a/gui/ui/examples/design-system/src/main.rs b/gui/ui/examples/design-system/src/main.rs deleted file mode 100644 index 87f0d23c..00000000 --- a/gui/ui/examples/design-system/src/main.rs +++ /dev/null @@ -1,153 +0,0 @@ -mod section; - -use iced::widget::{button, column, container, row, scrollable, text, Space}; -use iced::{executor, Application, Command, Length, Settings, Subscription}; -use liana_ui::{component::text::*, font, image, theme, widget::*}; - -pub fn main() -> iced::Result { - let mut settings = Settings::with_flags(Config {}); - settings.default_text_size = P1_SIZE.into(); - settings.default_font = font::REGULAR; - DesignSystem::run(settings) -} - -struct Config {} - -#[derive(Default)] -struct DesignSystem { - theme: theme::Theme, - sections: Vec>, - current: usize, -} - -#[derive(Debug, Clone)] -pub enum Message { - FontLoaded(Result<(), iced::font::Error>), - Event(iced::Event), - Section(usize), - Ignore, -} - -impl From> for Message { - fn from(res: Result<(), iced::font::Error>) -> Message { - Message::FontLoaded(res) - } -} - -impl Application for DesignSystem { - type Message = Message; - type Theme = theme::Theme; - type Flags = Config; - type Executor = executor::Default; - - fn title(&self) -> String { - String::from("Liana - Design System") - } - - fn new(_config: Config) -> (Self, Command) { - let app = Self { - theme: theme::Theme::Dark, - sections: vec![ - Box::new(section::Overview {}), - Box::new(section::Colors {}), - Box::new(section::Typography {}), - Box::new(section::Buttons {}), - Box::new(section::HardwareWallets {}), - Box::new(section::Events {}), - ], - current: 0, - }; - #[allow(unused_mut)] - let mut cmds: Vec> = font::loads(); - - #[cfg(target_arch = "wasm32")] - { - use iced_native::{command, window}; - let window = web_sys::window().unwrap(); - let (width, height) = ( - (window.inner_width().unwrap().as_f64().unwrap()) as u32, - (window.inner_height().unwrap().as_f64().unwrap()) as u32, - ); - cmds.push(Command::single(command::Action::Window( - window::Action::Resize { width, height }, - ))); - } - - (app, Command::batch(cmds)) - } - - fn update(&mut self, message: Message) -> Command { - match message { - Message::Section(i) => { - if self.sections.get(i).is_some() { - self.current = i; - } - } - Message::Event(iced::Event::Window(iced::window::Event::Resized { width, height })) => { - #[cfg(target_arch = "wasm32")] - { - use iced_native::{command, window}; - return Command::single(command::Action::Window(window::Action::Resize { - width, - height, - })); - } - } - _ => {} - } - Command::none() - } - - fn subscription(&self) -> Subscription { - iced::subscription::events().map(Self::Message::Event) - } - - fn view(&self) -> Element { - let sidebar = container( - column![ - image::liana_grey_logo(), - Space::with_height(Length::Fixed(100.0)), - self.sections.iter().enumerate().fold( - Column::new().spacing(10), - |col, (i, section)| col.push( - button( - container(text(section.title())) - .width(Length::Fill) - .padding(10) - ) - .style(theme::Button::Menu(i == self.current)) - .on_press(Message::Section(i)) - .width(Length::Fixed(200.0)) - ) - ) - ] - .spacing(20), - ) - .padding(20) - .style(theme::Container::Foreground) - .height(Length::Fill); - - container(row![ - sidebar.width(Length::FillPortion(2)), - Space::with_width(Length::FillPortion(1)), - container(scrollable(column![ - Space::with_height(Length::Fixed(150.0)), - container(self.sections[self.current].view()).width(Length::Fill) - ])) - .width(Length::FillPortion(8)), - Space::with_width(Length::FillPortion(1)), - ]) - .width(Length::Fill) - .height(Length::Fill) - .into() - } - - fn theme(&self) -> theme::Theme { - self.theme.clone() - } -} - -pub trait Section { - fn title(&self) -> &'static str; - fn view(&self) -> Element; -} diff --git a/gui/ui/examples/design-system/src/section.rs b/gui/ui/examples/design-system/src/section.rs deleted file mode 100644 index 4fb9c575..00000000 --- a/gui/ui/examples/design-system/src/section.rs +++ /dev/null @@ -1,287 +0,0 @@ -use iced::{ - alignment, - widget::{button, column, container, row, Space}, - Alignment, Length, -}; -use liana_ui::{ - color, - component::{amount::Amount, event, hw, separation, text::*}, - theme, - widget::Element, -}; - -use super::{Message, Section}; - -pub struct Overview {} - -impl Section for Overview { - fn title(&self) -> &'static str { - "Overview" - } - - fn view(&self) -> Element { - column![ - h1("Hello"), - column![text( - "This is the Liana design system for the Iced framework" - )] - .spacing(10) - ] - .spacing(100) - .into() - } -} - -pub struct Colors {} - -impl Section for Colors { - fn title(&self) -> &'static str { - "Colors" - } - - fn view(&self) -> Element { - column![ - h1(self.title()), - column![ - color_row(color::BLACK, "BLACK (0,0,0)"), - color_row(color::LIGHT_BLACK, "LIGHT_BLACK #141414 original design"), - color_row(color::GREEN, "GREEN #00FF66 original design"), - color_row(color::GREY_7, "GREY #3F3F3F"), - color_row(color::GREY_6, "GREY #202020"), - color_row(color::GREY_5, "GREY #272727"), - color_row(color::GREY_4, "GREY #424242"), - color_row(color::GREY_3, "GREY #717171"), - color_row(color::GREY_2, "GREY #CCCCCC"), - color_row(color::GREY_1, "GREY #E6E6E6"), - color_row(color::WHITE, "WHITE #FFFFFF"), - color_row(color::RED, "RED #F04359"), - color_row(color::ORANGE, "ORANGE #FFa700") - ] - .spacing(10) - ] - .spacing(100) - .into() - } -} - -pub struct Typography {} - -impl Section for Typography { - fn title(&self) -> &'static str { - "Typography" - } - - fn view(&self) -> Element { - column![ - h1(self.title()), - column![ - column![ - h2("Font-Family"), - separation().width(Length::Fill), - h1("IBM Plex Sans"), - ] - .spacing(10), - column![ - h2("Heading"), - separation().width(Length::Fill), - h1("H1. Heading 40 bold"), - h2("H2. Heading 29 bold"), - h3("H3. Heading 24 bold"), - h4_bold("H4. Heading 20 bold"), - h4_regular("H4. Heading 20 regular"), - h5_medium("H5. Heading 18 medium"), - h5_regular("H5. Heading 18 regular"), - ] - .spacing(10), - column![ - h2("Body"), - separation().width(Length::Fill), - p1_bold("P1. Body 16 bold"), - p1_medium("P1. Body 16 medium"), - p1_regular("P1. Body 16 regular"), - p2_medium("P2. Body 14 medium"), - p2_regular("P2. Body 14 regular"), - caption("Caption Body 12 regular"), - ] - .spacing(10), - ] - .spacing(50) - ] - .spacing(100) - .into() - } -} - -fn color_row<'a, T: 'a>(color: iced::Color, label: &'static str) -> Element<'a, T> { - row![ - container(Space::with_width(Length::Fixed(100.0))) - .height(Length::Fixed(100.0)) - .style(theme::Container::Custom(color)), - text(label) - ] - .spacing(10) - .align_items(Alignment::Center) - .spacing(10) - .into() -} - -pub struct Buttons {} - -impl Section for Buttons { - fn title(&self) -> &'static str { - "Buttons" - } - - fn view(&self) -> Element { - column![ - h1(self.title()), - column![ - button_row(theme::Button::Primary, "Primary"), - button_row(theme::Button::Secondary, "Secondary"), - button_row(theme::Button::Destructive, "Destructive"), - button_row(theme::Button::Transparent, "Transparent"), - button_row(theme::Button::TransparentBorder, "Transparent Border"), - button_row(theme::Button::Border, "Border"), - ] - .spacing(20) - ] - .spacing(100) - .into() - } -} - -fn button_row(style: theme::Button, label: &'static str) -> Element { - button( - container(text(label)) - .width(Length::Fill) - .align_x(alignment::Horizontal::Center), - ) - .width(Length::Fixed(200.0)) - .padding(5) - .style(style) - .on_press(Message::Ignore) - .into() -} - -pub struct HardwareWallets {} - -impl Section for HardwareWallets { - fn title(&self) -> &'static str { - "Hardware wallets" - } - - fn view(&self) -> Element { - column![ - h1(self.title()), - column![ - button( - hw::supported_hardware_wallet( - "ledger", - Some("v2.1.0"), - "f123de", - None:: - ) - .width(Length::Fixed(500.0)) - ) - .on_press(Message::Ignore) - .style(theme::Button::Border), - button( - hw::supported_hardware_wallet( - "ledger", - Some("v2.1.0"), - "f123de", - Some("Edouard key") - ) - .width(Length::Fixed(500.0)) - ) - .on_press(Message::Ignore) - .style(theme::Button::Border), - button( - hw::unregistered_hardware_wallet( - "ledger", - Some("v2.1.0"), - "f123de", - Some("Edouard key") - ) - .width(Length::Fixed(500.0)) - ) - .on_press(Message::Ignore) - .style(theme::Button::Border), - button( - hw::unsupported_hardware_wallet("ledger", Some("v2.1.0")) - .width(Length::Fixed(500.0)) - ) - .on_press(Message::Ignore) - .style(theme::Button::Border), - button( - hw::processing_hardware_wallet( - "ledger", - Some("v2.1.0"), - "f123de", - Some("Edouard key") - ) - .width(Length::Fixed(500.0)) - ) - .on_press(Message::Ignore) - .style(theme::Button::Border), - button( - hw::sign_success_hardware_wallet( - "ledger", - Some("v2.1.0"), - "f123de", - Some("Edouard key") - ) - .width(Length::Fixed(500.0)) - ) - .on_press(Message::Ignore) - .style(theme::Button::Border), - button( - hw::registration_success_hardware_wallet( - "ledger", - Some("v2.1.0"), - "f123de", - Some("Edouard key") - ) - .width(Length::Fixed(500.0)) - ) - .on_press(Message::Ignore) - .style(theme::Button::Border), - ] - .spacing(20) - ] - .spacing(100) - .into() - } -} - -pub struct Events {} - -impl Section for Events { - fn title(&self) -> &'static str { - "Events " - } - fn view(&self) -> Element { - let d = chrono::NaiveDate::from_ymd_opt(2015, 6, 3).unwrap(); - let t = chrono::NaiveTime::from_hms_milli_opt(12, 34, 56, 789).unwrap(); - column![ - h1(self.title()), - column![ - event::unconfirmed_outgoing_event(&Amount::from_sat(32934234), Message::Ignore), - event::confirmed_outgoing_event( - chrono::NaiveDateTime::new(d, t), - &Amount::from_sat(32934234), - Message::Ignore - ), - event::unconfirmed_incoming_event(&Amount::from_sat(32934234), Message::Ignore), - event::confirmed_incoming_event( - chrono::NaiveDateTime::new(d, t), - &Amount::from_sat(32934234), - Message::Ignore - ) - ] - .spacing(20) - ] - .spacing(100) - .into() - } -}