Skip to content

Instantly share code, notes, and snippets.

@0xtruly
Last active January 16, 2019 13:45
Show Gist options
  • Select an option

  • Save 0xtruly/9f201749b13fa6cedc8964783a3dcd4e to your computer and use it in GitHub Desktop.

Select an option

Save 0xtruly/9f201749b13fa6cedc8964783a3dcd4e to your computer and use it in GitHub Desktop.

Revisions

  1. 0xtruly revised this gist Jan 16, 2019. 2 changed files with 47 additions and 85 deletions.
    85 changes: 0 additions & 85 deletions 2ndHome.jsx
    Original file line number Diff line number Diff line change
    @@ -1,85 +0,0 @@
    import React, { Component } from 'react';
    import { Link } from 'react-router-dom';
    import styled from 'styled-components';
    import axios from 'axios';
    import { Grid, Column } from './Grid';
    import MusicBg from '../../assets/music-bg.jpeg';
    import MusicList from './MusicList';
    import Footer from './Footer';
    import Container from './Container';
    import Form from './Form';
    const HomeStyle = styled.div`
    header, footer{
    text-align: center;
    }
    main{
    margin: 20px 0;
    }
    `;

    const Header = styled.header`
    padding: 70px 20px;
    background: linear-gradient(rgba(0, 0, 0, .7), rgba(0, 0, 0, .7)), url(${MusicBg});
    background-size: cover;
    background-position: center;
    color: #fff;
    `;

    class Home extends Component {
    constructor() {
    super();
    this.state = {
    tracks: [],
    // store: [],
    // ready: 'initial',
    };
    }
    componentDidMount() {
    this.setState({
    ready: 'loading',
    });
    // axios({
    // method: 'get',
    // url: `${process.env.HOST}/artists`,
    // headers: `${process.env.API_KEY}`,
    // })
    axios.get('https://api.deezer.com/artist/27/top?e9d874c859b7133d36df9b5bcd38512d')
    .then(json => console.log(json.data.artist))
    // .then(({ data: { data } }) => {
    // this.setState({
    // ready: 'loaded',
    // tracks: data,
    // })
    // })
    }
    render() {
    const { tracks, ready } = this.state;
    return (
    <HomeStyle>
    <Header>
    <h1>Soundio</h1>
    <p>The Music Hub</p>
    <Form />
    </Header>
    <main>
    <Container>
    <Grid>
    { tracks.data ? '' : 'There are no sound clips ' }
    { ready === 'loading' ? 'Loading...' : '' }
    { tracks.map(tracks => (
    <Column columns="3" key={tracks.id}>
    <MusicList image={tracks.data.artist.picture ? charts.artists.Icon[0].url:''} preview={tracks.preview}>
    <h3><Link to={`/tracks/${tracks.id}`}>{tracks.artist.name}</Link></h3>
    </MusicList>
    </Column>
    )) }
    </Grid>
    </Container>
    </main>
    <Footer />
    </HomeStyle>
    );
    }
    }

    export default Home;
    47 changes: 47 additions & 0 deletions Result.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    class Result extends Component {
    constructor(props){
    super(props);
    this.state = {
    song: {},
    ready: 'initial'
    }
    }
    componentDidMount() {
    const {match : {params} } = this.props;
    const song = params;
    this.setState({ready: 'loaded'});
    }
    render(){
    const{song} = this.state;
    return(
    <ResultStyle>
    <Header>
    <h1>Soundio</h1>
    <p>The Music Hub</p>
    <Form />
    </Header>
    <main>
    <Container>
    <Grid>
    { song.length ? '' : <Loader /> }
    { ready === 'loading' ? 'Loading...' : '' }
    { song.map(song => (
    <Column columns="3" key={song.id}>
    <MusicList image={song.album.cover_medium ? song.artist.picture_medium:''}>
    <h3 onClick="pointer"><Link to={`/song/${song.id}`}>{song.artist.name}</Link></h3>
    <i className="fa fa-music">Album:{song.album.title}</i> <br />
    <i className="fa fa-music">Track:{song.title}</i>
    </MusicList>
    </Column>
    )) }
    </Grid>
    </Container>
    </main>
    <Footer />
    </ResultStyle>
    )
    }
    }


    export default Result;
  2. 0xtruly created this gist Dec 18, 2018.
    85 changes: 85 additions & 0 deletions 2ndHome.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,85 @@
    import React, { Component } from 'react';
    import { Link } from 'react-router-dom';
    import styled from 'styled-components';
    import axios from 'axios';
    import { Grid, Column } from './Grid';
    import MusicBg from '../../assets/music-bg.jpeg';
    import MusicList from './MusicList';
    import Footer from './Footer';
    import Container from './Container';
    import Form from './Form';
    const HomeStyle = styled.div`
    header, footer{
    text-align: center;
    }
    main{
    margin: 20px 0;
    }
    `;

    const Header = styled.header`
    padding: 70px 20px;
    background: linear-gradient(rgba(0, 0, 0, .7), rgba(0, 0, 0, .7)), url(${MusicBg});
    background-size: cover;
    background-position: center;
    color: #fff;
    `;

    class Home extends Component {
    constructor() {
    super();
    this.state = {
    tracks: [],
    // store: [],
    // ready: 'initial',
    };
    }
    componentDidMount() {
    this.setState({
    ready: 'loading',
    });
    // axios({
    // method: 'get',
    // url: `${process.env.HOST}/artists`,
    // headers: `${process.env.API_KEY}`,
    // })
    axios.get('https://api.deezer.com/artist/27/top?e9d874c859b7133d36df9b5bcd38512d')
    .then(json => console.log(json.data.artist))
    // .then(({ data: { data } }) => {
    // this.setState({
    // ready: 'loaded',
    // tracks: data,
    // })
    // })
    }
    render() {
    const { tracks, ready } = this.state;
    return (
    <HomeStyle>
    <Header>
    <h1>Soundio</h1>
    <p>The Music Hub</p>
    <Form />
    </Header>
    <main>
    <Container>
    <Grid>
    { tracks.data ? '' : 'There are no sound clips ' }
    { ready === 'loading' ? 'Loading...' : '' }
    { tracks.map(tracks => (
    <Column columns="3" key={tracks.id}>
    <MusicList image={tracks.data.artist.picture ? charts.artists.Icon[0].url:''} preview={tracks.preview}>
    <h3><Link to={`/tracks/${tracks.id}`}>{tracks.artist.name}</Link></h3>
    </MusicList>
    </Column>
    )) }
    </Grid>
    </Container>
    </main>
    <Footer />
    </HomeStyle>
    );
    }
    }

    export default Home;