Skip to content

Instantly share code, notes, and snippets.

@Faliszek
Created October 22, 2018 22:01
Show Gist options
  • Save Faliszek/844ba4c8295619bac0cc4aac36f91f27 to your computer and use it in GitHub Desktop.
Save Faliszek/844ba4c8295619bac0cc4aac36f91f27 to your computer and use it in GitHub Desktop.
Gdzies w komopnencie
<Icon iconType="brand" name="spotify" />
Icon component:
function mappedTyped(i) {
return {
"brand": "fab"
}[i]
}
type Props = {
name: 'spotify' | 'inna ikona'
}
<i className={`${mappedType(props.iconType) fa-${props.name}`}
@baransu
Copy link

baransu commented Oct 22, 2018

type name = Spotify | Something

type iconType = Brand

let typeNameClassName = (iconType, name) => 
  switch(iconType, name) {
    (Brand, Spotify) => "fab fa-spotify"
    (Brand, Something) => "fab fa-spotify"
  }

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