Skip to content

Commit 5c2c51a

Browse files
committed
➕ Make different styles depending on platform
1 parent 6fd65a5 commit 5c2c51a

File tree

25 files changed

+377
-105
lines changed

25 files changed

+377
-105
lines changed

src/scripts/components/App.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Header from "./Header";
44
import Content from "./Content";
55
import Footer from "./Footer";
66
import EditorForumlaPopup from "./Editor/Formula";
7+
import { getPlatform } from "../utils/PlatformUtils";
78

89
class App extends PureComponent {
910
state = {
@@ -31,7 +32,7 @@ class App extends PureComponent {
3132
}
3233

3334
render() {
34-
const theme = className("app", "qilin-panel", {
35+
const theme = className("app", "qilin-panel", `is-${getPlatform()}`, {
3536
"is-light": !this.state.isThemeToggled,
3637
"is-dark": this.state.isThemeToggled,
3738
});

src/scripts/components/Header.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ class Header extends PureComponent {
3434
}
3535

3636
render() {
37-
const themeIcon = className("qilin-button-icon", {
37+
const themeButton = className("qilin-button", {
3838
"is-active": this.props.isThemeToggled,
3939
});
4040

41-
const forumlaIcon = className("qilin-button-icon", {
41+
const formulaButton = className("qilin-button", {
4242
"is-active": this.props.isFormulaToggled,
4343
});
4444

45-
const previewIcon = className("qilin-button-icon", {
45+
const previewButton = className("qilin-button", {
4646
"is-active": this.props.isPreviewToggled,
4747
});
4848

@@ -59,16 +59,16 @@ class Header extends PureComponent {
5959
</div>
6060

6161
<div className="app-header-buttons">
62-
<button className="qilin-button" onClick={this.props.toggleTheme} role="menuitem">
63-
<ReactSVG className={themeIcon} path={require("../../images/icons/menu/theme.svg")} />
62+
<button className={themeButton} onClick={this.props.toggleTheme} role="menuitem">
63+
<ReactSVG className="qilin-button-icon" path={require("../../images/icons/menu/theme.svg")} />
6464
</button>
6565

66-
<button className="qilin-button" onClick={this.props.toggleFormula} role="menuitem">
67-
<ReactSVG className={forumlaIcon} path={require("../../images/icons/menu/formula.svg")} />
66+
<button className={formulaButton} onClick={this.props.toggleFormula} role="menuitem">
67+
<ReactSVG className="qilin-button-icon" path={require("../../images/icons/menu/formula.svg")} />
6868
</button>
6969

70-
<button className="qilin-button" onClick={this.props.togglePreview} role="menuitem">
71-
<ReactSVG className={previewIcon} path={require("../../images/icons/menu/preview.svg")} />
70+
<button className={previewButton} onClick={this.props.togglePreview} role="menuitem">
71+
<ReactSVG className="qilin-button-icon" path={require("../../images/icons/menu/preview.svg")} />
7272
</button>
7373
</div>
7474
</div>

src/scripts/utils/PlatformUtils.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os from "os";
2+
3+
export function getPlatform() {
4+
switch (os.platform()) {
5+
case "android":
6+
return "android";
7+
case "win32":
8+
return "windows";
9+
case "darwin":
10+
return "darwin";
11+
default:
12+
return "linux";
13+
}
14+
}

src/styles/components/_app.scss

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77

88
&-header {
99
display: grid;
10+
grid-template-areas: "a b c";
1011
grid-template-columns: 1fr auto 1fr;
1112

12-
align-items: center;
13-
justify-content: center;
14-
15-
height: 50px;
13+
height: auto;
1614
width: 100vw;
1715

1816
-webkit-app-region: drag;
@@ -23,20 +21,6 @@
2321
display: flex;
2422
outline: none;
2523
}
26-
27-
&-controls {
28-
justify-self: start;
29-
}
30-
31-
&-title {
32-
justify-self: center;
33-
}
34-
35-
&-buttons {
36-
justify-self: end;
37-
38-
margin: 0 11px;
39-
}
4024
}
4125

4226
&-content {
@@ -51,7 +35,7 @@
5135

5236
.is-preview-hidden {
5337
.Pane1 { width: 100% !important; }
54-
.Pane2 { width: 0 !important; }
38+
.Pane2 { width: 0 !important; }
5539
}
5640
}
5741
}

src/styles/components/_controls.scss

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
.controls-container {
2-
display: flex;
3-
4-
margin: 0 18px;
5-
padding: 0;
2+
display: grid;
3+
grid-template-areas: "a b c";
4+
grid-template-columns: auto auto auto;
65

76
.control-close,
87
.control-maximize,
98
.control-minimize {
109
content: "";
1110

12-
width: 14px;
13-
height: 14px;
14-
15-
margin: 0 10px 0 0;
16-
padding: 0;
17-
1811
outline: none;
1912
transition: all 100ms ease;
2013

src/styles/components/_editor-preview.scss

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,20 @@
77

88
padding: 1rem;
99
margin: 0;
10+
11+
pre {
12+
margin: 1rem 0;
13+
padding: .5rem;
14+
15+
overflow-x: scroll;
16+
overflow-y: scroll;
17+
18+
code {
19+
padding: 0;
20+
margin: 0;
21+
22+
// Resizing bug:
23+
width: 0;
24+
}
25+
}
1026
}

src/styles/components/qilin/_button.scss

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,26 @@
33
align-items: center;
44
justify-content: center;
55

6-
min-width: 26px;
7-
min-height: 20px;
8-
9-
margin: 7px;
10-
11-
border-width: 0;
12-
border-radius: 4px;
13-
border-style: solid;
6+
border: none;
7+
outline: none;
8+
cursor: pointer;
149

1510
overflow-x: hidden;
1611
overflow-y: hidden;
1712

18-
outline: none;
19-
cursor: pointer;
20-
2113
-webkit-appearance: none;
2214
-webkit-app-region: no-drag;
2315

16+
transition: all 100ms ease;
17+
2418
&.is-big {
2519
padding: .5rem 1rem;
2620
}
2721

2822
&-icon {
29-
height: 14px;
23+
height: 15px;
3024
width: auto;
3125

32-
transition: all 300ms ease;
26+
transition: all 100ms ease;
3327
}
3428
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.app {
2+
&-header {
3+
height: 50px;
4+
5+
&-controls,
6+
&-buttons,
7+
&-title {
8+
justify-content: center;
9+
align-items: center;
10+
}
11+
12+
&-buttons {
13+
margin: 0 11px;
14+
}
15+
16+
&-controls { grid-area: a; justify-self: start; }
17+
&-buttons { grid-area: c; justify-self: end; }
18+
&-title { grid-area: b; justify-self: center; }
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.controls-container {
2+
margin: 0 18px;
3+
padding: 0;
4+
5+
.control-close,
6+
.control-maximize,
7+
.control-minimize {
8+
width: 14px;
9+
height: 14px;
10+
11+
margin: 0 10px 0 0;
12+
padding: 0;
13+
}
14+
15+
.control-close { grid-area: a; }
16+
.control-minimize { grid-area: b; }
17+
.control-maximize { grid-area: c; }
18+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.qilin-button {
2+
min-width: 25px;
3+
min-height: 20px;
4+
5+
margin: 7px;
6+
}

0 commit comments

Comments
 (0)