Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
fix(css-variables): improve robustness and developer warnings (#449)
Browse files Browse the repository at this point in the history
* fix(css-variables): improve robustness and developer warnings

* chore(eslint): remove unneeded env setting

* chore(css-variables): fix typo

* fix(css-variables): adjusted prop validator name

* fix(css-variables): stop using whitelistProps because it's overkill

* chore(eslint): remove redundant `propWrapperFunctions` config
  • Loading branch information
HendrikThePendric authored and varl committed Nov 7, 2019
1 parent 8c13d81 commit 92d1e38
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/CssVariables.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import propTypes from 'prop-types'
import propTypes from '@dhis2/prop-types'
import * as theme from './theme.js'

const toPrefixedThemeSection = themeSectionKey =>
Expand All @@ -22,10 +22,11 @@ const toCustomPropertyString = themeSection =>
* @example import { CssVariables } from @dhis2/ui-core
* @see Live demo: {@link /demo/?path=/story/cssvariables--default|Storybook}
*/
const CssVariables = props => {
const variables = Object.keys(props)
const CssVariables = ({ colors, theme, layers, spacers, elevations }) => {
const allowedProps = { colors, theme, layers, spacers, elevations }
const variables = Object.keys(allowedProps)
// Filter all props that are false
.filter(prop => props[prop])
.filter(prop => allowedProps[prop])
// Map props to corresponding theme section and prefixes keys with section name
.map(toPrefixedThemeSection)
// Map each section to a single string of css custom property declarations
Expand Down

0 comments on commit 92d1e38

Please sign in to comment.