Skip to content

Commit 147f199

Browse files
committed
add font-size in preferences
1 parent b956d01 commit 147f199

File tree

11 files changed

+123
-17
lines changed

11 files changed

+123
-17
lines changed

images/minus.svg

Lines changed: 12 additions & 0 deletions
Loading

images/plus.svg

Lines changed: 12 additions & 0 deletions
Loading

shared/components/Editor/Editor.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@ class Editor extends React.Component {
1717
this._cm.on('change', () => {
1818
this.props.updateFile("sketch.js", this._cm.getValue());
1919
});
20-
console.log('test here');
20+
this._cm.getWrapperElement().style['font-size'] = this.props.fontSize+'px';
2121
}
2222

2323
componentDidUpdate(prevProps) {
2424
if (this.props.content !== prevProps.content &&
2525
this.props.content !== this._cm.getValue()) {
2626
this._cm.setValue(this.props.content);
2727
}
28+
if (this.props.fontSize !== prevProps.fontSize) {
29+
this._cm.getWrapperElement().style['font-size'] = this.props.fontSize+'px';
30+
}
2831
}
2932

3033
componentWillUnmount() {

shared/components/Preferences/Preferences.jsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React from 'react';
22

33
var Isvg = require('react-inlinesvg');
44
var exitUrl = require('../../../images/exit.svg');
5+
var plusUrl = require('../../../images/plus.svg');
6+
var minusUrl = require('../../../images/minus.svg');
57
var classNames = require('classnames');
68

79
class Preferences extends React.Component {
@@ -12,10 +14,22 @@ class Preferences extends React.Component {
1214
});
1315
return (
1416
<div className={preferencesContainerClass} tabindex="0">
15-
<div className="preferences__title-text">Preferences</div>
16-
<button className="preferences__exit-button" onClick={this.props.closePreferences}>
17-
<Isvg src={exitUrl} alt="Exit Preferences" />
18-
</button>
17+
<div className="preferences__heading">
18+
<h2 className="preferences__title-text">Preferences</h2>
19+
<button className="preferences__exit-button" onClick={this.props.closePreferences}>
20+
<Isvg src={exitUrl} alt="Exit Preferences" />
21+
</button>
22+
</div>
23+
<div className="preference">
24+
<h3 className="preference__title-text">Font Size</h3>
25+
<button className="preferences__plus-button" onClick={this.props.decreaseFont}>
26+
<Isvg src={minusUrl} alt="Decrease Font Size" />
27+
</button>
28+
<p className="preference__value">{this.props.fontSize}</p>
29+
<button className="preferences__minus-button" onClick={this.props.increaseFont}>
30+
<Isvg src={plusUrl} alt="Increase Font Size" />
31+
</button>
32+
</div>
1933
</div>
2034
);
2135
}

