0.6.4 • Published 3 months ago

@highlight-ui/layout v0.6.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

npm storybook.personio.design

@highlight-ui/layout

Layout components are used to manage the white space between components and other elements. They produce visual consistency across Personio products by using a limited set of standardised spacing tokens. This also removes the hassle of space-management from the user.

Features

  • Vertical spacing
    • Controlled by spacing tokens
  • Horizontal spacing
    • Controlled by spacing tokens
    • Horizontal and vertical alignment based on flex values
    • Toggle to allow wrapping

Installation

Using npm:

npm install @highlight-ui/layout

Using yarn:

yarn add @highlight-ui/layout

Using pnpm:

pnpm install @highlight-ui/layout

Remember to import the styles in your (S)CSS file, like so:

@import url('@highlight-ui/layout');

Usage

Stack

The Stack component manages the vertical spacing between elements.

In your TypeScript file:

import { Stack, StackProps } from '@highlight-ui/layout';
<Stack space="spacing-4">
  <Placeholder>Item 1</Placeholder>
  <Placeholder>Item 2</Placeholder>
  <Placeholder>Item 3</Placeholder>
</Stack>

Props 📜

PropTypeRequiredDefaultDescription
spaceSpacingTypeNospacing-0The spacing applied to the children.
classNamestringNonullClassname to apply to the element.
metadataComponentMetadataNonullObject used for testing. Contains testId and actionName.
childrenReact.ReactNodeNonullComponents to apply spacing between.

Inline

The Inline component manages the horizontal spacing between elements. In addition to this, this component can also control the alignment of the items (both vertically and horizontally).

In your TypeScript file:

import { Inline, InlineProps } from '@highlight-ui/layout';
<Inline space="spacing-4" align="center">
  <Placeholder>Item 1</Placeholder>
  <Placeholder>Item 2</Placeholder>
  <Placeholder>Item 3</Placeholder>
  <Placeholder>Item 4</Placeholder>
  <Placeholder>Item 5</Placeholder>
</Inline>

Props 📜

PropTypeRequiredDefaultDescription
spaceSpacingTypeNospacing-0The spacing applied to the children.
alignHorizontalAlignmentTypeNostartHorizontal alignment of the items.
alignVerticalVerticalAlignmentTypeNostartVertical alignment of the items.
wrapbooleanNofalseWhether to wrap the items when their width exceeds the container width.
classNamestringNonullClassname to apply to the element.
metadataComponentMetadataNonullObject used for testing. Contains testId and actionName.
childrenReact.ReactNodeNonullComponents to apply spacing between.

Shared types

TypeValues
SpacingTypespacing-0, spacing-0-5, spacing-1, spacing-2, spacing-3, spacing-4, spacing-5, spacing-6, spacing-8, spacing-10, spacing-12, spacing-16, spacing-20, spacing-24, spacing-32
HorizontalAlignmentTypestart, center, end, space-between, space-around, space-evenly
VerticalAlignmentTypestart, center, end, baseline, stretch

Testing

This example serves as starting point on how you can use these layout components as part of your tests.

Certain props are already defined in the renderInline (or renderStack) method, to reuse through individual tests. Any props can be overriden by passing these to the above function.

const testId = 'test-inline';
const metadata = { testId };

function renderInline(props?: Partial<InlineProps>) {
  render(
    <Inline {...props} metadata={metadata}>
      <p>Item 1</p>
      <p>Item 2</p>
    </Inline>,
  );
  return screen.getByTestId(testId);
}

Place in design system 💻

These layout components are not yet used within the highlight-ui library. They are still being develiped to be initially used within the following organisms:

Contributing 🖌️

If you're interested in contributing, please visit our contribution page.

0.6.4

3 months ago

0.6.3

5 months ago

0.5.10

7 months ago

0.5.8

7 months ago

0.4.9

10 months ago

0.5.7

8 months ago

0.4.8

10 months ago

0.5.9

7 months ago

0.4.10

9 months ago

0.4.11

9 months ago

0.4.12

9 months ago

0.5.4

8 months ago

0.4.5

10 months ago

0.6.2

7 months ago

0.5.3

8 months ago

0.4.4

10 months ago

0.5.6

8 months ago

0.4.7

10 months ago

0.6.0-r18.0

8 months ago

0.5.5

8 months ago

0.4.6

10 months ago

0.5.0

9 months ago

0.6.1

7 months ago

0.5.2

9 months ago

0.4.3

10 months ago

0.6.0

7 months ago

0.5.1

9 months ago

0.4.2

10 months ago

0.3.0

1 year ago

0.4.1

1 year ago

0.2.3

1 year ago

0.4.0

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago