Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Forms): add inline HelpButton to all Field.* components as default (with option to open in Dialog) #4282

Merged
merged 7 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const Default = () => {
)
}

export const OverStack = () => {
export const PrecedingFlexContainer = () => {
return (
<ComponentBox data-visual-test="layout-main-heading-over-stack">
<ComponentBox data-visual-test="layout-main-heading-above-stack">
<Form.MainHeading>This is a main heading</Form.MainHeading>
<Flex.Stack>
<P>Stack contents</P>
Expand All @@ -21,11 +21,29 @@ export const OverStack = () => {
)
}

export const OverStackWithCard = () => {
export const AboveCard = () => {
return (
<ComponentBox data-visual-test="layout-main-heading-over-card">
<ComponentBox data-visual-test="layout-main-heading-above-card">
<Form.MainHeading>This is a main heading</Form.MainHeading>
<Card stack>
<P>Card contents</P>
</Card>
</ComponentBox>
)
}

export const WithHelpButton = () => {
return (
<ComponentBox data-visual-test="layout-main-heading-help-button">
<Flex.Stack>
<Form.MainHeading
help={{
title: 'Title',
content: 'Content',
}}
>
This is a main heading
</Form.MainHeading>
<Card stack>
<P>Card contents</P>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ import * as Examples from './Examples'

<Examples.Default />

### Over Stack
### Above a flex container

<Examples.OverStack />
<Examples.PrecedingFlexContainer />

### Over Stack with Card
### Above Card

<Examples.OverStackWithCard />
When placed above a [Card](/uilib/components/card/) component, the heading will be indented to align with the card content.

On small screens, the indention will be removed.

<Examples.AboveCard />

### With HelpButton

<Examples.WithHelpButton />
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const BelowMainHeading = () => {
)
}

export const OverStack = () => {
export const PrecedingFlexContainer = () => {
return (
<ComponentBox>
<Form.SubHeading>This is a sub heading</Form.SubHeading>
Expand All @@ -43,15 +43,13 @@ export const InsideCard = () => {
)
}

export const OverStackWithCard = () => {
export const AboveCard = () => {
return (
<ComponentBox data-visual-test="layout-sub-heading-over-card">
<ComponentBox data-visual-test="layout-sub-heading-above-card">
<Form.SubHeading>This is a sub heading</Form.SubHeading>
<Flex.Stack>
<Card stack>
<P>Card contents</P>
</Card>
</Flex.Stack>
<Card stack>
<P>Card contents</P>
</Card>
</ComponentBox>
)
}
Expand All @@ -65,3 +63,23 @@ export const TwoSubHeadings = () => {
</ComponentBox>
)
}

export const WithHelpButton = () => {
return (
<ComponentBox data-visual-test="layout-sub-heading-help-button">
<Flex.Stack>
<Form.SubHeading
help={{
title: 'Title',
content: 'Content',
}}
>
This is a sub heading
</Form.SubHeading>
<Card stack>
<P>Card contents</P>
</Card>
</Flex.Stack>
</ComponentBox>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,26 @@ import * as Examples from './Examples'

<Examples.BelowMainHeading />

### Over Stack
### Above a flex container

<Examples.OverStack />
<Examples.PrecedingFlexContainer />

### Inside Card

<Examples.InsideCard />

### Over Stack with Card
### Above Card

<Examples.OverStackWithCard />
When placed above a [Card](/uilib/components/card/) component, the heading will be indented to align with the card content.

On small screens, the indention will be removed.

<Examples.AboveCard />

### Two sub headings

<Examples.TwoSubHeadings />

### With HelpButton

<Examples.WithHelpButton />
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,34 @@ showTabs: true

There is a corresponding [Value.ArraySelection](/uilib/extensions/forms/Value/ArraySelection) component.

The [Field.Option](/uilib/extensions/forms/base-fields/Option/) is a related component.

```jsx
import { Field } from '@dnb/eufemia/extensions/forms'

render(
<Field.ArraySelection>
<Field.Option />
<Field.Option />
</Field.ArraySelection>,
)
```

You can also use the `dataPath` property to provide the data to the component:

```jsx
import { Field } from '@dnb/eufemia/extensions/forms'

render(
<Form.Handler
data={{
myDataPath: [
{ title: 'Foo!', value: 'foo' },
{ title: 'Bar!', value: 'bar' },
],
}}
>
<Field.ArraySelection dataPath="/myDataPath" />
</Form.Handler>,
)
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export const CompositionError = () => (
width="large"
>
<Field.String label="Field A" width="stretch" />
<Field.String label="Field B with a long label" width="medium" />
<Field.String
label="Field B with a long label that wraps"
width="medium"
/>
</Field.Composition>
</ComponentBox>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
showTabs: true
---

import PropertiesTable from 'dnb-design-system-portal/src/shared/parts/PropertiesTable'
import { OptionProperties } from '@dnb/eufemia/src/extensions/forms/Field/Option/OptionDocs'

## Properties

| Property | Type | Description |
| ---------- | -------------------- | --------------------------------------------- |
| `value` | `string` or `number` | _(optional)_ Value for this option. |
| `title` | `string` | _(optional)_ Text title for the option. |
| `text` | `string` | _(optional)_ Secondary text. |
| `children` | `React.Node` | _(optional)_ Optional way to provide `title`. |
<PropertiesTable props={OptionProperties} />
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ showTabs: true

`Field.Selection` is a component for selecting between options using a dropdown or similar user experiences.

[Field.Option](/uilib/extensions/forms/base-fields/Option/) is a related component.

There is a corresponding [Value.Selection](/uilib/extensions/forms/Value/Selection) component.

The [Field.Option](/uilib/extensions/forms/base-fields/Option/) is a related component.

```tsx
import { Field } from '@dnb/eufemia/extensions/forms'

render(
<Field.Selection placeholder="Select something...">
<Field.Option value="foo" title="Foo!" />
Expand All @@ -20,6 +21,25 @@ render(
)
```

You can also use the `dataPath` property to provide the data to the component:

```jsx
import { Field } from '@dnb/eufemia/extensions/forms'

render(
<Form.Handler
data={{
myDataPath: [
{ title: 'Foo!', value: 'foo' },
{ title: 'Bar!', value: 'bar' },
],
}}
>
<Field.Selection dataPath="/myDataPath" />
</Form.Handler>,
)
```

## About the Autocomplete variant

The autocomplete variant (`variant="autocomplete"`) is a special easy drop-in version – basically as an replacement for the Dropdown variant, but with a search capability.
Expand Down
Loading
Loading