shared/containers/App/App.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ class App extends React.Component {
2222
/>
2323
<Preferences
2424
isPreferencesShowing = {this.props.preferences.isPreferencesShowing}
25-
closePreferences={this.props.closePreferences}/>
25+
closePreferences={this.props.closePreferences}
26+
increaseFont={this.props.increaseFont}
27+
decreaseFont={this.props.decreaseFont}
28+
fontSize={this.props.preferences.fontSize}/>
2629
<Editor
2730
content={this.props.file.content}
28-
updateFile={this.props.updateFile} />
31+
updateFile={this.props.updateFile}
32+
fontSize={this.props.preferences.fontSize} />
2933
<PreviewFrame
3034
content={this.props.file.content}
3135
head={

shared/redux/actions/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,15 @@ export function closePreferences() {
3737
type: ActionTypes.CLOSE_PREFERENCES
3838
}
3939
}
40+
41+
export function increaseFont() {
42+
return {
43+
type: ActionTypes.INCREASE_FONTSIZE
44+
}
45+
}
46+
47+
export function decreaseFont() {
48+
return {
49+
type: ActionTypes.DECREASE_FONTSIZE
50+
}
51+
}

shared/redux/constants/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ export const STOP_SKETCH = 'STOP_SKETCH';
66

77
export const OPEN_PREFERENCES = 'OPEN_PREFERENCES';
88
export const CLOSE_PREFERENCES = 'CLOSE_PREFERENCES';
9+
export const INCREASE_FONTSIZE = 'INCREASE_FONTSIZE';
10+
export const DECREASE_FONTSIZE = 'DECREASE_FONTSIZE';

shared/redux/reducers/preferences.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
import * as ActionTypes from '../constants/constants';
22

33
const initialState = {
4-
isPreferencesShowing: false
4+
isPreferencesShowing: false,
5+
fontSize: 18
56
}
67

78
const preferences = (state = initialState, action) => {
89
switch (action.type) {
910
case ActionTypes.OPEN_PREFERENCES:
1011
return {
11-
isPreferencesShowing: true
12+
isPreferencesShowing: true,
13+
fontSize: state.fontSize
1214
}
1315
case ActionTypes.CLOSE_PREFERENCES:
1416
return {
15-
isPreferencesShowing: false
17+
isPreferencesShowing: false,
18+
fontSize: state.fontSize
19+
}
20+
case ActionTypes.INCREASE_FONTSIZE:
21+
return {
22+
isPreferencesShowing: state.isPreferencesShowing,
23+
fontSize: state.fontSize+2
24+
}
25+
case ActionTypes.DECREASE_FONTSIZE:
26+
return {
27+
isPreferencesShowing: state.isPreferencesShowing,
28+
fontSize: state.fontSize-2
1629
}
1730
default:
1831
return state

styles/components/_editor.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
}
1818

1919
.CodeMirror-line {
20-
padding-left: #{5 / $base-font-size}rem;
21-
}
20+
padding-left: #{5 / $base-font-size}rem;
21+
}

styles/components/_preferences.scss

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
background-color: $light-preferences-background-color;
33
display: none;
44
font-family: 'Montserrat', sans-serif;
5+
padding-bottom: #{20 / $base-font-size}rem;
56
&--selected {
67
display: flex;
8+
flex-direction: column;
79
}
810
}
911

@@ -17,11 +19,44 @@
1719
}
1820
}
1921

20-
.preferences__title-text {
22+
.preferences__plus-button {
23+
@extend %preferences-button;
24+
margin-right: auto;
25+
}
26+
27+
.preferences__minus-button {
28+
@extend %preferences-button;
29+
}
30+
31+
.preferences__heading {
32+
display: flex;
33+
flex-direction: rows;
2134
margin-left: #{20 / $base-font-size}rem;
22-
font-size: $menu-font-size;
35+
}
36+
.preferences__title-text {
37+
margin: 0 0;
38+
font-size: #{$menu-font-size}px;
2339
font-weight: 700;
24-
font-color: white;
2540
height: #{44 / $base-font-size}rem;
2641
line-height: #{44 / $base-font-size}rem;
2742
}
43+
44+
.preference {
45+
margin: 0 #{20 / $base-font-size}rem;
46+
}
47+
48+
.preference__title-text {
49+
margin: 0 0;
50+
font-size: #{$base-font-size}px;
51+
font-weight: 400;
52+
height: #{44 / $base-font-size}rem;
53+
line-height: #{44 / $base-font-size}rem;
54+
}
55+
56+
.preference__value {
57+
@extend %button;
58+
border-radius: 0%;
59+
border: 2px solid $light-preferences-button-color;
60+
line-height: #{44 / $base-font-size}rem;
61+
margin: 0 #{20 / $base-font-size}rem;
62+
}

styles/layout/_ide.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
}
2020

2121
.preferences {
22-
width: 30%;
23-
height: 50%;
22+
width: 22.5%;
2423
position: absolute;
2524
top: #{20 / $base-font-size}rem;
2625
right:#{60 / $base-font-size}rem;

0 commit comments

Comments
 (0)