Skip to content

Commit e5d99f0

Browse files
authored
Merge pull request #640 from rvsia/makeHeadersConsistent
Make headers consistent
2 parents 9a09eda + 53e0809 commit e5d99f0

File tree

7 files changed

+46
-36
lines changed

7 files changed

+46
-36
lines changed

packages/react-renderer-demo/src/helpers/list-of-contents.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@ const ListHeader = ({ text }) => {
3636
const classes = useLinkStyles();
3737
const router = useRouter();
3838
const level = (text.match(/#/g) || []).length;
39+
40+
if (level === 1) {
41+
return null;
42+
}
43+
3944
const labelText = text.replace(/#/g, '');
4045
return (
4146
<a className={classes.link} href={`${router.pathname}#${headerToId(text)}`} title={labelText}>
42-
{[...new Array(level)].map((_v, index) => (
47+
{[...new Array(level - 1)].map((_v, index) => (
4348
<React.Fragment key={index}>&nbsp;&nbsp;</React.Fragment>
4449
))}
4550
{labelText}
@@ -80,12 +85,17 @@ const useStyles = makeStyles((theme) => ({
8085
},
8186
hidden: {
8287
height: '100%'
88+
},
89+
headerLink: {
90+
color: 'inherit',
91+
textDecoration: 'none'
8392
}
8493
}));
8594

8695
const ListOfContents = ({ found = [] }) => {
8796
const [activeItem, setActive] = useState();
8897
let isMounted = true;
98+
const router = useRouter();
8999

90100
const scrollListener = (setActive) => {
91101
const min = -10;
@@ -110,11 +120,15 @@ const ListOfContents = ({ found = [] }) => {
110120
}, []);
111121
const classes = useStyles();
112122

123+
const header = found[0].replace(/# /, '');
124+
113125
return (
114126
<StickyBox offsetTop={96} offsetBottom={20}>
115127
<div className={classes.fixedContainer}>
116128
<Typography className={classes.contentHeader} component="h3">
117-
Content
129+
<a className={classes.headerLink} href={`${router.pathname}#${headerToId(header)}`} title={header}>
130+
{header}
131+
</a>
118132
</Typography>
119133
<List dense>
120134
{found.map((text) => (

packages/react-renderer-demo/src/pages/components/field-array.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import DocPage from '@docs/doc-page';
1111
import { FieldArray } from '@data-driven-forms/react-form-renderer';
1212
```
1313

14-
# Dynamic fields
14+
## Dynamic fields
1515

1616
Dynamic fields allow you to add or remove field inputs in your forms. In Data Driven Forms, Field Array is used to provide this functionality. Simillarly to [FieldProvider](/components/field-provider) Data driven forms include [React Final Form Arrays](https://github.com/final-form/react-final-form-arrays). Please visit their documentation to learn more about the functionality and implementation.
1717

@@ -25,7 +25,7 @@ import { FieldArray } from '@data-driven-forms/react-form-renderer';
2525

2626
<CodeExamples source="components/field-array/form-fields-mapper" mode="preview" />
2727

28-
# Naming
28+
## Naming
2929

3030
FieldArray supports [final form notation](https://final-form.org/docs/final-form/field-names).
3131

@@ -59,7 +59,7 @@ You don't need to name the nested components, then the values are saved as an ar
5959
}
6060
```
6161

62-
# Validators
62+
## Validators
6363

6464
You can use user a few provided validators (you can also use your [own](/mappers/validator-mapper).)
6565

@@ -70,13 +70,9 @@ EXACT_LENGTH: ({threshold})
7070
```
7171

7272

73-
# Implementation
73+
## Implementation
7474

75-
PF4 and MUI component mapper provides an experimental implementation of field arrays.
76-
77-
[PF4 Field Array](/mappers/field-array?mapper=pf4)
78-
79-
[MUI Field Array](/mappers/field-array?mapper=mui)
75+
All DDF mappers contain its own implementation [field array](/mappers/field-array?mapper=pf4)
8076

8177
<CodeExamples source="components/field-array/pf4-demo" mode="preview" />
8278

packages/react-renderer-demo/src/pages/components/renderer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ const App = () => (<FormRenderer
4242
|[validate](/schema/introduction#validate)|func|A function which receives all form values and returns an object with errors.||
4343
|[validatorMapper](/mappers/validator-mapper)|object|A mapper containing custom validators, it's automatically merged with the default one.||
4444

45-
# Schema
45+
## Schema
4646

4747
The root object of the schema represents the Form component. Please read more [here](/schema/introduction).
4848

49-
## Example
49+
### Example
5050

5151
```javascript
5252
schema = {

packages/react-renderer-demo/src/pages/development-setup.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ yarn dev
4646
yarn lerna clean # will delete all node_modules
4747
```
4848

49-
# Tests
49+
## Tests
5050

5151
Tests needed to be run from the core folder.
5252

@@ -56,7 +56,7 @@ yarn test
5656
yarn test packages/pf3-component-mapper
5757
```
5858

59-
# Commits
59+
## Commits
6060

6161
Data Driven Forms uses [Semantic Release](https://github.com/semantic-release/commit-analyzer)
6262

@@ -79,11 +79,11 @@ Please, do not use Semantic Release, if you update only the demo.
7979

8080
All packages are releasing together and they share the version number.
8181

82-
# Changes to documentation
82+
## Changes to documentation
8383

8484
If your changes influence API or add new features, you should describe these new options in the `react-renderer-demo` repository. Thanks!
8585

86-
# Generating a mapper template
86+
## Generating a mapper template
8787

8888
To generate a mapper template, run:
8989

packages/react-renderer-demo/src/pages/mappers/action-mapper.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The [ActionMapper](/components/renderer#optionalprops) allows you to map schema
2929

3030
Do not forget to keep order of args or use object with keys as named arguments.
3131

32-
# Example
32+
## Example
3333

3434
So, let's say you need to translate labels of fields using your translate function `translate(id)` and the schema has no access to use JavaScript code.
3535

packages/react-renderer-demo/src/pages/mappers/component-api.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Standard components are:
3030
|switch|
3131
|timepicker/datepicker|
3232

33-
# Form fields components
33+
## Form fields components
3434

3535
Basic components that can change the form state (inputs) share common props. These components are using [useFieldApi](/mappers/custom-mapper#usefieldapi) or [FieldProvider](/mappers/custom-mapper#fieldprovider) to access the form state.
3636

@@ -45,23 +45,23 @@ Basic components that can change the form state (inputs) share common props. The
4545
|isReadOnly|boolean|Is the field readOnly?|
4646
|initialValue|custom|There are two ways how to set initial values in the form: you can use either the [initialValues](/components/renderer) prop for the whole form or you can set the value in the schema for each field separately. For more information, please see [here](https://final-form.org/docs/react-final-form/types/FieldProps#initialvalue).|
4747

48-
## Text field
48+
### Text field
4949

5050
|Prop|Type|Description|
5151
|----|:--:|----------:|
5252
|placeholder|node/string|A placeholder|
5353

5454
<ExampleLink to='text-field' />
5555

56-
## Text area
56+
### Text area
5757

5858
|Prop|Type|Description|
5959
|----|:--:|----------:|
6060
|placeholder|node/string|A placeholder|
6161

6262
<ExampleLink to='textarea' />
6363

64-
## Select
64+
### Select
6565

6666
|Prop|Type|Description|
6767
|----|:--:|----------:|
@@ -76,7 +76,7 @@ Basic components that can change the form state (inputs) share common props. The
7676

7777
<ExampleLink to='select' />
7878

79-
## Checkbox
79+
### Checkbox
8080

8181
|Prop|Type|Description|
8282
|----|:--:|----------:|
@@ -86,15 +86,15 @@ Basic components that can change the form state (inputs) share common props. The
8686
<br />
8787
<ExampleLink to='checkbox' text='Single checkbox example'/>
8888

89-
## Radio
89+
### Radio
9090

9191
|Prop|Type|Description|
9292
|----|:--:|----------:|
9393
|options|array|Options in format { label: 'Label', value: value }|
9494

9595
<ExampleLink to='radio' />
9696

97-
## Switch
97+
### Switch
9898

9999
|Prop|Type|Description|
100100
|----|:--:|----------:|
@@ -103,7 +103,7 @@ Basic components that can change the form state (inputs) share common props. The
103103

104104
<ExampleLink to='switch' />
105105

106-
## Datepicker
106+
### Datepicker
107107

108108
This component is using [react-day-picker](https://react-day-picker.js.org/docs/) as a base component.
109109

@@ -121,17 +121,17 @@ This component is using [react-day-picker](https://react-day-picker.js.org/docs/
121121

122122
<ExampleLink to='date-picker' />
123123

124-
## Timepicker
124+
### Timepicker
125125

126126
|Prop|Type|Description|
127127
|----|:--:|----------:|
128128
|placeholder|node/string|A placeholder|
129129

130130
<ExampleLink to='time-picker' />
131131

132-
# Others components
132+
## Others components
133133

134-
## Subform
134+
### Subform
135135

136136
|Prop|Type|Description|
137137
|----|:--:|----------:|
@@ -141,7 +141,7 @@ This component is using [react-day-picker](https://react-day-picker.js.org/docs/
141141

142142
<ExampleLink to='sub-form' />
143143

144-
## Tab/tab item
144+
### Tab/tab item
145145

146146
Tab <br/>
147147

@@ -158,7 +158,7 @@ Tab item <br/>
158158

159159
<ExampleLink to='tabs' />
160160

161-
## Wizard
161+
### Wizard
162162

163163
Wizard <br />
164164

@@ -180,7 +180,7 @@ Wizard step <br/>
180180

181181
<ExampleLink to='wizard' />
182182

183-
## Plain text
183+
### Plain text
184184

185185
|Prop|Type|Description|
186186
|----|:--:|----------:|

packages/react-renderer-demo/src/pages/schema/clear-on-unmount.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ When using dynamic forms where more fields share the same name, the value is pre
99
`clearOnUnmount` option in the renderer component or in the schema of the field. The option in the schema has always higher priority. (When
1010
`clearOnUnmount` is set in the renderer and the field has it this attribute set to `false`, the field value will not be cleared.)
1111

12-
# Examples
12+
## Examples
1313

14-
## Form example
14+
### Form example
1515

1616
<CodeExample source="components/clear-on-unmount" mode="preview" />
1717

1818

19-
## Form level configuration
19+
### Form level configuration
2020

2121
```jsx
2222
<FormRenderer
@@ -28,7 +28,7 @@ When using dynamic forms where more fields share the same name, the value is pre
2828
/>
2929
```
3030

31-
## Field level configuration
31+
### Field level configuration
3232

3333
```jsx
3434
{

0 commit comments

Comments
 (0)