0.5.0 • Published 3 years ago

@vtex/admin-primitives v0.5.0

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

Primitives

NPM

Primitives are polymorphic components

Getting started

This package is already a part of admin-ui - so if you are using it, there is no need for installation.

For standalone usage, you can install it as an npm package (with its peer dependencies):

yarn add @vtex/admin-primitives @vtex/admin-core reakit @emotion/css @emotion/react

After that, you must add the admin-core's ThemeProvider on your app root - so that you can consume styles.

import { Flex } from '@vtex/admin-primitives'

function ApplicationRoot() {
  return <Flex>A flex container</Flex>
}

Engineering

csx prop

This prop is present in all components and is responsible for receiving a style-object. More info Styles

<Primitive csx={{ bg: 'blue', color: 'light.primary' }}>Blue box</Primitive>s

Polymorphism

All primitives are polymorphic, this means that you can assign different elements to them through the element property.

The default element is the div, this is true to every component:

<Primitive>renders a div</Primitive>

You can choose the element to render:

<Primitive element="a" href="#">
  renders an anchor
</Primitive>

You can also pass a valid React component (it must receive className so that styles are passed correctly):

import { Link } from 'gatsby'

function Example() {
  return <Primitive element={Link}>Gatsby link</Primitive>
}

Types

PrimitiveProps

proptyperequireddescription
elementE🚫Element that will be rendered
classNamestring🚫element className
extends <E>props of E🚫This component inherits all props of E

FlexProps

proptyperequireddescription
EPrimitiveProps<E>🚫Extends all props of Primitive
alignResponsiveValue<AlignContent>🚫Shorthand for CSS alignItems property
basisResponsiveValue<FlexBasis>🚫Shorthand for CSS flexbasis property
directionResponsiveValue<FlexDirection>🚫Shorthand for CSS flexDirection property
growResponsiveValue<FlexGrow>🚫Shorthand for CSS flexGrow property
shrinkResponsiveValue<FlexShrink>🚫Shorthand for CSS flexShrink property
justifyResponsiveValue<JustifyContent>🚫Shorthand for CSS justifyContent property
wrapResponsiveValue<FlexWrap>🚫Shorthand for CSS flexWrap property
orderResponsiveValue<Order>🚫Shorthand for CSS order property

FlexSpacerProps

proptyperequireddescription
EPrimitiveProps<E>🚫Extends all props of Primitive

GridProps

proptyperequireddescription
EPrimitiveProps<E>🚫Extends all props of Primitive
gapResponsiveValue<GridGap>🚫Shorthand for CSS gridGap property
rowGapResponsiveValue<GridRowGap>🚫Shorthand for CSS gridRowGap property
columnGapResponsiveValue<GridColumnGap>🚫Shorthand for CSS gridColumnGap property
templateAreasstring[]🚫Shorthand for CSS gridTemplateAreas property
templateRowsResponsiveValue<GridTemplateRows>🚫Shorthand for CSS gridTemplateRows property
templateColumnsResponsiveValue<GridTemplateColumns>🚫Shorthand for CSS gridTemplateColumns property

GridItemProps

proptyperequireddescription
EPrimitiveProps<E>🚫Extends all props of Primitive
areaResponsiveValue<GridArea>🚫Shorthand for CSS gridArea property
0.5.0

3 years ago

0.5.0-alpha.0

3 years ago

0.4.12

3 years ago

0.4.10

3 years ago

0.4.11

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.1

3 years ago

0.2.2

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago