A pack of extensions for grommet 2
created:7/7/2021
updated:7/7/2021
loc
263
comments
3%
passed
6
failed
6
coverage
66%

Colors

avatar of atanasster

A color selection element, with custom color palettes.

Component

import { Colors } from 'grommet-controls';

Main

() => (
<Box direction="row">
<Box basis="medium">
<Colors
size="small"
onSelect={() => console.log('onSelect')}
colors={materialColors}
/>
</Box>
</Box>
)

Properties

Name
Description
Default
colors

Color palette for the user to choose a color from

object
-
color

The default selected color

string
-
onSelect

Called with an object containing the selected color, rowName and colorName

(props: { color: string; rowName: string; colorName: string; }) => void
-
size

What size to make it

mediumsmalllarge
medium
columns

The maximum number of colors per row, if left emty will be calculated automatically

number
-
wrap

If true, will wrap any rows of colors that exceed the columns limit, otherwise will truncate larger rows

boolean
-

Commits

Date
Author
Commit Message
8/31/2020

atanasster

avatar of atanasster
update stories titles and navigation
8/30/2020

atanasster

avatar of atanasster
update versions for publish
8/30/2020

atanasster

avatar of atanasster
update eslint and add component-controls
8/27/2019

atanasster

avatar of atanasster
initial commit 2.x alpha
4 commits

External dependencies

package
imports
peer
grommet
^2.15.0
KeyboardBox
*
normalizeColor
*
parseMetricToNum
*
react
^17.0.1
ReactComponent
*
react-dom
^17.0.1
findDOMNode
*
ThemeContext
*

Internal dependencies

file
imports
"./StyledColors"
StyledColorsStyledColorStyledColorContainerStyledRowStyledRows
"./ColorsProps"
IColorsProps

Component JSX

<StyledRow
keythemestyle
>
StyledRow
from"./StyledColors"
<StyledColorContainer
keytheme
>
StyledColorContainer
from"./StyledColors"
<ThemeContext.Consumer
>
<StyledColors
sizetheme
>
StyledColors
from"./StyledColors"

Stories

Colors

() => (
<Colors size="small" color="#ff0000" colors={uiColors} />
)

On Select

() => (
<Colors
size="small"
colors={basicColors}
onSelect={() => console.log('onSelect')}
/>
)

Size

() => (
<Box gap="small">
<Colors
size="small"
colors={{
blue,
blueGrey,
brown,
cyan,
deepOrange,
}}
/>
<Colors
size="medium"
columns={5}
colors={{
blue,
blueGrey,
brown,
cyan,
deepOrange,
}}
/>
<Colors
size="large"
columns={3}
colors={{
blue,
blueGrey,
brown,
cyan,
deepOrange,
}}
/>
</Box>
)

Columns

() => (
<Colors
size="small"
columns={5}
colors={{
blue,
blueGrey,
brown,
cyan,
deepOrange,
}}
/>
)

Wrap

() => (
<Colors
size="small"
columns={5}
wrap={true}
colors={{
blue,
blueGrey,
brown,
cyan,
deepOrange,
}}
/>
)