Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 80 additions & 71 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ features = [
]

[patch.crates-io]
patternfly-yew = { git = "https://github.com/patternfly-yew/patternfly-yew", rev = "40d93dd0" } # Banner support, awaiting release
#patternfly-yew = { git = "https://github.com/patternfly-yew/patternfly-yew", rev = "40d93dd0" } # Banner support, awaiting release
#patternfly-yew = { path = "../patternfly-yew" }
#patternfly-yew = { git = "https://github.com/patternfly-yew/patternfly-yew", rev = "9d1715d57e6ae801dec48fcfd89c4e6bd5a89366" } # FIXME: awaiting release
#yew-nested-router = { path = "../yew-nested-router" }
Expand Down
15 changes: 15 additions & 0 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub enum Component {
FileUpload,
Form(Form),
HelperText,
Hero,
Hint,
Label,
List,
Expand All @@ -58,6 +59,7 @@ pub enum Component {
Table,
Text,
TextInputGroup,
Timestamp,
Title,
Toast,
ToggleGroup,
Expand Down Expand Up @@ -97,6 +99,7 @@ pub enum Layout {
Flex,
Gallery,
Grid,
Level,
Split,
Stack,
}
Expand Down Expand Up @@ -162,6 +165,7 @@ fn switch_app_route(target: AppRoute) -> Html {
Component::Form(Form::Checkbox) => html! { <components::FormCheckboxExample /> },
Component::Form(Form::Radio) => html! { <components::FormRadioExample /> },
Component::HelperText => html! { <components::HelperTextExample /> },
Component::Hero => html! { <components::HeroExample /> },
Component::Hint => html! { <components::HintExample /> },
Component::Label => html! { <components::LabelExample /> },
Component::List => html! { <components::ListExample /> },
Expand All @@ -183,6 +187,7 @@ fn switch_app_route(target: AppRoute) -> Html {
Component::Tabs(current) => html! { <components::TabsExample current={current} /> },
Component::Text => html! { <components::TextExample /> },
Component::TextInputGroup => html! { <components::TextInputGroupExample /> },
Component::Timestamp => html! { <components::TimestampExample /> },
Component::Title => html! { <components::TitleExample /> },
Component::Toast => html! { <components::ToastExample /> },
Component::ToggleGroup => html! { <components::ToggleGroupExample /> },
Expand All @@ -196,6 +201,7 @@ fn switch_app_route(target: AppRoute) -> Html {
Layout::Flex => html! { <layouts::FlexExample /> },
Layout::Gallery => html! { <layouts::GalleryExample /> },
Layout::Grid => html! { <layouts::GridExample /> },
Layout::Level => html! { <layouts::LevelExample /> },
Layout::Split => html! { <layouts::SplitExample /> },
Layout::Stack => html! { <layouts::StackExample /> },
};
Expand Down Expand Up @@ -401,6 +407,9 @@ fn page(props: &PageProps) -> Html {
<NavRouterItem<AppRoute> to={AppRoute::Component(Component::HelperText)}>
{ "HelperText" }
</NavRouterItem<AppRoute>>
<NavRouterItem<AppRoute> to={AppRoute::Component(Component::Hero)}>
{ "Hero" }
</NavRouterItem<AppRoute>>
<NavRouterItem<AppRoute> to={AppRoute::Component(Component::Hint)}>
{ "Hint" }
</NavRouterItem<AppRoute>>
Expand Down Expand Up @@ -477,6 +486,9 @@ fn page(props: &PageProps) -> Html {
>
{ "Text Input Group" }
</NavRouterItem<AppRoute>>
<NavRouterItem<AppRoute> to={AppRoute::Component(Component::Timestamp)}>
{ "Timestamp" }
</NavRouterItem<AppRoute>>
<NavRouterItem<AppRoute> to={AppRoute::Component(Component::Title)}>
{ "Title" }
</NavRouterItem<AppRoute>>
Expand Down Expand Up @@ -509,6 +521,9 @@ fn page(props: &PageProps) -> Html {
<NavRouterItem<AppRoute> to={AppRoute::Layout(Layout::Grid)}>
{ "Grid" }
</NavRouterItem<AppRoute>>
<NavRouterItem<AppRoute> to={AppRoute::Layout(Layout::Level)}>
{ "Level" }
</NavRouterItem<AppRoute>>
<NavRouterItem<AppRoute> to={AppRoute::Layout(Layout::Split)}>
{ "Split" }
</NavRouterItem<AppRoute>>
Expand Down
9 changes: 9 additions & 0 deletions src/components/avatar/avatar.4.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
html!(
<Flex>
{ for AvatarColor::ALL.into_iter().map(|color| html_nested!(
<FlexItem>
<Avatar alt={format!("{color:?} avatar")} {color} />
</FlexItem>
)) }
</Flex>
)
13 changes: 13 additions & 0 deletions src/components/avatar/avatar.5.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
html!(
<Flex>
<FlexItem>
<Avatar alt="Charlie" initials="C" />
</FlexItem>
<FlexItem>
<Avatar alt="Charlie" initials="C" color={AvatarColor::Blue} />
</FlexItem>
<FlexItem>
<Avatar alt="Charlie" initials="C" color={AvatarColor::Purple} size={AvatarSize::Large} />
</FlexItem>
</Flex>
)
10 changes: 9 additions & 1 deletion src/components/avatar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ pub fn avatar() -> Html {
let example1 = example! ("Basic" => "avatar.1.example");
let example2 = example! ("Size Variations" => "avatar.2.example");
let example3 = example! ("Border Styles" => "avatar.3.example");
let example4 = example! ("Color modifiers" => "avatar.4.example");
let example5 = example! ("With initials" => "avatar.5.example");

html! {
<>
<ExamplePage title="Avatar">{ example1 }{ example2 }{ example3 }</ExamplePage>
<ExamplePage title="Avatar">
{ example1 }
{ example4 }
{ example5 }
{ example2 }
{ example3 }
</ExamplePage>
</>
}
}
20 changes: 20 additions & 0 deletions src/components/hero/hero.1.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
html!(
<Hero>
<Content>
<h1>{ "Welcome to PatternFly" }</h1>
<p>
{ "Build consistent, accessible, and scalable user experiences. \
Get started with components, patterns, and guidelines." }
</p>
</Content>
<br />
<Flex>
<FlexItem>
<Button variant={ButtonVariant::Primary}>{ "Get started" }</Button>
</FlexItem>
<FlexItem>
<Button variant={ButtonVariant::Secondary}>{ "Learn more" }</Button>
</FlexItem>
</Flex>
</Hero>
)
11 changes: 11 additions & 0 deletions src/components/hero/hero.2.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html!(
<Hero
gradient_light={HeroGradient::new("#fde6e0", "#ece1ff", "#e0f0ff")}
gradient_dark={HeroGradient::new("#3d1a14", "#2a1a4a", "#0f2a40")}
>
<Content>
<h1>{ "A hero with a gradient" }</h1>
<p>{ "Light and dark themes use separate gradients. Each stop accepts any valid CSS color." }</p>
</Content>
</Hero>
)
11 changes: 11 additions & 0 deletions src/components/hero/hero.3.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html!(
<Hero
background_src_light="assets/images/pf-background.svg"
background_src_dark="assets/images/pf-background.svg"
>
<Content>
<h1>{ "A hero with a background image" }</h1>
<p>{ "Provide distinct light and dark theme assets, and keep enough contrast with the text." }</p>
</Content>
</Hero>
)
11 changes: 11 additions & 0 deletions src/components/hero/hero.4.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html!(
<Hero body_width="400px" body_max_width="50%">
<Content>
<h1>{ "Narrow body" }</h1>
<p>
{ "Use the body width and max-width to control where the text sits, \
for example when no background image is used." }
</p>
</Content>
</Hero>
)
15 changes: 15 additions & 0 deletions src/components/hero/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::{example, example::ExamplePage};
use patternfly_yew::prelude::*;
use yew::prelude::*;

#[function_component(HeroExample)]
pub fn hero_example() -> Html {
let example1 = example! ("Basic" => "hero.1.example");
let example2 = example! ("With gradient" => "hero.2.example");
let example3 = example! ("With background image" => "hero.3.example");
let example4 = example! ("Custom body width" => "hero.4.example");

html! {
<ExamplePage title="Hero">{ example1 }{ example2 }{ example3 }{ example4 }</ExamplePage>
}
}
4 changes: 4 additions & 0 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mod expandable_section;
mod file_upload;
mod form;
mod helper_text;
mod hero;
mod hint;
mod label;
mod list;
Expand All @@ -41,6 +42,7 @@ mod table;
mod tabs;
mod text;
mod text_input_group;
mod timestamp;
mod title;
mod toast;
mod toggle_group;
Expand Down Expand Up @@ -71,6 +73,7 @@ pub use expandable_section::*;
pub use file_upload::*;
pub use form::*;
pub use helper_text::*;
pub use hero::*;
pub use hint::*;
pub use label::*;
pub use list::*;
Expand All @@ -91,6 +94,7 @@ pub use table::*;
pub use tabs::*;
pub use text::*;
pub use text_input_group::*;
pub use timestamp::*;
pub use title::*;
pub use toast::*;
pub use toggle_group::*;
Expand Down
2 changes: 1 addition & 1 deletion src/components/table/table.11.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn example() -> Html {
entries_sorted.sort_by(|a, b| a.foo.cmp(&b.foo));
},
Columns::Second => {
entries_sorted.sort_by(|a, b| a.foo.len().cmp(&b.foo.len()));
entries_sorted.sort_by_key(|a| a.foo.len());
},
_ => {},
};
Expand Down
24 changes: 24 additions & 0 deletions src/components/timestamp/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use crate::{example, example::ExamplePage};
use patternfly_yew::prelude::*;
use yew::prelude::*;

#[function_component(TimestampExample)]
pub fn timestamp_example() -> Html {
let example1 = example! ("Default" => "timestamp.1.example");
let example2 = example! ("Basic formats" => "timestamp.2.example");
let example3 = example! ("Custom format" => "timestamp.3.example");
let example4 = example! ("Default tooltip" => "timestamp.4.example");
let example5 = example! ("Custom content" => "timestamp.5.example");
let example6 = example! ("Custom tooltip" => "timestamp.6.example");

html! {
<ExamplePage title="Timestamp">
{ example1 }
{ example2 }
{ example3 }
{ example4 }
{ example5 }
{ example6 }
</ExamplePage>
}
}
15 changes: 15 additions & 0 deletions src/components/timestamp/timestamp.1.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
let date = chrono::DateTime::parse_from_rfc3339("2022-08-09T14:57:00Z")
.unwrap()
.with_timezone(&chrono::Utc);

html!(
<>
<Timestamp />
<br />
<Timestamp display_utc=true />
<br />
<Timestamp {date} />
</>
)
}
22 changes: 22 additions & 0 deletions src/components/timestamp/timestamp.2.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
html!(
<>
<Timestamp date_format={TimestampFormat::Full} time_format={TimestampFormat::Full} />
<br />
<Timestamp date_format={TimestampFormat::Full} />
<br />
<Timestamp time_format={TimestampFormat::Short} />
<br />
<Timestamp
date_format={TimestampFormat::Medium}
time_format={TimestampFormat::Short}
display_suffix="US Eastern"
/>
<br />
<Timestamp
date_format={TimestampFormat::Medium}
time_format={TimestampFormat::Short}
is_12_hour=false
locale="en-GB"
/>
</>
)
11 changes: 11 additions & 0 deletions src/components/timestamp/timestamp.3.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html!(
<Timestamp
custom_format={vec![
("weekday".into(), "long".into()),
("month".into(), "long".into()),
("day".into(), "numeric".into()),
("hour".into(), "2-digit".into()),
("minute".into(), "2-digit".into()),
]}
/>
)
15 changes: 15 additions & 0 deletions src/components/timestamp/timestamp.4.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
html!(
<>
<Timestamp
date_format={TimestampFormat::Medium}
time_format={TimestampFormat::Short}
tooltip={TimestampTooltip::default_utc()}
/>
<br />
<Timestamp
date_format={TimestampFormat::Medium}
time_format={TimestampFormat::Short}
tooltip={TimestampTooltip::Default { suffix: Some("Coordinated Universal Time".into()) }}
/>
</>
)
14 changes: 14 additions & 0 deletions src/components/timestamp/timestamp.5.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
let date = chrono::Utc::now() - chrono::Duration::hours(1);

html!(
<Timestamp
{date}
date_format={TimestampFormat::Full}
time_format={TimestampFormat::Short}
tooltip={TimestampTooltip::default_utc()}
>
{ "1 hour ago" }
</Timestamp>
)
}
3 changes: 3 additions & 0 deletions src/components/timestamp/timestamp.6.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html!(
<Timestamp tooltip={TimestampTooltip::Custom(html!("Last updated 12 hours ago"))} />
)
2 changes: 1 addition & 1 deletion src/full/login_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn login_page_example() -> Html {
if let Some(toaster) = &toaster {
toaster.toast(format!(
"Login - Username: {}, Password: {}",
&*username, &*password
*username, *password
));
}
})
Expand Down
7 changes: 7 additions & 0 deletions src/layouts/level/level.1.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
html!{
<LayoutLevel>
<LevelItem><LayoutItem>{"Level Item"}</LayoutItem></LevelItem>
<LevelItem><LayoutItem>{"Level Item"}</LayoutItem></LevelItem>
<LevelItem><LayoutItem>{"Level Item"}</LayoutItem></LevelItem>
</LayoutLevel>
}
7 changes: 7 additions & 0 deletions src/layouts/level/level.2.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
html!{
<LayoutLevel gutter=true>
<LevelItem><LayoutItem>{"Level Item"}</LayoutItem></LevelItem>
<LevelItem><LayoutItem>{"Level Item"}</LayoutItem></LevelItem>
<LevelItem><LayoutItem>{"Level Item"}</LayoutItem></LevelItem>
</LayoutLevel>
}
10 changes: 10 additions & 0 deletions src/layouts/level/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use crate::{example, example::ExamplePage, layouts::LayoutItem};
use patternfly_yew::prelude::*;
use yew::prelude::*;

#[function_component(LevelExample)]
pub fn level_example() -> Html {
let example1 = example!("Level" => "level.1.example");
let example2 = example!("Level (gutter)" => "level.2.example");
html! { <ExamplePage title="Level Layout">{ example1 }{ example2 }</ExamplePage> }
}
Loading
Loading