Skip to content

Commit 86217b7

Browse files
Copilotideag
andauthored
Simplify JSON structure: use direct array instead of 'buttons' wrapper
Agent-Logs-Url: https://github.com/tinypluginlabs/demo/sessions/f3fe6d1f-4ee6-4520-9e56-05dbd970585f Co-authored-by: ideag <3252474+ideag@users.noreply.github.com>
1 parent 67252d1 commit 86217b7

4 files changed

Lines changed: 71 additions & 84 deletions

File tree

BLUEPRINT_JSON_STRUCTURE.md

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,29 @@ This document provides the structure definition for `/blueprints/blueprints.json
55

66
## JSON Structure
77

8+
The JSON file is a direct array of button configuration objects:
9+
810
```json
9-
{
10-
"buttons": [
11-
{
12-
"id": "string",
13-
"title": "string",
14-
"path": "string",
15-
"icon": "string",
16-
"disabled": false
17-
}
18-
]
19-
}
11+
[
12+
{
13+
"id": "string",
14+
"title": "string",
15+
"path": "string",
16+
"icon": "string",
17+
"disabled": false
18+
}
19+
]
2020
```
2121

2222
## Field Definitions
2323

2424
| Field | Type | Required | Description |
2525
|-------|------|----------|-------------|
26-
| `buttons` | Array | Yes | Array of button configuration objects |
27-
| `buttons[].id` | String | Yes | Unique identifier for the button (used as React key) |
28-
| `buttons[].title` | String | Yes | Display text shown under the button icon |
29-
| `buttons[].path` | String | Yes | Navigation path (e.g., "/tinyrelated") |
30-
| `buttons[].icon` | String | No | Icon to display (React component name or SVG URL, default: "WordPressIcon") |
31-
| `buttons[].disabled` | Boolean | No | Whether the button is disabled (default: false) |
26+
| `[].id` | String | Yes | Unique identifier for the button (used as React key) |
27+
| `[].title` | String | Yes | Display text shown under the button icon |
28+
| `[].path` | String | Yes | Navigation path (e.g., "/tinyrelated") |
29+
| `[].icon` | String | No | Icon to display (React component name or SVG URL, default: "WordPressIcon") |
30+
| `[].disabled` | Boolean | No | Whether the button is disabled (default: false) |
3231

3332
## Icon Configuration
3433

@@ -51,30 +50,28 @@ If the `icon` field is omitted or an invalid component name is provided, the but
5150
## Example Configuration
5251

5352
```json
54-
{
55-
"buttons": [
56-
{
57-
"id": "tinyrelated",
58-
"title": "tinyRelated",
59-
"path": "/tinyrelated",
60-
"icon": "WordPressIcon",
61-
"disabled": false
62-
},
63-
{
64-
"id": "tinyrating",
65-
"title": "tinyRating",
66-
"path": "/tinyrating",
67-
"icon": "https://example.com/rating-icon.svg",
68-
"disabled": false
69-
},
70-
{
71-
"id": "tinyevent",
72-
"title": "tinyEvent",
73-
"path": "/tinyevent",
74-
"disabled": false
75-
}
76-
]
77-
}
53+
[
54+
{
55+
"id": "tinyrelated",
56+
"title": "tinyRelated",
57+
"path": "/tinyrelated",
58+
"icon": "WordPressIcon",
59+
"disabled": false
60+
},
61+
{
62+
"id": "tinyrating",
63+
"title": "tinyRating",
64+
"path": "/tinyrating",
65+
"icon": "https://example.com/rating-icon.svg",
66+
"disabled": false
67+
},
68+
{
69+
"id": "tinyevent",
70+
"title": "tinyEvent",
71+
"path": "/tinyevent",
72+
"disabled": false
73+
}
74+
]
7875
```
7976

8077
## File Location

IMPLEMENTATION_SUMMARY.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ export interface BlueprintButton {
1919
disabled?: boolean; // Optional: button disabled state
2020
}
2121

22-
export interface BlueprintsConfig {
23-
buttons: BlueprintButton[];
24-
}
22+
export type BlueprintsConfig = BlueprintButton[];
2523
```
2624

