Skip to content

Commit 792cdbd

Browse files
unhappychoiceclaude
andcommitted
feat(read_store): support PixelArt shape
Adds PixelArt to `READ_STORE_SHAPES`, `from_json`, `from_toml`, and `empty_body`, plus a structured-cases entry exercising both formats. Users can now drop a sprite at `$HOME/.splashboard/store/<id>.json` and point a `basic_read_store` widget at it with `shape = "pixel_art"` — the escape hatch the PixelArt shape needed to stand on its own without depending on a network fetcher. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 22251b1 commit 792cdbd

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

‎src/fetcher/read_store.rs‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use async_trait::async_trait;
44

55
use crate::payload::{
66
Bar, BarsData, Body, CalendarData, EntriesData, HeatmapData, ImageData, ImageLinkedListData,
7-
NumberSeriesData, Payload, PointSeriesData, RatioData, TextBlockData, TextData,
7+
NumberSeriesData, Payload, PixelArtData, PointSeriesData, RatioData, TextBlockData, TextData,
88
};
99
use crate::render::Shape;
1010

@@ -22,6 +22,7 @@ const READ_STORE_SHAPES: &[Shape] = &[
2222
Shape::PointSeries,
2323
Shape::Bars,
2424
Shape::Image,
25+
Shape::PixelArt,
2526
Shape::ImageLinkedList,
2627
Shape::Calendar,
2728
Shape::Heatmap,
@@ -178,6 +179,7 @@ fn from_json(text: &str, shape: Shape) -> Result<Body, FetchError> {
178179
Shape::PointSeries => parse_as!(PointSeriesData, PointSeries),
179180
Shape::Bars => parse_as!(BarsData, Bars),
180181
Shape::Image => parse_as!(ImageData, Image),
182+
Shape::PixelArt => parse_as!(PixelArtData, PixelArt),
181183
Shape::ImageLinkedList => parse_as!(ImageLinkedListData, ImageLinkedList),
182184
Shape::Calendar => parse_as!(CalendarData, Calendar),
183185
Shape::Heatmap => parse_as!(HeatmapData, Heatmap),
@@ -205,6 +207,7 @@ fn from_toml(text: &str, shape: Shape) -> Result<Body, FetchError> {
205207
Shape::PointSeries => parse_as!(PointSeriesData, PointSeries),
206208
Shape::Bars => parse_as!(BarsData, Bars),
207209
Shape::Image => parse_as!(ImageData, Image),
210+
Shape::PixelArt => parse_as!(PixelArtData, PixelArt),
208211
Shape::ImageLinkedList => parse_as!(ImageLinkedListData, ImageLinkedList),
209212
Shape::Calendar => parse_as!(CalendarData, Calendar),
210213
Shape::Heatmap => parse_as!(HeatmapData, Heatmap),
@@ -236,6 +239,10 @@ fn empty_body(shape: Shape) -> Body {
236239
Shape::Image => Body::Image(ImageData {
237240
path: String::new(),
238241
}),
242+
Shape::PixelArt => Body::PixelArt(PixelArtData {
243+
pixels: Vec::new(),
244+
label: None,
245+
}),
239246
Shape::ImageLinkedList => Body::ImageLinkedList(ImageLinkedListData { items: Vec::new() }),
240247
Shape::Calendar => Body::Calendar(CalendarData {
241248
year: 1970,
@@ -518,6 +525,18 @@ value = "main""#,
518525
path: "/tmp/pic.png".into(),
519526
}),
520527
),
528+
(
529+
Shape::PixelArt,
530+
r#"{"pixels":[[{"r":255,"g":0,"b":0,"a":255},{"r":0,"g":0,"b":0,"a":0}]],"label":"hi"}"#,
531+
"label = \"hi\"\npixels = [[{r=255,g=0,b=0,a=255},{r=0,g=0,b=0,a=0}]]",
532+
Body::PixelArt(PixelArtData {
533+
pixels: vec![vec![
534+
crate::payload::PixelColor::opaque(255, 0, 0),
535+
crate::payload::PixelColor::TRANSPARENT,
536+
]],
537+
label: Some("hi".into()),
538+
}),
539+
),
521540
(
522541
Shape::Calendar,
523542
r#"{"year":2026,"month":4,"day":30,"events":[1,15]}"#,
@@ -708,6 +727,13 @@ value = "main""#,
708727
path: String::new(),
709728
}),
710729
),
730+
(
731+
Shape::PixelArt,
732+
Body::PixelArt(PixelArtData {
733+
pixels: Vec::new(),
734+
label: None,
735+
}),
736+
),
711737
(
712738
Shape::Calendar,
713739
Body::Calendar(CalendarData {

0 commit comments

Comments
 (0)