Skip to content

Instantly share code, notes, and snippets.

@CHH
Last active November 11, 2019 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CHH/dc25d4b6129fb92513acc44d618b44b2 to your computer and use it in GitHub Desktop.
Save CHH/dc25d4b6129fb92513acc44d618b44b2 to your computer and use it in GitHub Desktop.
<template functional>
<Component
:is="props.tag || ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'][props.level - 1]"
:ref="data.ref"
class="font-light leading-tight"
:class="{
'text-3xl sm:text-4xl md:text-5xl': (props.size || props.level) === 1,
'text-2xl sm:text-3xl md:text-4xl': (props.size || props.level) === 2,
'text-1xl sm:text-2xl md:text-3xl': (props.size || props.level) === 3,
'text-xl sm:text-1xl md:text-2xl': (props.size || props.level) >= 4,
[data.class]: typeof data.class !== 'undefined',
[data.staticClass]: typeof data.staticClass !== 'undefined',
}"
:style="[
data.style,
data.staticStyle,
]"
v-bind="data.attrs"
v-on="listeners"
>
<slot/>
</Component>
</template>
<template functional>
<Component
:is="props.tag || ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'][props.level - 1]"
:ref="data.ref"
class="font-light leading-tight"
:class="[
...((props.size || props.level) === 1 ? ['text-3xl sm:text-4xl md:text-5xl'] : []),
...((props.size || props.level) === 2 ? ['text-2xl sm:text-3xl md:text-4xl'] : []),
...((props.size || props.level) === 3 ? ['text-1xl sm:text-2xl md:text-3xl'] : []),
...((props.size || props.level) >= 4 ? ['text-xl sm:text-1xl md:text-2xl'] : []),
data.class,
data.staticClass,
]"
:style="[
data.style,
data.staticStyle,
]"
v-bind="data.attrs"
v-on="listeners"
>
<slot/>
</Component>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment