gui: design system example
This commit is contained in:
parent
e1926c40a4
commit
f3bf6fa589
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,3 +8,6 @@ venv/
|
||||
pytest.log
|
||||
TODO
|
||||
**/target
|
||||
**/dist
|
||||
gui/ui/Cargo.lock
|
||||
gui/ui/examples/design-system/Cargo.lock
|
||||
|
||||
16
gui/ui/Cargo.toml
Normal file
16
gui/ui/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "liana_ui"
|
||||
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.7"
|
||||
iced_native = "0.8"
|
||||
iced_lazy = { version = "0.4"}
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"examples/*"
|
||||
]
|
||||
6
gui/ui/README.md
Normal file
6
gui/ui/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# `liana_ui`
|
||||
|
||||
UI components used across the liana GUI iced application.
|
||||
|
||||
An wasm compatible example of the design system can be found in
|
||||
`./examples/design-system`
|
||||
12
gui/ui/examples/design-system/Cargo.toml
Normal file
12
gui/ui/examples/design-system/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[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.7"
|
||||
iced_native = "0.8"
|
||||
web-sys = "0.3.61"
|
||||
liana_ui = { path = "../.." }
|
||||
7
gui/ui/examples/design-system/README.md
Normal file
7
gui/ui/examples/design-system/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
## Use WASM
|
||||
|
||||
`trunk serve`
|
||||
|
||||
to build for a directory on a distant server
|
||||
|
||||
`trunk build --public-url /design-system`
|
||||
18
gui/ui/examples/design-system/index.html
Normal file
18
gui/ui/examples/design-system/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Liana design system</title>
|
||||
<base data-trunk-public-url />
|
||||
<style>
|
||||
body {
|
||||
margin:0px;
|
||||
overflow:hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="z" data-bin="design-system" />
|
||||
</body>
|
||||
</html>
|
||||
172
gui/ui/examples/design-system/src/main.rs
Normal file
172
gui/ui/examples/design-system/src/main.rs
Normal file
@ -0,0 +1,172 @@
|
||||
mod section;
|
||||
|
||||
use iced::widget::{button, column, container, radio, row, text, Column, Space};
|
||||
use iced::{executor, Application, Command, Length, Settings, Subscription};
|
||||
use liana_ui::{theme, widget::Element};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
DesignSystem::run(Settings::with_flags(Config {}))
|
||||
}
|
||||
|
||||
struct Config {}
|
||||
|
||||
#[derive(Default)]
|
||||
struct DesignSystem {
|
||||
theme: theme::Theme,
|
||||
sections: Vec<Box<dyn Section>>,
|
||||
current: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum ThemeType {
|
||||
Light,
|
||||
Dark,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Message {
|
||||
ThemeChanged(ThemeType),
|
||||
Event(iced_native::Event),
|
||||
Section(usize),
|
||||
Ignore,
|
||||
}
|
||||
|
||||
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<Self::Message>) {
|
||||
let app = Self {
|
||||
theme: theme::Theme::Light,
|
||||
sections: vec![
|
||||
Box::new(section::Overview {}),
|
||||
Box::new(section::Colors {}),
|
||||
Box::new(section::Buttons {}),
|
||||
],
|
||||
current: 0,
|
||||
};
|
||||
#[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,
|
||||
);
|
||||
(
|
||||
app,
|
||||
Command::single(command::Action::Window(window::Action::Resize {
|
||||
width,
|
||||
height,
|
||||
})),
|
||||
)
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
(app, Command::none())
|
||||
}
|
||||
|
||||
fn update(&mut self, message: Message) -> Command<Self::Message> {
|
||||
match message {
|
||||
Message::ThemeChanged(theme) => {
|
||||
self.theme = match theme {
|
||||
ThemeType::Light => theme::Theme::Light,
|
||||
ThemeType::Dark => theme::Theme::Dark,
|
||||
}
|
||||
}
|
||||
Message::Section(i) => {
|
||||
if self.sections.get(i).is_some() {
|
||||
self.current = i;
|
||||
}
|
||||
}
|
||||
Message::Event(iced::Event::Window(iced_native::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<Self::Message> {
|
||||
iced_native::subscription::events().map(Self::Message::Event)
|
||||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
let sidebar = container(
|
||||
column![
|
||||
[ThemeType::Light, ThemeType::Dark].iter().fold(
|
||||
column![text("Choose a theme:")].spacing(10),
|
||||
|column, theme| {
|
||||
column.push(radio(
|
||||
format!("{theme:?}"),
|
||||
*theme,
|
||||
Some(match self.theme {
|
||||
theme::Theme::Light => ThemeType::Light,
|
||||
theme::Theme::Dark => ThemeType::Dark,
|
||||
}),
|
||||
Message::ThemeChanged,
|
||||
))
|
||||
},
|
||||
),
|
||||
Space::with_height(Length::Units(100)),
|
||||
self.sections.iter().enumerate().fold(
|
||||
Column::new().spacing(10),
|
||||
|col, (i, section)| col.push(
|
||||
button(
|
||||
container(text(section.title()))
|
||||
.width(Length::Fill)
|
||||
.padding(5)
|
||||
)
|
||||
.style(if i == self.current {
|
||||
theme::Button::Primary
|
||||
} else {
|
||||
theme::Button::Transparent
|
||||
})
|
||||
.on_press(Message::Section(i))
|
||||
.width(Length::Units(200))
|
||||
)
|
||||
)
|
||||
]
|
||||
.spacing(20),
|
||||
)
|
||||
.padding(20)
|
||||
.style(theme::Container::Foreground)
|
||||
.height(Length::Fill);
|
||||
|
||||
container(row![
|
||||
sidebar.width(Length::Units(200)),
|
||||
Space::with_width(Length::Units(150)),
|
||||
column![
|
||||
Space::with_height(Length::Units(150)),
|
||||
container(self.sections[self.current].view()).width(Length::Fill)
|
||||
]
|
||||
])
|
||||
.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<Message>;
|
||||
}
|
||||
104
gui/ui/examples/design-system/src/section.rs
Normal file
104
gui/ui/examples/design-system/src/section.rs
Normal file
@ -0,0 +1,104 @@
|
||||
use iced::{
|
||||
alignment,
|
||||
widget::{button, column, container, row, Space},
|
||||
Alignment, Length,
|
||||
};
|
||||
use liana_ui::{color, 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<Message> {
|
||||
column![
|
||||
text("Hello").bold().size(50),
|
||||
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<Message> {
|
||||
column![
|
||||
text(self.title()).bold().size(50),
|
||||
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::DARK_GREY, "DARK_GREY #555555"),
|
||||
color_row(color::GREY, "GREY #CCCCCC original design"),
|
||||
color_row(color::LIGHT_GREY, "LIGHT_GREY #E6E6E6 original design"),
|
||||
color_row(color::RED, "RED #F04359"),
|
||||
color_row(color::ORANGE, "ORANGE #FFa700")
|
||||
]
|
||||
.spacing(10)
|
||||
]
|
||||
.spacing(100)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
fn color_row<'a, T: 'a>(color: iced::Color, label: &'static str) -> Element<'a, T> {
|
||||
row![
|
||||
container(Space::with_width(Length::Units(100)))
|
||||
.height(Length::Units(100))
|
||||
.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<Message> {
|
||||
column![
|
||||
text(self.title()).bold().size(50),
|
||||
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")
|
||||
]
|
||||
.spacing(20)
|
||||
]
|
||||
.spacing(100)
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
fn button_row(style: theme::Button, label: &'static str) -> Element<Message> {
|
||||
button(
|
||||
container(text(label))
|
||||
.width(Length::Fill)
|
||||
.align_x(alignment::Horizontal::Center),
|
||||
)
|
||||
.width(Length::Units(200))
|
||||
.padding(5)
|
||||
.style(style)
|
||||
.on_press(Message::Ignore)
|
||||
.into()
|
||||
}
|
||||
42
gui/ui/src/color.rs
Normal file
42
gui/ui/src/color.rs
Normal file
@ -0,0 +1,42 @@
|
||||
use iced::Color;
|
||||
|
||||
pub const BLACK: Color = iced::Color::BLACK;
|
||||
|
||||
pub const LIGHT_BLACK: Color = Color::from_rgb(
|
||||
0x14 as f32 / 255.0,
|
||||
0x14 as f32 / 255.0,
|
||||
0x14 as f32 / 255.0,
|
||||
);
|
||||
|
||||
pub const GREEN: Color = Color::from_rgb(
|
||||
0x00 as f32 / 255.0,
|
||||
0xFF as f32 / 255.0,
|
||||
0x66 as f32 / 255.0,
|
||||
);
|
||||
|
||||
pub const DARK_GREY: Color = Color::from_rgb(
|
||||
0x55 as f32 / 255.0,
|
||||
0x55 as f32 / 255.0,
|
||||
0x55 as f32 / 255.0,
|
||||
);
|
||||
|
||||
pub const GREY: Color = Color::from_rgb(
|
||||
0xCC as f32 / 255.0,
|
||||
0xCC as f32 / 255.0,
|
||||
0xCC as f32 / 255.0,
|
||||
);
|
||||
|
||||
pub const LIGHT_GREY: Color = Color::from_rgb(
|
||||
0xE6 as f32 / 255.0,
|
||||
0xE6 as f32 / 255.0,
|
||||
0xE6 as f32 / 255.0,
|
||||
);
|
||||
|
||||
pub const RED: Color = Color::from_rgb(
|
||||
0xF0 as f32 / 255.0,
|
||||
0x43 as f32 / 255.0,
|
||||
0x59 as f32 / 255.0,
|
||||
);
|
||||
|
||||
pub const ORANGE: Color =
|
||||
Color::from_rgb(0xFF as f32 / 255.0, 0xa7 as f32 / 255.0, 0x0 as f32 / 255.0);
|
||||
11
gui/ui/src/font.rs
Normal file
11
gui/ui/src/font.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use iced::Font;
|
||||
|
||||
pub const BOLD: Font = Font::External {
|
||||
name: "Bold",
|
||||
bytes: include_bytes!("../../static/fonts/OpenSans-Bold.ttf"),
|
||||
};
|
||||
|
||||
pub const REGULAR: Font = Font::External {
|
||||
name: "Regular",
|
||||
bytes: include_bytes!("../../static/fonts/OpenSans-Regular.ttf"),
|
||||
};
|
||||
14
gui/ui/src/lib.rs
Normal file
14
gui/ui/src/lib.rs
Normal file
@ -0,0 +1,14 @@
|
||||
pub mod color;
|
||||
pub mod font;
|
||||
pub mod text;
|
||||
pub mod theme;
|
||||
|
||||
pub mod widget {
|
||||
#![allow(dead_code)]
|
||||
use crate::theme::Theme;
|
||||
|
||||
pub type Renderer = iced::Renderer<Theme>;
|
||||
pub type Element<'a, Message> = iced::Element<'a, Message, Renderer>;
|
||||
pub type Container<'a, Message> = iced::widget::Container<'a, Message, Renderer>;
|
||||
pub type Button<'a, Message> = iced::widget::Button<'a, Message, Renderer>;
|
||||
}
|
||||
24
gui/ui/src/text.rs
Normal file
24
gui/ui/src/text.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use crate::{font, theme::Theme};
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub const TEXT_REGULAR_SIZE: u16 = 25;
|
||||
|
||||
pub fn text<'a>(content: impl Into<Cow<'a, str>>) -> iced::widget::Text<'a, iced::Renderer<Theme>> {
|
||||
iced::widget::Text::new(content)
|
||||
.font(font::REGULAR)
|
||||
.size(TEXT_REGULAR_SIZE)
|
||||
}
|
||||
|
||||
pub trait Text {
|
||||
fn bold(self) -> Self;
|
||||
fn small(self) -> Self;
|
||||
}
|
||||
|
||||
impl Text for iced::widget::Text<'_, iced::Renderer<Theme>> {
|
||||
fn bold(self) -> Self {
|
||||
self.font(font::BOLD)
|
||||
}
|
||||
fn small(self) -> Self {
|
||||
self.size(20)
|
||||
}
|
||||
}
|
||||
304
gui/ui/src/theme.rs
Normal file
304
gui/ui/src/theme.rs
Normal file
@ -0,0 +1,304 @@
|
||||
use iced::{
|
||||
application,
|
||||
widget::{button, container, radio, text},
|
||||
};
|
||||
|
||||
use super::color;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
|
||||
pub enum Theme {
|
||||
#[default]
|
||||
Dark,
|
||||
Light,
|
||||
}
|
||||
|
||||
impl application::StyleSheet for Theme {
|
||||
type Style = ();
|
||||
|
||||
fn appearance(&self, _style: &Self::Style) -> application::Appearance {
|
||||
match self {
|
||||
Theme::Light => application::Appearance {
|
||||
background_color: color::LIGHT_GREY,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
Theme::Dark => application::Appearance {
|
||||
background_color: color::LIGHT_BLACK,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub enum Text {
|
||||
#[default]
|
||||
Default,
|
||||
Color(iced::Color),
|
||||
}
|
||||
|
||||
impl From<iced::Color> for Text {
|
||||
fn from(color: iced::Color) -> Self {
|
||||
Text::Color(color)
|
||||
}
|
||||
}
|
||||
|
||||
impl text::StyleSheet for Theme {
|
||||
type Style = Text;
|
||||
|
||||
fn appearance(&self, style: Self::Style) -> text::Appearance {
|
||||
match style {
|
||||
Text::Default => Default::default(),
|
||||
Text::Color(c) => text::Appearance { color: Some(c) },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Default)]
|
||||
pub enum Container {
|
||||
#[default]
|
||||
Transparent,
|
||||
Background,
|
||||
Foreground,
|
||||
Border,
|
||||
Custom(iced::Color),
|
||||
}
|
||||
|
||||
impl container::StyleSheet for Theme {
|
||||
type Style = Container;
|
||||
fn appearance(&self, style: &Self::Style) -> iced::widget::container::Appearance {
|
||||
match self {
|
||||
Theme::Light => match style {
|
||||
Container::Transparent => container::Appearance {
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Background => container::Appearance {
|
||||
background: color::LIGHT_GREY.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Foreground => container::Appearance {
|
||||
background: color::GREY.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Border => container::Appearance {
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
border_width: 1.0,
|
||||
border_color: color::LIGHT_BLACK.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Custom(c) => container::Appearance {
|
||||
background: (*c).into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
},
|
||||
Theme::Dark => match style {
|
||||
Container::Transparent => container::Appearance {
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Background => container::Appearance {
|
||||
background: color::LIGHT_BLACK.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Foreground => container::Appearance {
|
||||
background: color::BLACK.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Border => container::Appearance {
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
border_width: 1.0,
|
||||
border_color: color::LIGHT_GREY.into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
Container::Custom(c) => container::Appearance {
|
||||
background: (*c).into(),
|
||||
..container::Appearance::default()
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Radio {}
|
||||
impl radio::StyleSheet for Theme {
|
||||
type Style = Radio;
|
||||
|
||||
fn active(&self, _style: &Self::Style, _is_selected: bool) -> radio::Appearance {
|
||||
radio::Appearance {
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
dot_color: color::GREEN,
|
||||
border_width: 1.0,
|
||||
border_color: color::GREEN,
|
||||
text_color: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, style: &Self::Style, is_selected: bool) -> radio::Appearance {
|
||||
let active = self.active(style, is_selected);
|
||||
radio::Appearance {
|
||||
dot_color: color::GREEN,
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
..active
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub enum Button {
|
||||
#[default]
|
||||
Primary,
|
||||
Secondary,
|
||||
Destructive,
|
||||
Transparent,
|
||||
}
|
||||
|
||||
impl button::StyleSheet for Theme {
|
||||
type Style = Button;
|
||||
|
||||
fn active(&self, style: &Self::Style) -> button::Appearance {
|
||||
match self {
|
||||
Theme::Light => match style {
|
||||
Button::Primary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::LIGHT_BLACK.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
Button::Secondary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 1.0,
|
||||
border_color: color::DARK_GREY,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
Button::Destructive => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::RED.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
Button::Transparent => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
},
|
||||
Theme::Dark => match style {
|
||||
Button::Primary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::GREY.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
Button::Secondary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::LIGHT_BLACK.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 1.0,
|
||||
border_color: color::LIGHT_GREY,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
Button::Destructive => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::RED.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
Button::Transparent => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: iced::Color::TRANSPARENT.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn hovered(&self, style: &Self::Style) -> button::Appearance {
|
||||
match self {
|
||||
Theme::Light => match style {
|
||||
Button::Primary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::LIGHT_BLACK.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
Button::Secondary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::LIGHT_BLACK.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
Button::Destructive => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::RED.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
Button::Transparent => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::DARK_GREY.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
},
|
||||
Theme::Dark => match style {
|
||||
Button::Primary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::GREY.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
Button::Secondary => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::GREY.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
Button::Destructive => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::RED.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_BLACK,
|
||||
},
|
||||
Button::Transparent => button::Appearance {
|
||||
shadow_offset: iced::Vector::default(),
|
||||
background: color::DARK_GREY.into(),
|
||||
border_radius: 10.0,
|
||||
border_width: 0.0,
|
||||
border_color: iced::Color::TRANSPARENT,
|
||||
text_color: color::LIGHT_GREY,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
202
gui/ui/static/fonts/LICENSE.txt
Normal file
202
gui/ui/static/fonts/LICENSE.txt
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
BIN
gui/ui/static/fonts/OpenSans-Bold.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-Bold.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-BoldItalic.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-ExtraBold.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-ExtraBold.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-ExtraBoldItalic.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-ExtraBoldItalic.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-Italic.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-Italic.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-Light.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-Light.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-LightItalic.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-LightItalic.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-Regular.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-Regular.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-SemiBold.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-SemiBold.ttf
Normal file
Binary file not shown.
BIN
gui/ui/static/fonts/OpenSans-SemiBoldItalic.ttf
Normal file
BIN
gui/ui/static/fonts/OpenSans-SemiBoldItalic.ttf
Normal file
Binary file not shown.
21
gui/ui/static/icons/LICENSE.md
Normal file
21
gui/ui/static/icons/LICENSE.md
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019-2020 The Bootstrap Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
6
gui/ui/static/icons/README.md
Normal file
6
gui/ui/static/icons/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Icons
|
||||
|
||||
From the getbootstrap.com repository.
|
||||
Converted from .woff to ttf with https://raw.githubusercontent.com/hanikesn/woff2otf/master/woff2otf.py
|
||||
|
||||
Use http://mathew-kurian.github.io/CharacterMap/ to check Unicode.
|
||||
BIN
gui/ui/static/icons/bootstrap-icons.ttf
Normal file
BIN
gui/ui/static/icons/bootstrap-icons.ttf
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user