Chanel.js 2.98 KB
import React from "react";
import "./Chanel.css";
import "@material-ui/icons"
import PersonIcon from "@material-ui/icons/Person";
import PlayArrowIcon from '@material-ui/icons/PlayArrow';
import StopIcon from '@material-ui/icons/Stop';
import PauseIcon from '@material-ui/icons/Pause';

export function Chanel(props) {
    const chanel = props.chanel;

    return (
        <div className="chanel">
            <a href={chanel.url} className="chanel__url">
                {chanel.thumbnail && <img className="chanel__thumbnail" src={chanel.thumbnail} alt=""></img>}
                {!chanel.thumbnail && <PersonIcon className="chanel__icon"/>}
                <div className="chanel__box">
                    <div className="chanel__info">
                        <div className="chanel__name">{chanel.name}</div>
                        <div className="chanel__game">{chanel.game}</div>
                    </div>
                    <div className="chanel__view">{chanel.view}</div>
                    <input type="radio" name="chanel"></input>
                </div>
                
            </a>
        </div>
    );
}

export class ChanelList extends React.Component {
    

    render() {
        // data for test
        const test = [
            {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"},
            {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"},
            {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"},
            {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"},
            {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"},
            {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"},
            {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"},
            {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"},
            {"name": "name1", "view": 999, "game": "game1" ,"url": "https://www.twitch.tv", "thumbnail": "https://upload.wikimedia.org/wikipedia/commons/2/26/Twitch_logo.svg"},
            {"name": "name2", "view": 123124124, "game": "game2" , "url": "https://www.twitch.tv"},
        ]

        const chanels = test;

        return (
            <div className="chanel__list">
                <strong>CHANELS</strong>
                <ul>
                {chanels.map((chanel) => (
                    <li>
                        <Chanel chanel={chanel}/>
                        <hr />
                    </li>
                ))}
                </ul>
            </div>
        );
    }
}