Skip to content

Commit

Permalink
feat(Layout): release new Layout component
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Sep 15, 2023
1 parent 3c92cef commit a12feac
Show file tree
Hide file tree
Showing 140 changed files with 3,170 additions and 2,122 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: 'Layout'
description: 'To make it easier to build application layout and form-views in line with defined design sketches, there are a number of components for layout.'
status: 'new'
theme: 'sbanken'
showTabs: true
tabs:
- title: Info
key: /info
- title: Demos
key: /demos
breadcrumb:
- text: Layout
href: /uilib/components/layout/
---

import LayoutInfo from 'Docs/uilib/components/layout/info'
import LayoutDemos from 'Docs/uilib/components/layout/demos'

<LayoutInfo />
<LayoutDemos />
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ tabs:
- title: Properties
key: '/properties'
breadcrumb:
- text: Forms
href: /uilib/extensions/forms/
- text: Layout
href: /uilib/extensions/forms/Layout/
href: /uilib/components/layout/
- text: Card
href: /uilib/extensions/forms/Layout/Card/
href: /uilib/components/layout/Card/
---

import Info from 'Docs/uilib/extensions/forms/Layout/Card/info'
import Demos from 'Docs/uilib/extensions/forms/Layout/Card/demos'
import Info from 'Docs/uilib/components/layout/Card/info'
import Demos from 'Docs/uilib/components/layout/Card/demos'

<Info />
<Demos />
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Layout } from '@dnb/eufemia/src'
import ComponentBox from '../../../../../shared/tags/ComponentBox'
import { Field } from '@dnb/eufemia/src/extensions/forms'

export const Default = () => {
return (
<ComponentBox>
<Layout.Card>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi
cursus pharetra elit in bibendum.
<br />
<br />
Praesent nunc ipsum, convallis eget convallis gravida, vehicula
vitae metus..
</Layout.Card>
</ComponentBox>
)
}

