Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Empty state): promote composition #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum Component {
DescriptionList,
Divider,
Dropdown,
#[target(rename = "empty")]
#[target(rename = "empty_state")]
EmptyState,
ExpandableSection,
FileUpload,
Expand Down
28 changes: 0 additions & 28 deletions src/components/empty/mod.rs

This file was deleted.

27 changes: 27 additions & 0 deletions src/components/empty_state/empty_state.1.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
html!{
<EmptyState>
<EmptyStateHeader
title_text={html!("Empty state")}
heading_level={EmptyStateHeadingLevel::H4}
icon={html!(
<EmptyStateIcon icon={html!(<>{Icon::Cubes}</>)} />
)}
/>
<EmptyStateBody>
{"This represents the empty state pattern in PatternFly. Hopefully it's simple enough to use but flexible enough to meet a variety of needs."}
</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant={ButtonVariant::Primary}>{"Primary action"}</Button>
</EmptyStateActions>
<EmptyStateActions>
<Button variant={ButtonVariant::Link}>{"Multiple"}</Button>
<Button variant={ButtonVariant::Link}>{"Action Buttons"}</Button>
<Button variant={ButtonVariant::Link}>{"Can"}</Button>
<Button variant={ButtonVariant::Link}>{"Go here"}</Button>
<Button variant={ButtonVariant::Link}>{"In the secondary"}</Button>
<Button variant={ButtonVariant::Link}>{"Action area"}</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
}
21 changes: 21 additions & 0 deletions src/components/empty_state/empty_state.2.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
html!{
<EmptyState variant={EmptyStateVariant::XS}>
<EmptyStateHeader
title_text={html!("Empty state")}
heading_level={EmptyStateHeadingLevel::H4}
/>
<EmptyStateBody>
{"This represents the empty state pattern in PatternFly. Hopefully it's simple enough to use but flexible enough to meet a variety of needs."}
</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant={ButtonVariant::Link}>{"Multiple"}</Button>
<Button variant={ButtonVariant::Link}>{"Action Buttons"}</Button>
<Button variant={ButtonVariant::Link}>{"Can"}</Button>
<Button variant={ButtonVariant::Link}>{"Go here"}</Button>
<Button variant={ButtonVariant::Link}>{"In the secondary"}</Button>
<Button variant={ButtonVariant::Link}>{"Action area"}</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
}
27 changes: 27 additions & 0 deletions src/components/empty_state/empty_state.3.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
html!{
<EmptyState variant={EmptyStateVariant::SM}>
<EmptyStateHeader
title_text={html!("Empty state")}
heading_level={EmptyStateHeadingLevel::H4}
icon={html!(
<EmptyStateIcon icon={html!(<>{Icon::Cubes}</>)} />
)}
/>
<EmptyStateBody>
{"This represents the empty state pattern in PatternFly. Hopefully it's simple enough to use but flexible enough to meet a variety of needs."}
</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant={ButtonVariant::Primary}>{"Primary action"}</Button>
</EmptyStateActions>
<EmptyStateActions>
<Button variant={ButtonVariant::Link}>{"Multiple"}</Button>
<Button variant={ButtonVariant::Link}>{"Action Buttons"}</Button>
<Button variant={ButtonVariant::Link}>{"Can"}</Button>
<Button variant={ButtonVariant::Link}>{"Go here"}</Button>
<Button variant={ButtonVariant::Link}>{"In the secondary"}</Button>
<Button variant={ButtonVariant::Link}>{"Action area"}</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
}
27 changes: 27 additions & 0 deletions src/components/empty_state/empty_state.4.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
html!{
<EmptyState variant={EmptyStateVariant::LG}>
<EmptyStateHeader
title_text={html!("Empty state")}
heading_level={EmptyStateHeadingLevel::H4}
icon={html!(
<EmptyStateIcon icon={html!(<>{Icon::Cubes}</>)} />
)}
/>
<EmptyStateBody>
{"This represents the empty state pattern in PatternFly. Hopefully it's simple enough to use but flexible enough to meet a variety of needs."}
</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant={ButtonVariant::Primary}>{"Primary action"}</Button>
</EmptyStateActions>
<EmptyStateActions>
<Button variant={ButtonVariant::Link}>{"Multiple"}</Button>
<Button variant={ButtonVariant::Link}>{"Action Buttons"}</Button>
<Button variant={ButtonVariant::Link}>{"Can"}</Button>
<Button variant={ButtonVariant::Link}>{"Go here"}</Button>
<Button variant={ButtonVariant::Link}>{"In the secondary"}</Button>
<Button variant={ButtonVariant::Link}>{"Action area"}</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
}
27 changes: 27 additions & 0 deletions src/components/empty_state/empty_state.5.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
html!{
<EmptyState variant={EmptyStateVariant::XL}>
<EmptyStateHeader
title_text={html!("Empty state")}
heading_level={EmptyStateHeadingLevel::H4}
icon={html!(
<EmptyStateIcon icon={html!(<>{Icon::Cubes}</>)} />
)}
/>
<EmptyStateBody>
{"This represents the empty state pattern in PatternFly. Hopefully it's simple enough to use but flexible enough to meet a variety of needs."}
</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant={ButtonVariant::Primary}>{"Primary action"}</Button>
</EmptyStateActions>
<EmptyStateActions>
<Button variant={ButtonVariant::Link}>{"Multiple"}</Button>
<Button variant={ButtonVariant::Link}>{"Action Buttons"}</Button>
<Button variant={ButtonVariant::Link}>{"Can"}</Button>
<Button variant={ButtonVariant::Link}>{"Go here"}</Button>
<Button variant={ButtonVariant::Link}>{"In the secondary"}</Button>
<Button variant={ButtonVariant::Link}>{"Action area"}</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
}
11 changes: 11 additions & 0 deletions src/components/empty_state/empty_state.6.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
html!{
<EmptyState>
<EmptyStateHeader
title_text={html!("Loading")}
heading_level={EmptyStateHeadingLevel::H4}
icon={html!(
<EmptyStateIcon icon={html!(<Spinner/>)} />
)}
/>
</EmptyState>
}
19 changes: 19 additions & 0 deletions src/components/empty_state/empty_state.7.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
html!{
<EmptyState>
<EmptyStateHeader
title_text={html!("No results found")}
heading_level={EmptyStateHeadingLevel::H4}
icon={html!(
<EmptyStateIcon icon={html!(<>{Icon::Search}</>)} />
)}
/>
<EmptyStateBody>
{"No results match the filter criteria. Clear all filters and try again."}
</EmptyStateBody>
<EmptyStateFooter>
<EmptyStateActions>
<Button variant={ButtonVariant::Link}>{"Clear all filters"}</Button>
</EmptyStateActions>
</EmptyStateFooter>
</EmptyState>
}
14 changes: 14 additions & 0 deletions src/components/empty_state/empty_state.8.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
html!{
<EmptyState>
<EmptyStateHeader
title_text={html!("Custom icon color")}
heading_level={EmptyStateHeadingLevel::H4}
icon={html!(
<EmptyStateIcon icon={html!(<>{Icon::Check}</>)} color="var(--pf-v5-global--success-color--100)" />
)}
/>
<EmptyStateBody>
{"This represents the empty state pattern in PatternFly with a custom icon color. Hopefully it's simple enough to use but flexible enough to meet a variety of needs."}
</EmptyStateBody>
</EmptyState>
}
46 changes: 46 additions & 0 deletions src/components/empty_state/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use crate::{example, example::ExamplePage};
use patternfly_yew::prelude::*;
use yew::prelude::*;

