@wedgekit/layout
v2.2.0
Published
@wedgkit/layout exports components that should be used to generate standard screen layouts that are approved by the design system.
Downloads
41
Maintainers
Keywords
Readme
Layout
@wedgkit/layout exports components that should be used to generate standard screen layouts that are approved by the design system.
Layout.App
Layout.App
consists of a layout with optional headers, drawers and notifications that match the design system.
Example
import Layout from '@wedgekit/layout';
import color from '@wedgekit/color';
import styled from 'styled-components';
const HeaderContainer = styled.div`
background: ${color.N700};
color: ${color.N050};
padding: 8px;
`;
const ResourceContainer = styled.div`
background: ${color.N200};
height: 50vh;
padding: 8px;
`;
const NotificationContainer = styled.div`
background: ${color.R100};
padding: 8px;
`;
const Example = () => {
return (
<Layout.App
header={<HeaderContainer>Header</HeaderContainer>}
resource={<ResourceContainer>Resource</ResourceContainer>}
notifications={<NotificationContainer>Notification</NotificationContainer>}
resourceMounted
resourceType="drawer"
drawerLeft
drawerWidth="10vw"
>
{() => <div style={{ padding: '40px' }}>Content</div>}
</Layout.App>
);
};
render(<Example />);
API
| Prop | Required | Type | Default | Description |
| --------------- | -------- | ------------------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| header | ❌ | JSX.Element
| null | An application header designed to be placed at the top of the app |
| notifications | ❌ | JSX.Element
| null | Notifications/Alerts components to be rendered below the header and above the rest of the content. |
| resource | ❌ | JSX.Element
| | A resource to be rendered when resourceMounted
is true
|
| resourceMounted | ❌ | boolean
| false | Whether or not the resource is mounted |
| resourceType | ❌ | 'drawer'/'drawer-overlay'/'drawer-unstyled'/'drawer-mobile'
| '' | The type of resource mounting the App will perform. The default drawer type will apply standard padding and scrolling. The overlay drawer will dim the rest of the screen act similarly to a modal. The unstyled drawer is similar to the default drawer with all styling removed (use this with render sticky action rows). The mobile drawer is best used in mobile applications. |
| drawerLeft | ❌ | boolean
| false | When true show the drawer on the left side of the screen |
| drawerWidth | ❌ | string
| | Custom size to set as the drawer width |
Layout.Grid
Layout.Grid
is a dynamic grid that can resize children components relative to the view window's dimension.
Usage
import Layout from '@wedgekit/layout';
import color from '@wedgekit/color';
const Example = () => {
return (
<>
<Layout.Grid
areas={['red blue green']}
rows={['20vh']}
areasLg={['red blue', 'green .']}
rowsLg={['20vh', '20vh']}
areasMd={['red', 'blue', 'green']}
rowsMd={['20vh', '20vh', '20vh']}
>
<Layout.Section area="red" style={{ background: 'red' }}>
Red
</Layout.Section>
<Layout.Section area="blue" style={{ background: 'blue' }}>
Blue
</Layout.Section>
<Layout.Section area="green" style={{ background: 'Green' }}>
green
</Layout.Section>
</Layout.Grid>
Shrink/Expand your browser to see the boxes arrange themselves.
</>
);
};
render(<Example />);
API
| Prop | Required | Type | Description |
| ------------ | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| areas | ✅ | Array<string>
| An array of grid-template-areas with each entry corresponding to a row |
| areasXl | ❌ | Array<string>
| An array of grid-template-areas which display above 1200px |
| areasLg | ❌ | Array<string>
| An array of grid-template-areas to display up to 1200px |
| areasMd | ❌ | Array<string>
| An array of grid-template-areas up to 992px |
| areasSm | ❌ | Array<string>
| An array of grid-template-areas up to 768px |
| areasXs | ❌ | Array<string>
| An array of grid-template-areas up to 576px |
| columns | ❌ | Array<string>
| An array of grid-template-columns with each entry corresponding to a column. Can accept a number (N) which as a column which will result in minmax(0, Nfr)
. If a string is provided the string will be directly applied with nothing added to it. |
| columnsXl | ❌ | Array<string>
| An array of grid-template-columns which display above 1200px |
| columnsLg | ❌ | Array<string>
| An array of grid-template-columns to display up to 1200px |
| columnsMd | ❌ | Array<string>
| An array of grid-template-columns up to 992px |
| columnsSm | ❌ | Array<string>
| An array of grid-template-columns up to 768px |
| columnsXs | ❌ | Array<string>
| An array of grid-template-columns up to 576px |
| rows | ❌ | Array<string>
| An array of grid-template-rows with each entry corresponding to a row |
| rowsXl | ❌ | Array<string>
| An array of grid-template-rows which display above 1200px |
| rowsLg | ❌ | Array<string>
| An array of grid-template-rows to display up to 1200px |
| rowsMd | ❌ | Array<string>
| An array of grid-template-rows up to 992px |
| rowsSm | ❌ | Array<string>
| An array of grid-template-rows up to 768px |
| rowsXs | ❌ | Array<string>
| An array of grid-template-rows up to 576px |
| justify | ❌ | string
| Passes in a justify-content setting |
| justifyItems | ❌ | string
| Passes in a justify-items setting |
| align | ❌ | string
| Passes in a align-items setting |
| place | ❌ | string
| Passes in a place-items setting |
| className | ❌ | string
| A string of the className to be applied to the Grid component |
| children | ✅ | JSX.Element
| |
Layout.Section
Layout.Section
is the dynamic child of a Layout.Grid
.
API
| Prop | Required | Type | Description | | ---- | -------- | ---- | ----------- |
| children | ✅ | JSX.Element
|
| area | ✅ | string
| The grid-template area to which this section belongs |
| ref | ❌ | React.Ref<HTMLDivElement>
| Optional ref for targeting the underlying HTML element |