-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(forms): add
Value.Selection
component (#3857)
- [x] Fix and update tests - [x] Improve and fix Value rendering --------- Co-authored-by: Tobias Høegh <tobias@tujo.no>
- Loading branch information
1 parent
13fc1a8
commit 7432986
Showing
18 changed files
with
571 additions
and
57 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
27 changes: 27 additions & 0 deletions
27
...es/dnb-design-system-portal/src/docs/uilib/extensions/forms/Value/Selection.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,27 @@ | ||
--- | ||
title: 'Selection' | ||
description: '`Value.Selection` is a component for displaying a string value based on a user selection.' | ||
componentType: 'base-value' | ||
hideInMenu: true | ||
showTabs: true | ||
tabs: | ||
- title: Info | ||
key: '/info' | ||
- title: Demos | ||
key: '/demos' | ||
- title: Properties | ||
key: '/properties' | ||
breadcrumb: | ||
- text: Forms | ||
href: /uilib/extensions/forms/ | ||
- text: Value | ||
href: /uilib/extensions/forms/Value/ | ||
- text: Selection | ||
href: /uilib/extensions/forms/Value/Selection/ | ||
--- | ||
|
||
import Info from 'Docs/uilib/extensions/forms/Value/Selection/info' | ||
import Demos from 'Docs/uilib/extensions/forms/Value/Selection/demos' | ||
|
||
<Info /> | ||
<Demos /> |
101 changes: 101 additions & 0 deletions
101
...ges/dnb-design-system-portal/src/docs/uilib/extensions/forms/Value/Selection/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,101 @@ | ||
import ComponentBox from '../../../../../../shared/tags/ComponentBox' | ||
import { Flex, P } from '@dnb/eufemia/src' | ||
import { Field, Form, Value } from '@dnb/eufemia/src/extensions/forms' | ||
|
||
export const Placeholder = () => { | ||
return ( | ||
<ComponentBox scope={{ Value }}> | ||
<Value.Selection placeholder="No values selected" /> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const WithValue = () => { | ||
return ( | ||
<ComponentBox scope={{ Value }}> | ||
<Value.Selection value="Bar" /> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const Label = () => { | ||
return ( | ||
<ComponentBox scope={{ Value }}> | ||
<Value.Selection label="Label text" showEmpty /> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const LabelAndValue = () => { | ||
return ( | ||
<ComponentBox scope={{ Value }}> | ||
<Value.Selection label="Label text" value="Foo" /> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const Inline = () => { | ||
return ( | ||
<ComponentBox scope={{ Value }}> | ||
<P> | ||
This is before the component | ||
<Value.Selection value="Baz" inline /> | ||
This is after the component | ||
</P> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const FieldSelectionPath = () => { | ||
return ( | ||
<ComponentBox> | ||
<Form.Handler | ||
data={{ | ||
selection: 'bar', | ||
myList: [ | ||
{ value: 'foo', title: 'Foo' }, | ||
{ value: 'bar', title: 'Bar' }, | ||
{ value: 'baz', title: 'Baz' }, | ||
], | ||
}} | ||
> | ||
<Flex.Stack> | ||
<Field.Selection | ||
path="/selection" | ||
dataPath="/myList" | ||
variant="radio" | ||
label="My selection" | ||
/> | ||
<Value.Selection | ||
path="/selection" | ||
dataPath="/myList" | ||
inheritLabel | ||
/> | ||
</Flex.Stack> | ||
</Form.Handler> | ||
</ComponentBox> | ||
) | ||
} | ||
|
||
export const FieldSelectionAndOption = () => { | ||
return ( | ||
<ComponentBox> | ||
<Form.Handler> | ||
<Flex.Stack> | ||
<Field.Selection | ||
label="My selection" | ||
path="/myPath" | ||
variant="radio" | ||
value="bar" | ||
> | ||
<Field.Option value="foo" title="Foo" /> | ||
<Field.Option value="bar" title="Bar" /> | ||
<Field.Option value="baz" title="Baz" /> | ||
</Field.Selection> | ||
|
||
<Value.Selection label="My selection" path="/myPath" /> | ||
</Flex.Stack> | ||
</Form.Handler> | ||
</ComponentBox> | ||
) | ||
} |
39 changes: 39 additions & 0 deletions
39
...-design-system-portal/src/docs/uilib/extensions/forms/Value/Selection/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,39 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import * as Examples from './Examples' | ||
|
||
## Demos | ||
|
||
### Placeholder | ||
|
||
<Examples.Placeholder /> | ||
|
||
### Value | ||
|
||
<Examples.WithValue /> | ||
|
||
### Label | ||
|
||
<Examples.Label /> | ||
|
||
### Label and value | ||
|
||
<Examples.LabelAndValue /> | ||
|
||
### Inline | ||
|
||
<Examples.Inline /> | ||
|
||
### Field.Selection with path | ||
|
||
When using the same `path` as on a `Field.Selection`, the title will be used as the displayed value. | ||
|
||
<Examples.FieldSelectionPath /> | ||
|
||
### Field.Option and Field.Selection | ||
|
||
When using the same `path` as on a `Field.Selection`, the `Field.Option` title will be used as the displayed value. | ||
|
||
<Examples.FieldSelectionAndOption /> |
14 changes: 14 additions & 0 deletions
14
...b-design-system-portal/src/docs/uilib/extensions/forms/Value/Selection/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,14 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
## Description | ||
|
||
`Value.Selection` is a component for displaying a string value based on a user selection. | ||
|
||
There is a corresponding [Field.Selection](/uilib/extensions/forms/base-fields/Selection) component. | ||
|
||
```jsx | ||
import { Value } from '@dnb/eufemia/extensions/forms' | ||
render(<Value.Selection />) | ||
``` |
18 changes: 18 additions & 0 deletions
18
...gn-system-portal/src/docs/uilib/extensions/forms/Value/Selection/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,18 @@ | ||
--- | ||
showTabs: true | ||
--- | ||
|
||
import TranslationsTable from 'dnb-design-system-portal/src/shared/parts/TranslationsTable' | ||
import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable' | ||
import { SelectionProperties } from '@dnb/eufemia/src/extensions/forms/Value/Selection/SelectionDocs' | ||
import { ValueProperties } from '@dnb/eufemia/src/extensions/forms/Value/ValueDocs' | ||
|
||
## Properties | ||
|
||
### Field-specific props | ||
|
||
<PropertiesTable props={SelectionProperties} /> | ||
|
||
### General props | ||
|
||
<PropertiesTable props={ValueProperties} /> |
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
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
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
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
Oops, something went wrong.