Skip to content

Commit 8f55d05

Browse files
committed
added toggle
1 parent 1f56272 commit 8f55d05

File tree

2 files changed

+62
-26
lines changed

2 files changed

+62
-26
lines changed

src/index.js

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
1-
import Button from './button';
2-
import Card from './card';
3-
import Checkbox from './checkbox';
4-
import CheckboxGroup from './checkboxGroup';
5-
6-
export default {
7-
Button,
8-
Card,
9-
Checkbox,
10-
CheckboxGroup,
11-
};
1+
// import Button from './button';
2+
// import Card from './card';
3+
// import Checkbox from './checkbox';
4+
// import CheckboxGroup from './checkboxGroup';
125

6+
// export default {
7+
// Button,
8+
// Card,
9+
// Checkbox,
10+
// CheckboxGroup,
11+
// };
12+
13+
import React from 'react';
14+
import ReactDOM from 'react-dom';
15+
import Toggle from './toggle';
16+
17+
class ToggleDisplay extends React.Component {
18+
constructor(props) {
19+
super(props);
20+
21+
this.state = {
22+
toggled: false,
23+
};
24+
}
25+
26+
handleToggle = () => {
27+
this.setState({
28+
toggled: !this.state.toggled,
29+
});
30+
}
31+
32+
render() {
33+
return (
34+
<Toggle
35+
toggled={this.state.toggled}
36+
onClick={this.handleToggle}
37+
/>
38+
);
39+
}
40+
}
41+
42+
ReactDOM.render(<ToggleDisplay />, document.getElementById('index'));

src/toggle/theme.scss

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
:local(.toggle) {
22
background-color: #ccc;
33
padding: 2px;
4+
display: inline-block;
5+
width: 60px;
6+
height: 35px;
7+
position: relative;
48
&:hover {
59
cursor: pointer;
610
}
711
input {
812
/* Disable the HTML input */
913
opacity: 0;
1014
}
15+
&:before {
16+
position: absolute;
17+
content: "";
18+
height: 70%;
19+
width: 35%;
20+
left: 10%;
21+
top: 15%;
22+
background-color: white;
23+
}
1124
}
1225

1326
:local(.toggled) {
14-
background-color: #2196F3 !important;
15-
height: 200px;
16-
position: relative;
17-
.toggle-item {
18-
/* Toggle item class */
19-
/* Builds a rectange with border width and rotates it 45 Degree */
27+
background-color: #2196F3;
28+
&:before {
2029
position: absolute;
21-
left: 30%;
22-
top: 10%;
23-
width: 5px;
24-
height: 10px;
25-
border: solid white;
26-
border-width: 0 3px 3px 0;
27-
-webkit-transform: rotate(45deg);
28-
-ms-transform: rotate(45deg);
29-
transform: rotate(45deg);
30+
content: "";
31+
height: 70%;
32+
width: 35%;
33+
left: 55%;
34+
top: 15%;
35+
background-color: white;
3036
}
3137
}

0 commit comments

Comments
 (0)