Showing
8 changed files
with
110 additions
and
7 deletions
src/components/Side.js
0 → 100644
1 | +import { useContext } from "react"; | ||
2 | +import { CalendarStateContext } from "../pages/Calendar"; | ||
3 | +import "../styles/Side.css"; | ||
4 | +import SideSubject from "./SideSubject"; | ||
5 | + | ||
6 | +const Side = () => { | ||
7 | + const { subs, setSubs } = useContext(CalendarStateContext); | ||
8 | + | ||
9 | + const renderSubs = () => { | ||
10 | + const sideSubjects = []; | ||
11 | + | ||
12 | + for (let i = 0; i < subs.length; i++) { | ||
13 | + sideSubjects.push( | ||
14 | + <SideSubject key={i} subject={subs[i]} setSubs={setSubs} /> | ||
15 | + ); | ||
16 | + } | ||
17 | + | ||
18 | + return sideSubjects; | ||
19 | + }; | ||
20 | + | ||
21 | + return <aside>{renderSubs()}</aside>; | ||
22 | +}; | ||
23 | + | ||
24 | +export default Side; |
src/components/SideSubject.js
0 → 100644
1 | +const SideSubject = ({ subject }) => { | ||
2 | + let isChecked = false; | ||
3 | + const defaultColor = "#EFEFEF"; | ||
4 | + const bgc = "background-color"; | ||
5 | + | ||
6 | + const check = (e) => { | ||
7 | + if (isChecked) e.target.style["background-color"] = defaultColor; | ||
8 | + else e.target.style["background-color"] = subject.color; | ||
9 | + isChecked = !isChecked; | ||
10 | + }; | ||
11 | + | ||
12 | + return ( | ||
13 | + <div className="SideSubject"> | ||
14 | + <div | ||
15 | + className="ssc" | ||
16 | + onClick={check} | ||
17 | + style={{ | ||
18 | + [bgc]: isChecked ? subject.color : defaultColor, | ||
19 | + }} | ||
20 | + ></div> | ||
21 | + | ||
22 | + <span>{subject.name}</span> | ||
23 | + </div> | ||
24 | + ); | ||
25 | +}; | ||
26 | + | ||
27 | +export default SideSubject; |
1 | header { | 1 | header { |
2 | background-color: rgba(255, 255, 255, 1); | 2 | background-color: rgba(255, 255, 255, 1); |
3 | display: flex; | 3 | display: flex; |
4 | - padding: 8px; | 4 | + margin-bottom: 12px; |
5 | justify-content: space-between; | 5 | justify-content: space-between; |
6 | align-items: center; | 6 | align-items: center; |
7 | } | 7 | } |
8 | 8 | ||
9 | .hl { | 9 | .hl { |
10 | - padding-right: 50px; | 10 | + padding-right: 100px; |
11 | } | 11 | } |
12 | 12 | ||
13 | .hls { | 13 | .hls { |
... | @@ -42,8 +42,8 @@ header { | ... | @@ -42,8 +42,8 @@ header { |
42 | } | 42 | } |
43 | 43 | ||
44 | .hrd { | 44 | .hrd { |
45 | - margin-right: 10px; | 45 | + margin-right: 12px; |
46 | - margin-left: 10px; | 46 | + margin-left: 12px; |
47 | } | 47 | } |
48 | 48 | ||
49 | .hrd > button { | 49 | .hrd > button { | ... | ... |
src/styles/Home.css
deleted
100644 → 0
File mode changed
src/styles/Side.css
0 → 100644
1 | +aside { | ||
2 | + width: 250px; | ||
3 | + margin-right: 8px; | ||
4 | + padding-top: 50px; | ||
5 | +} | ||
6 | + | ||
7 | +.SideSubject { | ||
8 | + height: 25px; | ||
9 | + padding: 5px; | ||
10 | + display: flex; | ||
11 | +} | ||
12 | + | ||
13 | +.ssc { | ||
14 | + height: 15px; | ||
15 | + width: 15px; | ||
16 | + margin: 5px 10px 5px 5px; | ||
17 | + border: solid thin grey; | ||
18 | + border-radius: 3px; | ||
19 | +} |
1 | +html, | ||
1 | body { | 2 | body { |
3 | + width: 100%; | ||
4 | + height: 100%; | ||
2 | margin: 0; | 5 | margin: 0; |
3 | - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | 6 | + padding: 0; |
4 | - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | 7 | +} |
8 | + | ||
9 | +body { | ||
10 | + overflow: hidden; | ||
11 | + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", | ||
12 | + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", | ||
5 | sans-serif; | 13 | sans-serif; |
6 | -webkit-font-smoothing: antialiased; | 14 | -webkit-font-smoothing: antialiased; |
7 | -moz-osx-font-smoothing: grayscale; | 15 | -moz-osx-font-smoothing: grayscale; |
8 | } | 16 | } |
9 | 17 | ||
10 | code { | 18 | code { |
11 | - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | 19 | + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", |
12 | monospace; | 20 | monospace; |
13 | } | 21 | } | ... | ... |
-
Please register or login to post a comment