-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Forms): Extension (beta) for simplified implementation of web fo…
…rms through tailored functionality for layout and data handling (#2420) ## Summary This is an extension to the base components of Eufemia for data input, display and layout surrounding data input/display. ## Details For more information about the architecture and idea behind how these components are structured, I would recommend reading the documentation for the extension that is added to the portal in the PR. Both in the base extension page (`/uilib/extensions/deposit/`), the provided demos there, as well as the base pages of each group of components (like `/uilib/extensions/deposit/DataInput/`) and each component page. For more detailed questions or discussions, please contact me on Slack. <img width="2015" alt="Screenshot 2023-06-01 at 14 24 28" src="https://github.com/dnbexperience/eufemia/assets/2526740/b7ce2b07-db7e-4479-9088-93f77a4c0dba"> ## Test plan <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI. --> --------- Co-authored-by: Henrik Haugberg <[email protected]> Co-authored-by: Tobias Høegh <[email protected]> Co-authored-by: -l <[email protected]>
- Loading branch information
1 parent
d8cfb1c
commit 74700c0
Showing
437 changed files
with
15,589 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: 'Forms' | ||
description: 'Reusable components for data input, data display and surrounding layout for simplified user interface creation in React, built on top of base Eufemia components.' | ||
showTabs: true | ||
status: 'beta' | ||
order: 2 | ||
tabs: | ||
- title: Info | ||
key: /uilib/extensions/forms/info | ||
- title: Demos | ||
key: /uilib/extensions/forms/demos | ||
- title: Case demo 1 | ||
key: /uilib/extensions/forms/casedemo1 | ||
--- | ||
|
||
import Info from 'Docs/uilib/extensions/forms/info' | ||
import Demos from 'Docs/uilib/extensions/forms/demos' | ||
|
||
<Info /> | ||
<Demos /> |
16 changes: 16 additions & 0 deletions
16
packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/DataContext.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
title: 'DataContext' | ||
order: 0 | ||
showTabs: true | ||
tabs: | ||
- title: Info | ||
key: '/info' | ||
- title: Components | ||
key: '/components' | ||
--- | ||
|
||
import Info from 'Docs/uilib/extensions/forms/DataContext/info' | ||
import Components from 'Docs/uilib/extensions/forms/DataContext/components' | ||
|
||
<Info /> | ||
<Components /> |
20 changes: 20 additions & 0 deletions
20
...ges/dnb-design-system-portal/src/docs/uilib/extensions/forms/DataContext/At.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: 'At' | ||
description: '`DataContext.At` makes it possible to dig into a data set to set a pointer as the root for sub components, as well as iterate array-data' | ||
showTabs: true | ||
tabs: | ||
- title: Info | ||
key: '/info' | ||
- title: Demos | ||
key: '/demos' | ||
- title: Properties | ||
key: '/properties' | ||
--- | ||
|
||
import Info from 'Docs/uilib/extensions/forms/DataContext/At/info' | ||
import Demos from 'Docs/uilib/extensions/forms/DataContext/At/demos' | ||
import Properties from 'Docs/uilib/extensions/forms/DataContext/At/properties' | ||
|
||
<Info /> | ||
<Demos /> | ||
<Properties /> |
56 changes: 56 additions & 0 deletions
56
...ages/dnb-design-system-portal/src/docs/uilib/extensions/forms/DataContext/At/Examples.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import ComponentBox from '../../../../../../shared/tags/ComponentBox' | ||
import { | ||
DataContext, | ||
Field, | ||
Value, | ||
} from '@dnb/eufemia/src/extensions/forms' | ||
|
||
export const Path = () => { | ||
return ( | ||
<ComponentBox scope={{ DataContext, Field }}> | ||
<DataContext.Provider | ||
data={{ | ||
foo: { | ||
one: 1, | ||
two: 2, | ||
}, | ||
bar: 'Bar', | ||
}} | ||
> | ||
<DataContext.At path="/foo"> | ||
<Field.Number path="/one" label="One" /> | ||
<Field.Number path="/two" label="Two" /> | ||
</DataContext.At> | ||
</DataContext.Provider> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const IteratePath = () => { | ||
return ( | ||
<ComponentBox scope={{ DataContext, Field, Value }}> | ||
<DataContext.Provider | ||
data={{ | ||
list: [ | ||
{ | ||
title: 'Object 1', | ||
}, | ||
{ | ||
title: 'Object 2', | ||
}, | ||
], | ||
bar: 'Bar', | ||
}} | ||
onChange={(data) => console.log('onChange', data)} | ||
onPathChange={(path, value) => | ||
console.log('onPathChange', path, value) | ||
} | ||
> | ||
<DataContext.At path="/list" iterate> | ||
<Value.String path="/title" label="Title" /> | ||
<Field.String path="/title" label="Title" /> | ||
</DataContext.At> | ||
</DataContext.Provider> | ||
</ComponentBox> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
...b-design-system-portal/src/docs/uilib/extensions/forms/DataContext/At/demos.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import * as Examples from './Examples' | ||
|
||
## Demos | ||
|
||
### At path | ||
|
||
<Examples.Path /> | ||
|
||
### Iterate path | ||
|
||
<Examples.IteratePath /> |
7 changes: 7 additions & 0 deletions
7
...nb-design-system-portal/src/docs/uilib/extensions/forms/DataContext/At/info.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Description | ||
|
||
`DataContext.At` makes it possible to dig into a data set to set a pointer as the root for sub components, as well as iterate array-data. |
11 changes: 11 additions & 0 deletions
11
...ign-system-portal/src/docs/uilib/extensions/forms/DataContext/At/properties.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| ---------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `children` | `React.Node` | _(optional)_ Features with given path as root for the DataContext. | | ||
| `path` | `string` | _(optional)_ JSON Pointer path to where in the outer DataContext source to point at. | | ||
| `iterate` | `boolean` | _(optional)_ True to iterate elements at given path based on the source data, including the index in the outer path, instead of just rendering children once. | |
11 changes: 11 additions & 0 deletions
11
...nb-design-system-portal/src/docs/uilib/extensions/forms/DataContext/Context.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: 'Context' | ||
description: 'The context object used in `DataContext.Provider`.' | ||
showTabs: false | ||
--- | ||
|
||
# DataContext.Context | ||
|
||
## Description | ||
|
||
The main context for [DataContext.Provider](/uilib/extensions/forms/DataContext/Provider) which the [Field](/uilib/extensions/forms/Field/) and [Value](/uilib/extensions/forms/Value/) components connect to (optional) for sources and callbacks when it is present. It can be used for creating custom components in similar ways. |
43 changes: 43 additions & 0 deletions
43
...s/dnb-design-system-portal/src/docs/uilib/extensions/forms/DataContext/ListComponents.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react' | ||
import { useStaticQuery, graphql } from 'gatsby' | ||
import ListSummaryFromEdges from '../../../../../shared/parts/ListSummaryFromEdges' | ||
|
||
export default function ListComponents() { | ||
const { | ||
allMdx: { edges }, | ||
} = useStaticQuery(graphql` | ||
{ | ||
allMdx( | ||
filter: { | ||
frontmatter: { | ||
title: { ne: null, nin: "Fragments" } | ||
draft: { ne: true } | ||
} | ||
internal: { | ||
contentFilePath: { | ||
glob: "**/uilib/extensions/forms/DataContext/**/*" | ||
} | ||
} | ||
} | ||
sort: [ | ||
{ frontmatter: { order: ASC } } | ||
{ frontmatter: { title: ASC } } | ||
] | ||
) { | ||
edges { | ||
node { | ||
fields { | ||
slug | ||
} | ||
frontmatter { | ||
title | ||
description | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`) | ||
|
||
return <ListSummaryFromEdges edges={edges} /> | ||
} |
24 changes: 24 additions & 0 deletions
24
...b-design-system-portal/src/docs/uilib/extensions/forms/DataContext/Provider.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
title: 'Provider' | ||
description: '`DataContext.Provider` is the context provider that has to wrap the features if components of Field and Value is to be used with a common source instead of distributing values and events individually.' | ||
showTabs: true | ||
tabs: | ||
- title: Info | ||
key: '/info' | ||
- title: Demos | ||
key: '/demos' | ||
- title: Properties | ||
key: '/properties' | ||
- title: Events | ||
key: '/events' | ||
--- | ||
|
||
import Info from 'Docs/uilib/extensions/forms/DataContext/Provider/info' | ||
import Demos from 'Docs/uilib/extensions/forms/DataContext/Provider/demos' | ||
import Properties from 'Docs/uilib/extensions/forms/DataContext/Provider/properties' | ||
import Events from 'Docs/uilib/extensions/forms/DataContext/Provider/events' | ||
|
||
<Info /> | ||
<Demos /> | ||
<Properties /> | ||
<Events /> |
Oops, something went wrong.
74700c0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
eufemia – ./
eufemia-eufemia.vercel.app
eufemia-dnb-design-system-portal.vercel.app
eufemia-git-main-eufemia.vercel.app