ijunseong

Update: add play & pause icon

1 -.chanel { 1 +.channel__list {
2 + display: flex;
3 + flex-grow: 1;
4 + flex-direction: column;
5 + flex: 0.3;
6 + min-width: 500px;
7 + height: 100vh;
8 + color: white;
9 + background-color: #0e0e0e;
10 + box-sizing: border-box;
11 +}
12 +
13 +.channel__list__title {
14 + display: flex;
15 + padding: 25px;
16 + width: 30vw;
17 + min-width: 500px;
18 + background-color: #0e0e0e;
19 + font-size: 20px;
20 + font-weight: bold;
21 + position: fixed;
22 + box-sizing: border-box;
23 +}
24 +
25 +.channel__list > ul {
26 + list-style: none;
27 + overflow: auto;
28 + padding-top: 50px;
29 +}
30 +
31 +.channel__list > ul > li > hr {
32 + border: 2px solid #282828;
33 +}
34 +
35 +.channel {
2 display: flex; 36 display: flex;
3 align-items: center; 37 align-items: center;
4 flex-direction: row; 38 flex-direction: row;
5 - padding-left: 10px;
6 height: 100px; 39 height: 100px;
7 - background-color: #0e0e10; 40 + background-color: #0e0e0e;
8 - padding-left: 10px;
9 } 41 }
10 42
11 -.chanel__url { 43 +.channel__url {
12 display: flex; 44 display: flex;
13 align-items: center; 45 align-items: center;
14 flex-grow: 1; 46 flex-grow: 1;
...@@ -20,82 +52,59 @@ ...@@ -20,82 +52,59 @@
20 padding-bottom: 20px; 52 padding-bottom: 20px;
21 } 53 }
22 54
23 -.chanel__box { 55 +.channel__box {
24 display: flex; 56 display: flex;
57 + flex-basis: 80%;
25 flex-direction: row; 58 flex-direction: row;
26 justify-content: space-between; 59 justify-content: space-between;
27 } 60 }
28 61
29 -.chanel__box > input { 62 +.channel__thumbnail {
30 - margin-right: 10px; 63 + height: 25px;
64 + width: 25px;
65 + border-radius: 70%;
66 + overflow: hidden;
67 + margin-right: 30px;
68 + background-color: white;
69 +}
70 +
71 +.channel__icon {
72 + height: 25px;
73 + width: 25px;
74 + border-radius: 70%;
75 + overflow: hidden;
76 + margin-right: 30px;
31 } 77 }
32 78
33 -.chanel__info { 79 +.channel__info {
34 - width: 5vw; 80 + flex-basis: 70%;
35 margin-right: 20px; 81 margin-right: 20px;
36 } 82 }
37 83
38 -.chanel__name { 84 +.channel__name {
39 align-content: center; 85 align-content: center;
40 font-size: 16px; 86 font-size: 16px;
41 } 87 }
42 88
43 -.chanel__game { 89 +.channel__game {
44 font-size: 12px; 90 font-size: 12px;
45 color: gray; 91 color: gray;
46 } 92 }
47 93
48 -.chanel__view { 94 +.channel__view {
49 - margin-left: 15px;
50 - margin-right: 5px;
51 - width: 4vw;
52 text-align: right; 95 text-align: right;
53 } 96 }
54 97
55 -.chanel__thumbnail { 98 +.play__icon {
56 - height: 25px; 99 + margin-left: 10px;
57 - width: 25px; 100 + margin-right: 10px;
58 - border-radius: 70%;
59 - overflow: hidden;
60 - margin-right: 30px;
61 - background-color: white;
62 } 101 }
63 102
64 -.chanel__icon { 103 +.pause__icon {
65 - height: 25px; 104 + margin-left: 10px;
66 - width: 25px; 105 + margin-right: 10px;
67 - border-radius: 70%;
68 - overflow: hidden;
69 - margin-right: 30px;
70 } 106 }
71 107
72 108
73 -.chanel__list {
74 - display: flex;
75 - flex-grow: 1;
76 - flex-direction: column;
77 - flex: 0.2;
78 - padding-right: 10px;
79 - min-width: 300px;
80 - height: 100vh;
81 - color: white;
82 - background-color: #0e0e10;
83 -}
84 109
85 -.chanel__list > ul {
86 - list-style: none;
87 - overflow: auto;
88 - padding-top: 50px;
89 -}
90 -
91 -.chanel__list > ul > li > hr {
92 - border: 2px solid #282828;
93 -}
94 110
95 -.chanel__list > strong {
96 - padding: 25px;
97 - width: 17%;
98 - background-color: #0e0e0e;
99 - font-size: 20px;
100 - position: fixed;
101 -}
...\ No newline at end of file ...\ No newline at end of file
......
1 import React from "react"; 1 import React from "react";
2 -import "./Chanel.css"; 2 +import "./Channel.css";
3 import "@material-ui/icons" 3 import "@material-ui/icons"
4 import PersonIcon from "@material-ui/icons/Person"; 4 import PersonIcon from "@material-ui/icons/Person";
5 import PlayArrowIcon from '@material-ui/icons/PlayArrow'; 5 import PlayArrowIcon from '@material-ui/icons/PlayArrow';
6 -import StopIcon from '@material-ui/icons/Stop';
7 import PauseIcon from '@material-ui/icons/Pause'; 6 import PauseIcon from '@material-ui/icons/Pause';
7 +import { WatchOutlined } from "@material-ui/icons";
8 8
9 -export function Chanel(props) { 9 +export function Channel(props) {
10 - const chanel = props.chanel; 10 + const channel = props.channel;
11 11
12 return ( 12 return (
13 - <div className="chanel"> 13 + <div className="channel">
14 - <a href={chanel.url} className="chanel__url"> 14 + <a href={channel.url} className="channel__url">
15 - {chanel.thumbnail && <img className="chanel__thumbnail" src={chanel.thumbnail} alt=""></img>} 15 + {channel.thumbnail && <img className="channel__thumbnail" src={channel.thumbnail} alt=""></img>}
16 - {!chanel.thumbnail && <PersonIcon className="chanel__icon"/>} 16 + {!channel.thumbnail && <PersonIcon className="channel__icon"/>}
17 - <div className="chanel__box"> 17 + <div className="channel__box">
18 - <div className="chanel__info"> 18 + <div className="channel__info">
19 - <div className="chanel__name">{chanel.name}</div> 19 + <div className="channel__name">{channel.name}</div>
20 - <div className="chanel__game">{chanel.game}</div> 20 + <div className="channel__game">{channel.game}</div>
21 </div> 21 </div>
22 - <div className="chanel__view">{chanel.view}</div> 22 + <div className="channel__view">{channel.view}</div>
23 - <input type="radio" name="chanel"></input>
24 </div> 23 </div>
25 -
26 </a> 24 </a>
25 + {channel.isPlay && <PauseIcon className="pause__icon" onClick={props.onClick} />}
26 + {!channel.isPlay && <PlayArrowIcon className="play__icon" onClick={props.onClick} />}
27 </div> 27 </div>
28 ); 28 );
29 } 29 }
30 30
31 -export class ChanelList extends React.Component { 31 +export class ChannelList extends React.Component {
32 - 32 + constructor(props) {
33 - 33 + super(props);
34 - render() { 34 +
35 // data for test 35 // data for test
36 const test = [ 36 const test = [
37 {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"}, 37 {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"},
...@@ -46,20 +46,61 @@ export class ChanelList extends React.Component { ...@@ -46,20 +46,61 @@ export class ChanelList extends React.Component {
46 {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"}, 46 {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"},
47 ] 47 ]
48 48
49 - const chanels = test; 49 + this.state = {
50 + channels: test,
51 + xisPlaying: null,
52 + }
53 + }
54 +
55 + changeState(channel, index){
56 + const channels = this.state.channels;
57 + // 버튼을 누른 채널이 재생중일때
58 + if (channel.isPlay === true) {
59 + channels[index].isPlay = false;
60 + this.setState({
61 + channels: channels,
62 + xisPlaying: null,
63 + });
64 + }
50 65
66 + // 버튼을 누른 채널이 재생중이 아닐 때
67 + else {
68 + // xisPlaying이 null이 아닐 때
69 + if (this.state.xisPlaying !== null) {
70 + // 기존에 재생되던 채널의 isPlay를 false로, 클릭 이벤트가 발생한 채널의 isPlay를 true로 변경
71 + channels[this.state.xisPlaying].isPlay = false;
72 + channels[index].isPlay = true;
73 + }
74 +
75 + // xisPlaying이 null일 때
76 + else {
77 + channels[index].isPlay = true;
78 + }
79 +
80 + this.setState({
81 + channels: channels,
82 + xisPlaying: index,
83 + });
84 + }
85 + }
86 +
87 + render() {
51 return ( 88 return (
52 - <div className="chanel__list"> 89 + <div className="channel__list">
53 - <strong>CHANELS</strong> 90 + <div className="channel__list__title"> CHANNEL LIST</div>
54 <ul> 91 <ul>
55 - {chanels.map((chanel) => ( 92 + {this.state.channels.map((channel, index) => (
56 - <li> 93 + <li key={index}>
57 - <Chanel chanel={chanel}/> 94 + <Channel
95 + channel={channel}
96 + onClick={ () => this.changeState(channel, index)}
97 + />
58 <hr /> 98 <hr />
59 </li> 99 </li>
60 ))} 100 ))}
61 </ul> 101 </ul>
62 </div> 102 </div>
103 +
63 ); 104 );
64 } 105 }
65 } 106 }
...\ No newline at end of file ...\ No newline at end of file
......