mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-24 09:32:56 +00:00
change font-size to be a range input with quick example
This commit is contained in:
@@ -87,7 +87,7 @@ const createSettingsExtensions = (settings)=>[
|
|||||||
...(settings.fontSize
|
...(settings.fontSize
|
||||||
? [EditorView.theme({
|
? [EditorView.theme({
|
||||||
'&, .cm-content' : {
|
'&, .cm-content' : {
|
||||||
fontSize : `${settings.fontSize}px`,
|
fontSize : `${settings.fontSize || 1}em`,
|
||||||
},
|
},
|
||||||
})]
|
})]
|
||||||
: []),
|
: []),
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ const Editor = forwardRef(
|
|||||||
showImagePreviews : true,
|
showImagePreviews : true,
|
||||||
activeLineShading : true,
|
activeLineShading : true,
|
||||||
lineNumbers : true,
|
lineNumbers : true,
|
||||||
fontSize : 13,
|
fontSize : 1,
|
||||||
editorTheme : 'default',
|
editorTheme : 'default',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,7 @@ import React from 'react';
|
|||||||
const SettingsEditor = ({ settings, updateSettings = ()=>{}, EditorThemeNameList })=>{
|
const SettingsEditor = ({ settings, updateSettings = ()=>{}, EditorThemeNameList })=>{
|
||||||
|
|
||||||
const validations = {
|
const validations = {
|
||||||
fontSize : [
|
|
||||||
(value)=>{
|
|
||||||
const number = Number(value);
|
|
||||||
|
|
||||||
if(number < 9 || number > 30) {
|
|
||||||
return 'Font size must be between 9 and 30.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFieldChange = (setting, e)=>{
|
const handleFieldChange = (setting, e)=>{
|
||||||
@@ -129,12 +119,13 @@ const SettingsEditor = ({ settings, updateSettings = ()=>{}, EditorThemeNameList
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className='value'>
|
<div className='value'>
|
||||||
<small>from 9px to 30px</small>
|
<small style={{ fontSize: `${settings.fontSize || 1}em` }}>from 9px to 30px</small>
|
||||||
<input
|
<input
|
||||||
id='fontSize'
|
id='fontSize'
|
||||||
type='number'
|
type='range'
|
||||||
min={9}
|
min={.6}
|
||||||
max={30}
|
step={.1}
|
||||||
|
max={2}
|
||||||
name='fontSize'
|
name='fontSize'
|
||||||
value={settings.fontSize}
|
value={settings.fontSize}
|
||||||
onChange={(e)=>handleFieldChange('fontSize', e)}
|
onChange={(e)=>handleFieldChange('fontSize', e)}
|
||||||
|
|||||||
Reference in New Issue
Block a user