Skip to content

Commit 3102fcd

Browse files
committed
feat: add style presets with selector, prompt support, and screenshots
1 parent f90b422 commit 3102fcd

16 files changed

Lines changed: 483 additions & 44 deletions

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 0.3.0
2+
3+
- Added style preset model with `JsonStyleDefinition` and `JsonCatalog.styles`
4+
- Added style-aware prompt generation via `JsonPromptOptions.selectedStyleId`
5+
- Added optional spec-level style (`JsonRenderSpec.style`) and style validation in `validateSpec`
6+
- Added runtime style override support in `JsonRenderer(styleId: ...)`
7+
- Extended render/action contexts with `styleId`
8+
- Improved `Row` overflow handling with `overflow: row|wrap|scroll` and `runSpacing`
9+
- Expanded showcase example with style preset selector (`clean`, `midnight`, `sunset`)
10+
- Added style screenshots and updated README/pub.dev documentation
11+
112
## 0.2.0
213

314
- Added JSON Patch support with `JsonPatchOperation`, `JsonPatchOp`, and `applyJsonPatch`

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ A Flutter-first implementation of the [vercel-labs/json-render](https://github.c
88
- Flat and model-friendly spec shape (`root + elements`)
99
- Dynamic prop resolution (`$state`, `$item`, `$index`, `$cond`)
1010
- Visibility and repeat support
11+
- Style presets and style-aware prompt generation
1112
- JSONL streaming patch compiler for progressive UI updates
1213

1314
## Install
@@ -22,6 +23,7 @@ flutter pub add flutter_json_render
2223
- `JsonRegistry`: maps component type -> Flutter widget builder, action -> handler
2324
- `JsonRenderer`: renders `JsonRenderSpec` safely
2425
- `JsonSpecStreamCompiler`: compiles streamed JSONL specs/patches
26+
- `JsonStyleDefinition`: defines selectable style presets for generation/runtime
2527

2628
## Quick Start
2729

@@ -43,6 +45,18 @@ final catalog = JsonCatalog(
4345
...standardActionDefinitions,
4446
'increment': const JsonActionDefinition(description: 'Increase count'),
4547
},
48+
styles: {
49+
'clean': const JsonStyleDefinition(
50+
displayName: 'Clean',
51+
description: 'Neutral and productivity-focused',
52+
guidance: 'Use subtle borders and restrained color.',
53+
),
54+
'midnight': const JsonStyleDefinition(
55+
displayName: 'Midnight',
56+
description: 'Dark, high-contrast dashboard style',
57+
guidance: 'Use compact spacing and bright accents.',
58+
),
59+
},
4660
);
4761
4862
final registry = defineRegistry(
@@ -100,13 +114,28 @@ Widget app() {
100114
return MaterialApp(
101115
home: Scaffold(
102116
body: Center(
103-
child: JsonRenderer(spec: spec, registry: registry),
117+
child: JsonRenderer(
118+
spec: spec,
119+
registry: registry,
120+
styleId: 'clean', // runtime-selected style
121+
),
104122
),
105123
),
106124
);
107125
}
108126
```
109127

128+
Generate style-aware LLM prompts:
129+
130+
```dart
131+
final prompt = catalog.prompt(
132+
options: const JsonPromptOptions(
133+
selectedStyleId: 'clean',
134+
includeStyles: true,
135+
),
136+
);
137+
```
138+
110139
## Stream JSONL Patches
111140

112141
```dart
@@ -184,6 +213,19 @@ Included scenarios:
184213
- Async action flow
185214
- Streamed JSONL patch simulation
186215

216+
The example includes a `Style Preset` dropdown and supports startup style selection:
217+
218+
```bash
219+
cd example
220+
flutter run --dart-define=STYLE_PRESET=midnight
221+
```
222+
223+
### Style Preset Screenshots
224+
225+
| clean | midnight | sunset |
226+
|---|---|---|
227+
| ![clean](https://raw.githubusercontent.com/Dev-Beom/flutter-json-render/main/assets/screenshots/example-style-clean.png) | ![midnight](https://raw.githubusercontent.com/Dev-Beom/flutter-json-render/main/assets/screenshots/example-style-midnight.png) | ![sunset](https://raw.githubusercontent.com/Dev-Beom/flutter-json-render/main/assets/screenshots/example-style-sunset.png) |
228+
187229
## pub.dev Release Checklist
188230

189231
```bash
205 KB
Loading
196 KB
Loading
211 KB
Loading

example/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@ Showcase app for the package with practical scenarios:
77
3. Dynamic props with `$cond`
88
4. Async action flow
99
5. Streamed JSONL patch simulation
10+
6. Style preset switching (`clean`, `midnight`, `sunset`)
1011

1112
Run:
1213

1314
```bash
1415
flutter pub get
1516
flutter run
1617
```
18+
19+
Run with a preset at startup:
20+
21+
```bash
22+
flutter run --dart-define=STYLE_PRESET=midnight
23+
```

0 commit comments

Comments
 (0)