Skip to content

Instantly share code, notes, and snippets.

@sairion
Last active April 9, 2016 17:47
Show Gist options
  • Save sairion/b2513f67bdf233d5e5f1188cc03f608a to your computer and use it in GitHub Desktop.
Save sairion/b2513f67bdf233d5e5f1188cc03f608a to your computer and use it in GitHub Desktop.
style-mixin.js
export const Display = {
None: { display: 'none' },
Block: { display: 'block' },
Inline: { display: 'inline' },
InlineBlock: { display: 'inline-block' },
NoneIf(cond) {
return cond ? Display.None : null;
},
BlockIf(cond) {
return cond ? Display.Block : null;
},
InlineIf(cond) {
return cond ? Display.Inline : null;
},
InlineBlockIf(cond) {
return cond ? Display.InlineBlock : null;
}
};
// <div style={Display.InlineIf(conditionMet)}> ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment