Skip to content

Commit

Permalink
Fix list empty view image being too big
Browse files Browse the repository at this point in the history
  • Loading branch information
Exidex committed Jan 7, 2025
1 parent b2094be commit d9b60d5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
7 changes: 7 additions & 0 deletions dev_plugin/gauntlet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ path = 'src/empty.tsx'
type = 'view'
description = ''

[[entrypoint]]
id = 'empty-list-entrypoint'
name = 'Empty List Entrypoint'
path = 'src/empty-list.tsx'
type = 'view'
description = ''

[[entrypoint]]
id = 'entrypoint-generator'
name = 'Entrypoint generator'
Expand Down
12 changes: 12 additions & 0 deletions dev_plugin/src/empty-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ReactElement } from "react";
import { List } from "@project-gauntlet/api/components";

const alderaanImage = "https://static.wikia.nocookie.net/starwars/images/4/4a/Alderaan.jpg/revision/latest?cb=20061211013805"

export default function EmptyListView(): ReactElement {
return (
<List>
<List.EmptyView title="Nothing here" description="But there was something" image={{ url: alderaanImage }}/>
</List>
)
}
2 changes: 2 additions & 0 deletions rust/client/src/ui/theme/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ impl<'a, Message: 'a> ThemableWidget<'a, Message> for Container<'a, Message, Gau
}
ContainerStyle::EmptyViewImage => {
self.padding(theme.empty_view_image.padding.to_iced())
.max_width(theme.empty_view_image.size.width)
.max_height(theme.empty_view_image.size.height)
}
ContainerStyle::Main => {
self.class(ContainerStyleInner::Main)
Expand Down
9 changes: 1 addition & 8 deletions rust/client/src/ui/theme/image.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
use crate::ui::theme::{Element, ThemableWidget};
use iced::widget::Image;
use crate::ui::theme::{Element, get_theme, ThemableWidget};

pub enum ImageStyle {
EmptyViewImage,
MainListItemIcon,
}

impl<'a, Message: 'a> ThemableWidget<'a, Message> for Image<iced::advanced::image::Handle> {
type Kind = ImageStyle;

fn themed(self, kind: ImageStyle) -> Element<'a, Message> {
let theme = get_theme();

match kind {
ImageStyle::EmptyViewImage => {
self.width(theme.empty_view_image.size.width)
.height(theme.empty_view_image.size.height)
}
ImageStyle::MainListItemIcon => {
self.width(18)
.height(18)
Expand Down
4 changes: 2 additions & 2 deletions rust/client/src/ui/theme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ impl GauntletComplexTheme {
empty_view_image: ThemePaddingSize {
padding: padding_all(8.0),
size: ExternalThemeSize {
width: 100.0,
height: 100.0,
width: 150.0,
height: 150.0,
},
},
grid_item: ThemeButton {
Expand Down

0 comments on commit d9b60d5

Please sign in to comment.