make font styling work

main
Mike Fix 6 years ago committed by Michael Fix
parent eae24c397a
commit f5fe38ea88

@ -117,14 +117,6 @@ class Carbon extends React.PureComponent {
<div className="alpha eliminateOnRender" /> <div className="alpha eliminateOnRender" />
<div className="bg" /> <div className="bg" />
</div> </div>
<style jsx global>
{`
@font-face {
font-family: ${config.fontUrl ? config.fontFamily : ''};
src: url(${config.fontUrl || ''}) format('woff');
}
`}
</style>
<style jsx> <style jsx>
{` {`
.container { .container {

@ -33,11 +33,10 @@ function FontSelect(props) {
updateFonts(fonts => [{ id: name, name, url }, ...fonts]) updateFonts(fonts => [{ id: name, name, url }, ...fonts])
props.onChange('fontFamily', name) props.onChange('fontFamily', name)
props.onChange('fontUrl', url)
} }
return ( return (
<> <div>
<ListSetting <ListSetting
title="Font" title="Font"
items={[{ id: 'upload', name: 'Upload +' }, ...fonts]} items={[{ id: 'upload', name: 'Upload +' }, ...fonts]}
@ -46,15 +45,30 @@ function FontSelect(props) {
> >
{Font} {Font}
</ListSetting> </ListSetting>
<input ref={inputEl} type="file" multiple accept={EXTENSIONS.join(',')} onChange={onFiles} /> <input
<style jsx> hidden
{` ref={inputEl}
input { type="file"
display: none; multiple
} accept={EXTENSIONS.join(',')}
`} onChange={onFiles}
</style> />
</> {fonts
.filter(font => font.url)
.map(font => (
<style jsx global key={font.id}>
{`
@font-face {
font-family: '${font.name}';
src: url(${font.url}) format('woff');
font-display: swap;
font-style: normal;
font-weight: 400;
}
`}
</style>
))}
</div>
) )
} }

Loading…
Cancel
Save