2725
### 2. Component Updates
@@ -56,14 +54,14 @@ function resolveIcon(iconSpec?: string): React.ReactNode {
5654
return <WordPressIcon />;
5755
}
5856

59-
// Fetch from JSON
57+
// Fetch from JSON (direct array)
6058
const { data: blueprintsConfig } = useFetch<BlueprintsConfig>(
6159
'/blueprints/blueprints.json'
6260
);
6361

6462
// Fallback to defaults
6563
const defaultCreationOptions: BlueprintButton[] = [...];
66-
const buttonsConfig = blueprintsConfig?.buttons || defaultCreationOptions;
64+
const buttonsConfig = blueprintsConfig || defaultCreationOptions;
6765

6866
// Transform to button props with dynamic icon resolution
6967
const creationOptions = buttonsConfig.map((button) => ({
@@ -87,17 +85,16 @@ Comprehensive documentation explaining:
8785

8886
## JSON File Structure
8987

90-
The CI process should deploy a `blueprints.json` file to `/blueprints/blueprints.json` with the following structure:
88+
The CI process should deploy a `blueprints.json` file to `/blueprints/blueprints.json` as a direct array:
9189

9290
```json
93-
{
94-
"buttons": [
95-
{
96-
"id": "tinyrelated",
97-
"title": "tinyRelated",
98-
"path": "/tinyrelated",
99-
"disabled": false
100-
},
91+
[
92+
{
93+
"id": "tinyrelated",
94+
"title": "tinyRelated",
95+
"path": "/tinyrelated",
96+
"disabled": false
97+
},
10198
{
10299
"id": "tinyrating",
103100
"title": "tinyRating",
@@ -110,8 +107,7 @@ The CI process should deploy a `blueprints.json` file to `/blueprints/blueprints
110107
"path": "/tinyevent",
111108
"disabled": false
112109
}
113-
]
114-
}
110+
]
115111
```
116112

117113
## Behavior

packages/playground/website/src/components/saved-playgrounds-overlay/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function SavedPlaygroundsOverlay({
148148
];
149149

150150
// Use fetched config if available, otherwise use defaults
151-
const buttonsConfig = blueprintsConfig?.buttons || defaultCreationOptions;
151+
const buttonsConfig = blueprintsConfig || defaultCreationOptions;
152152

153153
// Transform button configs into creation options with onClick handlers
154154
const creationOptions = buttonsConfig.map((button) => ({

packages/playground/website/src/lib/types/blueprints-config.ts

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,23 @@
55
* to /blueprints/blueprints.json for configuring the "Start a new Playground"
66
* overlay buttons.
77
*
8-
* Example JSON structure:
9-
* {
10-
* "buttons": [
11-
* {
12-
* "id": "tinyrelated",
13-
* "title": "tinyRelated",
14-
* "path": "/tinyrelated",
15-
* "icon": "WordPressIcon",
16-
* "disabled": false
17-
* },
18-
* {
19-
* "id": "tinyrating",
20-
* "title": "tinyRating",
21-
* "path": "/tinyrating",
22-
* "icon": "https://example.com/icon.svg",
23-
* "disabled": false
24-
* }
25-
* ]
26-
* }
8+
* Example JSON structure (array of button objects):
9+
* [
10+
* {
11+
* "id": "tinyrelated",
12+
* "title": "tinyRelated",
13+
* "path": "/tinyrelated",
14+
* "icon": "WordPressIcon",
15+
* "disabled": false
16+
* },
17+
* {
18+
* "id": "tinyrating",
19+
* "title": "tinyRating",
20+
* "path": "/tinyrating",
21+
* "icon": "https://example.com/icon.svg",
22+
* "disabled": false
23+
* }
24+
* ]
2725
*/
2826

2927
/**
@@ -62,11 +60,7 @@ export interface BlueprintButton {
6260
}
6361

6462
/**
65-
* Root configuration object for blueprints.json
63+
* Root configuration type for blueprints.json
64+
* The JSON file should be a direct array of BlueprintButton objects
6665
*/
67-
export interface BlueprintsConfig {
68-
/**
69-
* Array of button configurations
70-
*/
71-
buttons: BlueprintButton[];
72-
}
66+
export type BlueprintsConfig = BlueprintButton[];

0 commit comments

Comments
 (0)