Skip to content

Commit be5c42d

Browse files
CopilotApollon77
andauthored
Add responsive size attributes to jsonConfig template (#1164)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Apollon77 <11976694+Apollon77@users.noreply.github.com> Co-authored-by: Ingo Fischer <github@fischer-ka.de>
1 parent 969a4e0 commit be5c42d

File tree

4 files changed

+83
-4
lines changed

4 files changed

+83
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
(at the beginning of a new line)
77
-->
88
## __WORK IN PROGRESS__
9+
* (@Apollon77/@copilot) Add responsive size attributes to jsonConfig template (#1121) · [Migration guide](docs/updates/20250831_jsonconfig_responsive_attributes.md)
910
* (@hacki11) Dev Container improvements (#1137) · [Migration guide](docs/updates/20250404_devcontainer_improvments.md)
1011
* (@hacki11) Allow newer versions of `admin` (#1137) · [Migration guide](docs/updates/20250406_admin_dependency_ge.md)
1112
* (@Apollon77/@copilot) Upgrade to @iobroker/testing 5.1.1, remove redundant dependencies (#1165) · [Migration guide](docs/updates/20250831_iobroker_testing_51.md)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Add responsive size attributes to jsonConfig template
2+
3+
The jsonConfig template now includes responsive size attributes to follow current best practices for ioBroker admin UI layouts. If you have an existing adapter with jsonConfig, you should consider adding these attributes for better responsive design.
4+
5+
## What changed
6+
7+
The `generateSetting` function in `templates/admin/jsonConfig.json.ts` now includes Bootstrap-style responsive size attributes for all input types:
8+
9+
```json
10+
{
11+
"xs": 12,
12+
"sm": 12,
13+
"md": 6,
14+
"lg": 4,
15+
"xl": 4
16+
}
17+
```
18+
19+
These attributes control how form fields are displayed across different screen sizes in the admin UI.
20+
21+
## How to update your adapter
22+
23+
If you have an existing adapter with `admin/jsonConfig.json`, you can manually add the responsive size attributes to improve the layout across different screen sizes.
24+
25+
**Before:**
26+
```json
27+
{
28+
"type": "text",
29+
"label": "option1",
30+
"newLine": true
31+
}
32+
```
33+
34+
**After:**
35+
```json
36+
{
37+
"type": "text",
38+
"label": "option1",
39+
"newLine": true,
40+
"xs": 12,
41+
"sm": 12,
42+
"md": 6,
43+
"lg": 4,
44+
"xl": 4
45+
}
46+
```
47+
48+
## Layout options reference
49+
50+
For detailed information about layout options and responsive attributes in jsonConfig, please refer to the official documentation:
51+
https://github.com/ioBroker/ioBroker.admin/blob/master/packages/jsonConfig/README.md#layout-options-xllgmdsmxs
52+
53+
## Benefits
54+
55+
- Better responsive design across different screen sizes
56+
- Consistent layout with current ioBroker admin UI standards
57+
- More professional appearance on tablets and mobile devices
58+
- Follows Bootstrap grid system conventions

templates/admin/jsonConfig.json.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,23 @@ function generateSetting(settings: AdapterSettings): any {
77
type: "select",
88
label: settings.label || settings.key,
99
options: settings.options.map(o => ({ label: o.text, value: o.value })),
10-
newLine: true
10+
newLine: true,
11+
xs: 12,
12+
sm: 12,
13+
md: 6,
14+
lg: 4,
15+
xl: 4
1116
};
1217
} else {
1318
return {
1419
type: settings.inputType,
1520
label: settings.label || settings.key,
16-
newLine: true
21+
newLine: true,
22+
xs: 12,
23+
sm: 12,
24+
md: 6,
25+
lg: 4,
26+
xl: 4
1727
};
1828
}
1929
}

test/baselines/adapter_JS_JsonUI_ESLint_TypeChecking_Spaces_SingleQuotes_Apache-2.0/admin/jsonConfig.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55
"option1": {
66
"type": "checkbox",
77
"label": "option1",
8-
"newLine": true
8+
"newLine": true,
9+
"xs": 12,
10+
"sm": 12,
11+
"md": 6,
12+
"lg": 4,
13+
"xl": 4
914
},
1015
"option2": {
1116
"type": "text",
1217
"label": "option2",
13-
"newLine": true
18+
"newLine": true,
19+
"xs": 12,
20+
"sm": 12,
21+
"md": 6,
22+
"lg": 4,
23+
"xl": 4
1424
}
1525
}
1626
}

0 commit comments

Comments
 (0)