Skip to content

Commit 0b773fa

Browse files
viankakrisnaCompuIves
authored andcommitted
Add/preferences/line height (codesandbox#86)
* add preferences for line height * add style and step to PreferenceNumber * remove editors from preferences label
1 parent 9823f84 commit 0b773fa

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/app/components/Preference/PreferenceNumber.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ export default class PreferenceInput extends React.PureComponent {
2424
};
2525

2626
render() {
27-
const { value } = this.props;
27+
const { value, style, step } = this.props;
2828
return (
2929
<StyledInput
30-
style={{ width: '3rem' }}
30+
step={step}
31+
style={{ width: '3rem', ...style }}
3132
type="number"
3233
value={value}
3334
onChange={this.handleChange}

src/app/components/sandbox/CodeEditor/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const CodeContainer = styled.div`
5454
.CodeMirror {
5555
font-family: ${props =>
5656
fontFamilies(props.fontFamily, 'Source Code Pro', 'monospace')};
57+
line-height: ${props => props.lineHeight};
5758
background: ${theme.background2()};
5859
color: #e0e0e0;
5960
height: 100%;
@@ -475,7 +476,10 @@ export default class CodeEditor extends React.PureComponent {
475476
title={title}
476477
path={modulePath}
477478
/>
478-
<CodeContainer fontFamily={preferences.fontFamily}>
479+
<CodeContainer
480+
fontFamily={preferences.fontFamily}
481+
lineHeight={preferences.lineHeight}
482+
>
479483
<div
480484
style={{ height: '100%', fontSize: preferences.fontSize || 14 }}
481485
ref={this.getCodeMirror}

src/app/containers/Preferences/EditorPageSettings/EditorSettings/Preferences.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,26 @@ const Preferences = ({ preferences, preferencesActions }: Props) => {
6565
/>
6666
<Rule />
6767
<PaddedPreference
68-
title="Editor font size"
68+
title="Font size"
6969
type="number"
7070
{...bindValue('fontSize')}
7171
/>
7272
<Rule />
7373
<PaddedPreference
74-
title="Editor font family"
74+
title="Font family"
7575
type="string"
7676
placeholder="Source Code Pro"
7777
{...bindValue('fontFamily')}
7878
/>
79+
<Rule />
80+
<PaddedPreference
81+
title="Line height"
82+
type="number"
83+
placeholder="1.15"
84+
step="0.05"
85+
style={{ width: '4rem' }}
86+
{...bindValue('lineHeight')}
87+
/>
7988
</PreferenceContainer>
8089
</Container>
8190
);

src/app/store/preferences/reducer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const initialState: Preferences = Object.keys(keys).reduce(
3030
instantPreviewEnabled: false,
3131
fontSize: 14,
3232
fontFamily: '',
33+
lineHeight: 1.15,
3334
clearConsoleEnabled: false,
3435
prettierConfig: DEFAULT_PRETTIER_CONFIG,
3536
},

0 commit comments

Comments
 (0)