pub struct EmptyStateExample {}

impl Component for EmptyStateExample {
type Message = ();
type Properties = ();

fn create(_: &Context<Self>) -> Self {
Self {}
}

fn view(&self, ctx: &Context<Self>) -> Html {
let example_a = example! ("Simple Empty State" => "simple_empty_state.1.example");
let example_b = example! ("Simple Empty state (XLarge)" => "simple_empty_state.2.example");

let example1 = example! ("Basic" => "empty_state.1.example");
let example2 = example! ("Extra small" => "empty_state.2.example");
let example3 = example! ("Small" => "empty_state.3.example");
let example4 = example! ("Large" => "empty_state.4.example");
let example5 = example! ("Extra large" => "empty_state.5.example");
let example6 = example! ("Spinner" => "empty_state.6.example");
let example7 = example! ("No match found" => "empty_state.7.example");
let example8 = example! ("Custom icon color" => "empty_state.8.example");

html! {
<>
<ExamplePage title="Empty state">
{example_a}
{example_b}

{example1}
{example2}
{example3}
{example4}
{example5}
{example6}
{example7}
{example8}
</ExamplePage>
</>
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
html!{
<EmptyState
<SimpleEmptyState
title="Empty state"
icon={Icon::Cubes}
primary={Action::new("Push me", ctx.link().callback(|_|{}))}
Expand All @@ -10,5 +10,5 @@ html!{
]}
>
{"This section should explain why the state is empty, and what you can do next."}
</EmptyState>
</SimpleEmptyState>
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
html!{
<EmptyState
<SimpleEmptyState
title="Empty state"
icon={Icon::Cubes}
size={Size::XLarge}
Expand All @@ -11,5 +11,5 @@ html!{
]}
>
{"This section should explain why the state is empty, and what you can do next."}
</EmptyState>
</SimpleEmptyState>
}
4 changes: 2 additions & 2 deletions src/components/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod context_selector;
mod description_list;
mod divider;
mod dropdown;
mod empty;
mod empty_state;
mod expandable_section;
mod file_upload;
mod form;
Expand Down Expand Up @@ -56,7 +56,7 @@ pub use context_selector::*;
pub use description_list::*;
pub use divider::*;
pub use dropdown::*;
pub use empty::*;
pub use empty_state::*;
pub use expandable_section::*;
pub use file_upload::*;
pub use form::*;
Expand Down