export const VerticalFields = () => {
return (
<ComponentBox scope={{ Field }}>
<Layout.Card>
<Layout.Vertical>
<Field.String label="Label" value="Value" />
<Field.String label="Label" value="Value" />
</Layout.Vertical>
</Layout.Card>
</ComponentBox>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import * as Examples from './Examples'

## Demo

### Default border

<Examples.Default />

## Widths
### Vertical fields

<Examples.Widths />
<Examples.VerticalFields />
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ showTabs: true

## Properties

| Property | Type | Description |
| ------------------------------------------- | ------------------- | --------------------------------------------------------------------------------------------- |
| `stack` | `boolean` | _(optional)_ True to stack the sub components with lines between. |
| `direction` | `string` | _(optional)_ Direction of sub components. Can be: `row` or `column`. |
| `spacing` | `string` or `false` | _(optional)_ How to separate sub components. Can be: `space`, `line` or `false` for no space. |
| `children` | `React.Node` | _(optional)_ Contents. |
| [Space](/uilib/components/space/properties) | Various | _(optional)_ Spacing properties like `top` or `bottom` are supported. |
| Property | Type | Description |
| ------------------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `stack` | `boolean` | _(optional)_ True to stack the sub components with lines between. |
| `direction` | `string` | _(optional)_ Direction of sub components. Can be: `horizontal` or `vertical`. |
| `spacing` | `string` or `false` | _(optional)_ How to separate sub components. Valid values as listed in [FlexContainer](/uilib/components/layout/FlexContainer/properties). |
| `children` | `React.Node` | _(optional)_ Contents. |
| [Space](/uilib/components/space/properties) | Various | _(optional)_ Spacing properties like `top` or `bottom` are supported. |
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import ComponentBox from '../../../../shared/tags/ComponentBox'
import { Layout } from '@dnb/eufemia/src'
import { TestElement, Field } from '@dnb/eufemia/src/extensions/forms'
import { defaultBreakpoints } from '@dnb/eufemia/src/shared/MediaQueryUtils'
import { defaultQueries } from '@dnb/eufemia/src/shared/useMedia'
import styled from '@emotion/styled'

export const colors = [
{ background: '#babeee' } as React.CSSProperties,
{ background: '#dfe0ee' } as React.CSSProperties,
{ background: '#90d2c3' } as React.CSSProperties,
{ background: '#ecf4be' } as React.CSSProperties,
]

export const HorizontalWithResponsiveFlexItem = () => {
return (
<ComponentBox scope={{ colors, TestElement, Field }}>
<Layout.FlexContainer direction="horizontal" wrap>
<Layout.FlexItem size={8}>
<TestElement style={colors[0]}>FlexItem (8)</TestElement>
</Layout.FlexItem>
<Layout.FlexItem size={4}>
<TestElement style={colors[1]}>FlexItem (4)</TestElement>
</Layout.FlexItem>
<Layout.FlexItem size={{ small: 12, medium: 4 }}>
<TestElement style={colors[2]}>
FlexItem (small: 8, medium: 4)
</TestElement>
</Layout.FlexItem>
<Layout.FlexItem size={{ small: 12, medium: 8 }}>
<TestElement style={colors[3]}>
FlexItem (small: 4, medium: 8)
</TestElement>
</Layout.FlexItem>
</Layout.FlexContainer>
</ComponentBox>
)
}

export const HorizontalWithResponsiveFlexItemCustomColumns = () => {
return (
<ComponentBox
scope={{
colors,
TestElement,
Field,
defaultBreakpoints,
defaultQueries,
}}
>
{() => {
const breakpoints = {
...defaultBreakpoints,
xsmall: '30em',
}

const queries = {
...defaultQueries,
xsmall: { min: 0, max: 'xsmall' },
small: { min: 'xsmall', max: 'small' },
}

const CustomMediaQuery = styled.div`
.dnb-layout__flex-container[data-media-key='xsmall']
.dnb-layout__flex-item--responsive {
--size: var(--xsmall);
}
`

return (
<CustomMediaQuery>
<Layout.FlexContainer
direction="horizontal"
wrap
columns={4}
breakpoints={breakpoints}
queries={queries}
>
<Layout.FlexItem size={{ small: 2, medium: 3, large: 1 }}>
<TestElement style={colors[0]}>FlexItem</TestElement>
</Layout.FlexItem>
<Layout.FlexItem size={{ small: 2, medium: 1, large: 2 }}>
<TestElement style={colors[1]}>FlexItem</TestElement>
</Layout.FlexItem>
<Layout.FlexItem
size={{ xsmall: 4, small: 2, medium: 1, large: 1 }}
>
<TestElement style={colors[2]}>FlexItem</TestElement>
</Layout.FlexItem>
<Layout.FlexItem
size={{ xsmall: 4, small: 2, medium: 3, large: 4 }}
>
<TestElement style={colors[3]}>FlexItem</TestElement>
</Layout.FlexItem>
</Layout.FlexContainer>
</CustomMediaQuery>
)
}}
</ComponentBox>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ tabs:
- title: Properties
key: '/properties'
breadcrumb:
- text: Forms
href: /uilib/extensions/forms/
- text: Layout
href: /uilib/extensions/forms/Layout/
href: /uilib/components/layout/
- text: FieldContainer
href: /uilib/extensions/forms/Layout/FieldContainer/
href: /uilib/components/layout/FieldContainer/
---

import Info from 'Docs/uilib/extensions/forms/Layout/FlexContainer/info'
import Demos from 'Docs/uilib/extensions/forms/Layout/FlexContainer/demos'
import Info from 'Docs/uilib/components/layout/FlexContainer/info'
import Demos from 'Docs/uilib/components/layout/FlexContainer/demos'

<Info />
<Demos />
Loading

0 comments on commit a12feac

Please sign in to comment.