Skip to content

Commit 3a651c7

Browse files
committed
Form rows are multi-column, according to parent width.
1 parent eebe16b commit 3a651c7

File tree

9 files changed

+34
-21
lines changed

9 files changed

+34
-21
lines changed

.eslintcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/reportWebVitals.js":"1","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/App.jsx":"2","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/LocationsPanel.jsx":"3","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/formData.js":"4","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/index.js":"5","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/jsonSchema.js":"6","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/uiSchema.js":"7","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/TwoColObjectFieldTemplate.jsx":"8","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/getFormData.js":"9"},{"size":452,"mtime":1613077644221,"results":"10","hashOfConfig":"11"},{"size":460,"mtime":1613147279663,"results":"12","hashOfConfig":"11"},{"size":1478,"mtime":1613148101303,"results":"13","hashOfConfig":"11"},{"size":192,"mtime":1613088855077,"results":"14","hashOfConfig":"11"},{"size":612,"mtime":1613072388235,"results":"15","hashOfConfig":"11"},{"size":830,"mtime":1613089761093,"results":"16","hashOfConfig":"11"},{"size":651,"mtime":1613089723356,"results":"17","hashOfConfig":"11"},{"size":1801,"mtime":1613144044405,"results":"18","hashOfConfig":"11"},{"size":106,"mtime":1613092417203,"results":"19","hashOfConfig":"11"},{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},"1675vna",{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"31","messages":"32","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/reportWebVitals.js",[],["39","40","41","42","43"],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/App.jsx",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/LocationsPanel.jsx",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/formData.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/index.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/jsonSchema.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/uiSchema.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/TwoColObjectFieldTemplate.jsx",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/getFormData.js",[],{"ruleId":"44","replacedBy":"45"},{"ruleId":"46","replacedBy":"47"},{"ruleId":"48","replacedBy":"49"},{"ruleId":"50","replacedBy":"51"},{"ruleId":"52","replacedBy":"53"},"lines-around-directive",["54"],"global-require",[],"no-buffer-constructor",[],"no-new-require",[],"no-path-concat",[],"padding-line-between-statements"]
1+
[{"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/reportWebVitals.js":"1","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/App.jsx":"2","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/LocationsPanel.jsx":"3","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/formData.js":"4","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/index.js":"5","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/jsonSchema.js":"6","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/uiSchema.js":"7","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/TwoColObjectFieldTemplate.jsx":"8","/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/getFormData.js":"9"},{"size":452,"mtime":1613077644221,"results":"10","hashOfConfig":"11"},{"size":460,"mtime":1613147279663,"results":"12","hashOfConfig":"11"},{"size":1447,"mtime":1613223053048,"results":"13","hashOfConfig":"11"},{"size":192,"mtime":1613088855077,"results":"14","hashOfConfig":"11"},{"size":612,"mtime":1613072388235,"results":"15","hashOfConfig":"11"},{"size":832,"mtime":1613223006190,"results":"16","hashOfConfig":"11"},{"size":651,"mtime":1613089723356,"results":"17","hashOfConfig":"11"},{"size":1800,"mtime":1613222701333,"results":"18","hashOfConfig":"11"},{"size":106,"mtime":1613092417203,"results":"19","hashOfConfig":"11"},{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},"1675vna",{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"25","messages":"26","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"27","messages":"28","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"29","messages":"30","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"31","messages":"32","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"33","messages":"34","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"22"},"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/reportWebVitals.js",[],["39","40","41","42","43"],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/App.jsx",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/LocationsPanel.jsx",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/formData.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/index.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/jsonSchema.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/schemas/uiSchema.js",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/components/TwoColObjectFieldTemplate.jsx",[],"/Users/mauget/WebstormProjects/react-json-schema-form-demo/src/services/getFormData.js",[],{"ruleId":"44","replacedBy":"45"},{"ruleId":"46","replacedBy":"47"},{"ruleId":"48","replacedBy":"49"},{"ruleId":"50","replacedBy":"51"},{"ruleId":"52","replacedBy":"53"},"lines-around-directive",["54"],"global-require",[],"no-buffer-constructor",[],"no-new-require",[],"no-path-concat",[],"padding-line-between-statements"]

.idea/workspace.xml

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ document, a JSON schema describing the document, and a JSON
66
UI schema that says how to render the form items of the document.
77

88
It uses a custom object field template in its Ui schema to force
9-
fields into two columns or one column for narrow views.
9+
fields into multiple columns according to parent weidth.
1010

1111
## Install
1212

doc/registration-form.png

-8.79 KB
Loading

src/components/LocationsPanel.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,18 @@ toastr.options.progressBar = true;
1010

1111
const StyledWrapper = styled.section`
1212
margin: 2rem;
13-
padding: 4rem;
13+
padding: 1rem;
1414
border: solid 1px darkred;
1515
color: darkslateblue;
1616
border-radius: 12px;
1717
`;
1818

1919
const StyledTitle = styled.h1`
2020
font-size: 1.5rem;
21-
text-align: center;
2221
`;
2322

2423
const StyledDetailArea = styled.div`
25-
margin: 1.5rem;
24+
margin: 2.0rem;
2625
`;
2726

2827
export default function LocationsPanel() {
@@ -40,7 +39,7 @@ export default function LocationsPanel() {
4039

4140
return (
4241
<StyledWrapper>
43-
<StyledTitle>Demonstration of React JSON Schema</StyledTitle>
42+
<StyledTitle>React JSON Schema Form Demo</StyledTitle>
4443
<StyledDetailArea>
4544
<Form
4645
dataTestId="testid"

src/components/TwoColObjectFieldTemplate.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ const StyledRow = styled.div`
1515
`;
1616

1717
const StyledCol = styled.div`
18-
min-width: 44%;
19-
margin: 0.5rem;
18+
margin: 0 2rem 0 0;
2019
flex-grow: 1;
2120
`;
2221

@@ -25,9 +24,9 @@ const StyledCol = styled.div`
2524
* It arranges all fields in a single row using flex-wrap and min-width to force the layout
2625
* to rows of two fields. For form widths approaching min-width each row contains one field.
2726
*
28-
* Add this custom object template to a `<form objectFieldTemplate=TwoColObjectFieldTemplate `,
27+
* Add this custom object template to a `<form objectFieldTemplate=MultiColumnObjectFieldTemplate `,
2928
* or to the RJSF UI schema,
30-
* ` "ui:TwoColObjectFieldTemplate": TwoColObjectFieldTemplate, `
29+
* ` "ui:MultiColumnObjectFieldTemplate": MultiColumnObjectFieldTemplate, `
3130
*
3231
* @param TitleField
3332
* @param properties array

src/components/TwoColObjectFieldTemplate.test.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
22
import { configure, shallow } from 'enzyme';
33
import Adapter from 'enzyme-adapter-react-16';
4-
import TwoColObjectFieldTemplate from './TwoColObjectFieldTemplate';
4+
import MultiColumnObjectFieldTemplate from './TwoColObjectFieldTemplate';
55

66
configure({ adapter: new Adapter() });
77

8-
describe('TwoColObjectFieldTemplate', () => {
8+
describe('MultiColumnObjectFieldTemplate', () => {
99
it('should match its snapshot', () => {
1010
const titleField = jest.fn();
1111
const properties = [
@@ -14,7 +14,7 @@ describe('TwoColObjectFieldTemplate', () => {
1414
{ content: { ket: 'age' } },
1515
];
1616
const wrapper = shallow(
17-
<TwoColObjectFieldTemplate
17+
<MultiColumnObjectFieldTemplate
1818
TitleField={titleField}
1919
properties={properties}
2020
title='title'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`TwoColObjectFieldTemplate should match its snapshot 1`] = `ShallowWrapper {}`;
3+
exports[`MultiColumnObjectFieldTemplate should match its snapshot 1`] = `ShallowWrapper {}`;

src/schemas/jsonSchema.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const jsonSchema = {
2-
title: 'A registration form',
3-
description: 'A simple form example.',
2+
title: 'Registration form',
3+
description: 'Mulci-column form example.',
44
type: 'object',
55
required: ['firstName', 'lastName'],
66
properties: {

0 commit comments

Comments
 (0)