mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-24 17:03:47 +01:00
feat: adjust code editor font size (#2204)
* add font-size setting for code editor * add code font size to remaining editors * align font-size after font-family * changed default font size to 14 * fixed className typo * set inherit mode if unset * add code font size schema validation * add font size to folder settings --------- Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
parent
682c7bd1b1
commit
ee7f886c03
@ -5,6 +5,7 @@ const StyledWrapper = styled.div`
|
|||||||
background: ${(props) => props.theme.codemirror.bg};
|
background: ${(props) => props.theme.codemirror.bg};
|
||||||
border: solid 1px ${(props) => props.theme.codemirror.border};
|
border: solid 1px ${(props) => props.theme.codemirror.border};
|
||||||
font-family: ${(props) => (props.font ? props.font : 'default')};
|
font-family: ${(props) => (props.font ? props.font : 'default')};
|
||||||
|
font-size: ${(props) => (props.fontSize ? `${props.fontSize}px` : 'inherit')};
|
||||||
line-break: anywhere;
|
line-break: anywhere;
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
}
|
}
|
||||||
|
@ -333,6 +333,7 @@ export default class CodeEditor extends React.Component {
|
|||||||
className="h-full w-full flex flex-col relative"
|
className="h-full w-full flex flex-col relative"
|
||||||
aria-label="Code Editor"
|
aria-label="Code Editor"
|
||||||
font={this.props.font}
|
font={this.props.font}
|
||||||
|
fontSize={this.props.fontSize}
|
||||||
ref={(node) => {
|
ref={(node) => {
|
||||||
this._node = node;
|
this._node = node;
|
||||||
}}
|
}}
|
||||||
|
@ -46,6 +46,7 @@ const Docs = ({ collection }) => {
|
|||||||
onSave={onSave}
|
onSave={onSave}
|
||||||
mode="application/text"
|
mode="application/text"
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Markdown collectionPath={collection.pathname} onDoubleClick={toggleViewMode} content={docs} />
|
<Markdown collectionPath={collection.pathname} onDoubleClick={toggleViewMode} content={docs} />
|
||||||
|
@ -52,6 +52,7 @@ const Script = ({ collection }) => {
|
|||||||
mode="javascript"
|
mode="javascript"
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-1 mt-6">
|
<div className="flex-1 mt-6">
|
||||||
@ -64,6 +65,7 @@ const Script = ({ collection }) => {
|
|||||||
mode="javascript"
|
mode="javascript"
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ const Tests = ({ collection }) => {
|
|||||||
mode="javascript"
|
mode="javascript"
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
|
@ -47,6 +47,7 @@ const Documentation = ({ item, collection }) => {
|
|||||||
collection={collection}
|
collection={collection}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
value={docs || ''}
|
value={docs || ''}
|
||||||
onEdit={onEdit}
|
onEdit={onEdit}
|
||||||
onSave={onSave}
|
onSave={onSave}
|
||||||
|
@ -54,6 +54,7 @@ const Script = ({ collection, folder }) => {
|
|||||||
mode="javascript"
|
mode="javascript"
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col flex-1 mt-2 gap-y-2">
|
<div className="flex flex-col flex-1 mt-2 gap-y-2">
|
||||||
@ -66,6 +67,7 @@ const Script = ({ collection, folder }) => {
|
|||||||
mode="javascript"
|
mode="javascript"
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ const Tests = ({ collection, folder }) => {
|
|||||||
mode="javascript"
|
mode="javascript"
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="mt-6">
|
<div className="mt-6">
|
||||||
|
@ -9,17 +9,25 @@ const Font = ({ close }) => {
|
|||||||
const preferences = useSelector((state) => state.app.preferences);
|
const preferences = useSelector((state) => state.app.preferences);
|
||||||
|
|
||||||
const [codeFont, setCodeFont] = useState(get(preferences, 'font.codeFont', 'default'));
|
const [codeFont, setCodeFont] = useState(get(preferences, 'font.codeFont', 'default'));
|
||||||
|
const [codeFontSize, setCodeFontSize] = useState(get(preferences, 'font.codeFontSize', '14'));
|
||||||
|
|
||||||
const handleInputChange = (event) => {
|
const handleCodeFontChange = (event) => {
|
||||||
setCodeFont(event.target.value);
|
setCodeFont(event.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCodeFontSizeChange = (event) => {
|
||||||
|
// Restrict to min/max value
|
||||||
|
const clampedSize = Math.max(1, Math.min(event.target.value, 32));
|
||||||
|
setCodeFontSize(clampedSize);
|
||||||
|
};
|
||||||
|
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
dispatch(
|
dispatch(
|
||||||
savePreferences({
|
savePreferences({
|
||||||
...preferences,
|
...preferences,
|
||||||
font: {
|
font: {
|
||||||
codeFont
|
codeFont,
|
||||||
|
codeFontSize
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
).then(() => {
|
).then(() => {
|
||||||
@ -29,17 +37,33 @@ const Font = ({ close }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledWrapper>
|
<StyledWrapper>
|
||||||
<label className="block font-medium">Code Editor Font</label>
|
<div className="flex flex-row gap-2 w-full">
|
||||||
<input
|
<div className="w-4/5">
|
||||||
type="text"
|
<label className="block font-medium">Code Editor Font</label>
|
||||||
className="block textbox mt-2 w-full"
|
<input
|
||||||
autoComplete="off"
|
type="text"
|
||||||
autoCorrect="off"
|
className="block textbox mt-2 w-full"
|
||||||
autoCapitalize="off"
|
autoComplete="off"
|
||||||
spellCheck="false"
|
autoCorrect="off"
|
||||||
onChange={handleInputChange}
|
autoCapitalize="off"
|
||||||
defaultValue={codeFont}
|
spellCheck="false"
|
||||||
/>
|
onChange={handleCodeFontChange}
|
||||||
|
defaultValue={codeFont}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="w-1/5">
|
||||||
|
<label className="block font-medium">Font Size</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
className="block textbox mt-2 w-full"
|
||||||
|
autoComplete="off"
|
||||||
|
autoCorrect="off"
|
||||||
|
inputMode="numeric"
|
||||||
|
onChange={handleCodeFontSizeChange}
|
||||||
|
defaultValue={codeFontSize}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="mt-10">
|
<div className="mt-10">
|
||||||
<button type="submit" className="submit btn btn-sm btn-secondary" onClick={handleSave}>
|
<button type="submit" className="submit btn btn-sm btn-secondary" onClick={handleSave}>
|
||||||
|
@ -31,6 +31,7 @@ const GraphQLRequestPane = ({ item, collection, leftPaneWidth, onSchemaLoad, tog
|
|||||||
: get(item, 'request.body.graphql.variables');
|
: get(item, 'request.body.graphql.variables');
|
||||||
const { displayedTheme } = useTheme();
|
const { displayedTheme } = useTheme();
|
||||||
const [schema, setSchema] = useState(null);
|
const [schema, setSchema] = useState(null);
|
||||||
|
const preferences = useSelector((state) => state.app.preferences);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onSchemaLoad(schema);
|
onSchemaLoad(schema);
|
||||||
@ -71,6 +72,8 @@ const GraphQLRequestPane = ({ item, collection, leftPaneWidth, onSchemaLoad, tog
|
|||||||
onRun={onRun}
|
onRun={onRun}
|
||||||
onEdit={onQueryChange}
|
onEdit={onQueryChange}
|
||||||
onClickReference={handleGqlClickReference}
|
onClickReference={handleGqlClickReference}
|
||||||
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ const GraphQLVariables = ({ variables, item, collection }) => {
|
|||||||
value={variables || ''}
|
value={variables || ''}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
onEdit={onEdit}
|
onEdit={onEdit}
|
||||||
mode="javascript"
|
mode="javascript"
|
||||||
onRun={onRun}
|
onRun={onRun}
|
||||||
|
@ -4,6 +4,8 @@ const StyledWrapper = styled.div`
|
|||||||
div.CodeMirror {
|
div.CodeMirror {
|
||||||
background: ${(props) => props.theme.codemirror.bg};
|
background: ${(props) => props.theme.codemirror.bg};
|
||||||
border: solid 1px ${(props) => props.theme.codemirror.border};
|
border: solid 1px ${(props) => props.theme.codemirror.border};
|
||||||
|
font-family: ${(props) => (props.font ? props.font : 'default')};
|
||||||
|
font-size: ${(props) => (props.fontSize ? `${props.fontSize}px` : 'inherit')};
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +211,8 @@ export default class QueryEditor extends React.Component {
|
|||||||
<StyledWrapper
|
<StyledWrapper
|
||||||
className="h-full w-full flex flex-col relative"
|
className="h-full w-full flex flex-col relative"
|
||||||
aria-label="Query Editor"
|
aria-label="Query Editor"
|
||||||
|
font={this.props.font}
|
||||||
|
fontSize={this.props.fontSize}
|
||||||
ref={(node) => {
|
ref={(node) => {
|
||||||
this._node = node;
|
this._node = node;
|
||||||
}}
|
}}
|
||||||
|
@ -50,6 +50,7 @@ const RequestBody = ({ item, collection }) => {
|
|||||||
collection={collection}
|
collection={collection}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
value={bodyContent[bodyMode] || ''}
|
value={bodyContent[bodyMode] || ''}
|
||||||
onEdit={onEdit}
|
onEdit={onEdit}
|
||||||
onRun={onRun}
|
onRun={onRun}
|
||||||
|
@ -47,6 +47,7 @@ const Script = ({ item, collection }) => {
|
|||||||
value={requestScript || ''}
|
value={requestScript || ''}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
onEdit={onRequestScriptEdit}
|
onEdit={onRequestScriptEdit}
|
||||||
mode="javascript"
|
mode="javascript"
|
||||||
onRun={onRun}
|
onRun={onRun}
|
||||||
@ -60,6 +61,7 @@ const Script = ({ item, collection }) => {
|
|||||||
value={responseScript || ''}
|
value={responseScript || ''}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
onEdit={onResponseScriptEdit}
|
onEdit={onResponseScriptEdit}
|
||||||
mode="javascript"
|
mode="javascript"
|
||||||
onRun={onRun}
|
onRun={onRun}
|
||||||
|
@ -34,6 +34,7 @@ const Tests = ({ item, collection }) => {
|
|||||||
value={tests || ''}
|
value={tests || ''}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
onEdit={onEdit}
|
onEdit={onEdit}
|
||||||
mode="javascript"
|
mode="javascript"
|
||||||
onRun={onRun}
|
onRun={onRun}
|
||||||
|
@ -81,6 +81,7 @@ const QueryResultPreview = ({
|
|||||||
<CodeEditor
|
<CodeEditor
|
||||||
collection={collection}
|
collection={collection}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
onRun={onRun}
|
onRun={onRun}
|
||||||
value={formattedData}
|
value={formattedData}
|
||||||
|
@ -53,6 +53,7 @@ const CodeView = ({ language, item }) => {
|
|||||||
collection={collection}
|
collection={collection}
|
||||||
value={snippet}
|
value={snippet}
|
||||||
font={get(preferences, 'font.codeFont', 'default')}
|
font={get(preferences, 'font.codeFont', 'default')}
|
||||||
|
fontSize={get(preferences, 'font.codeFontSize')}
|
||||||
theme={displayedTheme}
|
theme={displayedTheme}
|
||||||
mode={lang}
|
mode={lang}
|
||||||
/>
|
/>
|
||||||
|
@ -23,7 +23,8 @@ const defaultPreferences = {
|
|||||||
timeout: 0
|
timeout: 0
|
||||||
},
|
},
|
||||||
font: {
|
font: {
|
||||||
codeFont: 'default'
|
codeFont: 'default',
|
||||||
|
codeFontSize: 14
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@ -54,7 +55,8 @@ const preferencesSchema = Yup.object().shape({
|
|||||||
timeout: Yup.number()
|
timeout: Yup.number()
|
||||||
}),
|
}),
|
||||||
font: Yup.object().shape({
|
font: Yup.object().shape({
|
||||||
codeFont: Yup.string().nullable()
|
codeFont: Yup.string().nullable(),
|
||||||
|
codeFontSize: Yup.number().min(1).max(32).nullable()
|
||||||
}),
|
}),
|
||||||
proxy: Yup.object({
|
proxy: Yup.object({
|
||||||
enabled: Yup.boolean(),
|
enabled: Yup.boolean(),
|
||||||
|
Loading…
Reference in New Issue
Block a user