Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/components/Canvas/Sections/FontSizes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
>
<p
class="mb-2 leading-none text-gray-900 dark:text-gray-500"
:style="{
fontSize: getFontSizeValue(value)
}"
:style="getFontSizeValue(value)"
>
{{ data.typographyExample }}
</p>
<CanvasBlockLabel
:label="`text-${prop}`"
:value="getFontSizeValue(value)"
:value="getFontSizeString(value)"
/>
</div>
</div>
Expand Down Expand Up @@ -57,10 +55,18 @@ export default {
getFontSizeValue (value) {
// Tailwind 2.0 returns font size as array with size and line height
if (Array.isArray(value)) {
return value[0]
return {
fontSize: value[0],
...value[1]
}
}

return value
return {
fontSize: value
}
},
getFontSizeString (value) {
return Object.values(this.getFontSizeValue(value)).join(', ')
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ export const remToPx = (rem, config) => {
export const appendPxToRems = (rem, config) => {
if (rem.search('rem') === -1) return rem

return `${rem} (${remToPx(rem, config)}px)`
return rem.replaceAll(/(\d|\.)*rem/g, (value) => {
return `${value} (${remToPx(value, config)}px)`
})
}