Skip to content

default variant#5

Open
ahmetkuslular wants to merge 1 commit into
styled-components:masterfrom
ahmetkuslular:default-variant
Open

default variant#5
ahmetkuslular wants to merge 1 commit into
styled-components:masterfrom
ahmetkuslular:default-variant

Conversation

@ahmetkuslular

Copy link
Copy Markdown
  • If the variant sent does not match, the default variant usage is added

Comment thread index.js
return function(props) {
var variant = props[prop] && values[props[prop]];
return variant && getThemeValue(name, props, variant);
var defaultVariant = props[prop] && values['default'];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that there is 'default' key in the variants object. In few use cases we may not be having 'default' as one of the item in the list of variants. In such case, I suggest to use the first item from the list of variants as a fallback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants