Skip to content

Commit 4490f27

Browse files
committed
Set style for code UAST toggle switch
Signed-off-by: Carlos Martín <[email protected]>
1 parent 0d79ca8 commit 4490f27

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"react-helmet": "^5.2.0",
1515
"react-scripts": "1.1.4",
1616
"react-split-pane": "^0.1.77",
17+
"react-switch": "^3.0.4",
1718
"react-table": "^6.8.2",
1819
"uast-viewer": "^0.0.4"
1920
},

frontend/src/components/CodeViewer.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Modal } from 'react-bootstrap';
33
import PropTypes from 'prop-types';
44
import SplitPane from 'react-split-pane';
55
import UASTViewer, { Editor, withUASTEditor } from 'uast-viewer';
6+
import Switch from 'react-switch';
67
import api from '../api';
78
import './CodeViewer.less';
89

@@ -145,14 +146,21 @@ class CodeViewer extends Component {
145146
<Modal.Header closeButton>
146147
<Modal.Title>
147148
CODE
148-
<label>
149-
<input
150-
type="checkbox"
151-
checked={showUast}
152-
onChange={this.handleShowUastChange}
153-
disabled={!language}
154-
/>UAST
155-
</label>
149+
<Switch
150+
checked={showUast}
151+
onChange={this.handleShowUastChange}
152+
disabled={!language}
153+
checkedIcon={<span className="switch-text checked">UAST</span>}
154+
uncheckedIcon={
155+
<span className="switch-text unchecked">UAST</span>
156+
}
157+
onColor="#ffba34"
158+
offColor="#e1e1e1"
159+
width={100}
160+
handleDiameter={20}
161+
className="code-toggler"
162+
aria-label="Toggle UAST view"
163+
/>
156164
</Modal.Title>
157165
</Modal.Header>
158166
<Modal.Body>

frontend/src/components/CodeViewer.less

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import '../variables.less';
2+
13
.code-viewer {
24
position: relative;
35
height: 100%;
@@ -21,3 +23,22 @@
2123
.editor-pane {
2224
height: 100%;
2325
}
26+
27+
.code-toggler {
28+
margin-left: 40px;
29+
30+
.switch-text {
31+
font-size: 18px;
32+
font-weight: @btn-font-weight;
33+
}
34+
35+
.switch-text.checked {
36+
color: @btn-gbpl-tertiary-color;
37+
padding-left: 28px;
38+
}
39+
40+
.switch-text.unchecked {
41+
color: #979797;
42+
margin-left: -29px;
43+
}
44+
}

frontend/yarn.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5944,6 +5944,12 @@ react-style-proptype@^3.0.0:
59445944
dependencies:
59455945
prop-types "^15.5.4"
59465946

5947+
react-switch@^3.0.4:
5948+
version "3.0.4"
5949+
resolved "https://registry.yarnpkg.com/react-switch/-/react-switch-3.0.4.tgz#52958b2736b4d21b4f0050997955c5365019ca7b"
5950+
dependencies:
5951+
prop-types "^15.6.1"
5952+
59475953
react-table@^6.8.2:
59485954
version "6.8.2"
59495955
resolved "https://registry.yarnpkg.com/react-table/-/react-table-6.8.2.tgz#3a5aefabc85953300d16786fa307c30610db9adc"

0 commit comments

Comments
 (0)