menu
Channels
# All channels
view-forward
# General
view-forward
# Help me
view-forward
# Requests
view-forward
Team

Creating a Global Theme

May 29, 2020 at 2:44am

Creating a Global Theme

May 29, 2020 at 2:44am (Edited 2 months ago)
const headingFamily = 'Work Sans'
const textFamily = 'Work Sans'
const mainTheme = {
...defaultTheme,
typography: {
...defaultTheme.typography,
fontFamilies: {
display: headingFamily
ui: textFamily ,
mono: textFamily
},
headings: {
'100': {
...defaultTheme.typography.headings['100'],
fontFamily: headingFamily
},
'200': {
...defaultTheme.typography.headings['200'],
fontFamily: headingFamily
},
'300': {
...defaultTheme.typography.headings['300'],
fontFamily: headingFamily
},
'400': {
...defaultTheme.typography.headings['400'],
fontFamily: headingFamily
},
'500': {
...defaultTheme.typography.headings['500'],
fontFamily: headingFamily
},
'600': {
...defaultTheme.typography.headings['600'],
fontFamily: headingFamily
},
'700': {
...defaultTheme.typography.headings['700'],
fontFamily: headingFamily
},
'800': {
...defaultTheme.typography.headings['800'],
fontFamily: headingFamily
},
'900': {
...defaultTheme.typography.headings['900'],
fontFamily: headingFamily
}
},
text: {
'300': {
...defaultTheme.typography.text['300'],
fontFamily: textFamily
},
'400': {
...defaultTheme.typography.text['400'],
fontFamily: textFamily
},
'500': {
...defaultTheme.typography.text['500'],
fontFamily: textFamily
},
'600': {
...defaultTheme.typography.text['600'],
fontFamily: textFamily
}
}
}
console.log(defaultTheme.getFontFamily('ui'), mainTheme.getFontFamily('ui'))
the problem is this:
The final console.log always returns the defaultTheme fontfamily,

July 2, 2020 at 1:08pm
Encountering same issue.
  • reply
  • like

July 16, 2020 at 7:29pm
Theming is not really supported yet in v4. There are lots of sharp edges like the one you'e run into for seemingly simple theme configurations. In most cases you can get by after mutating the defaultTheme (yikes!) but this might not be possible for getFontFamily. We are going to be working on some major improvements to theming very soon though. Stay tuned!
  • reply
  • like