SLIDER FOR TOP WEBSITES AND SOFTWARE PLATFORM

by Amir Danish

HTML

<div id="app"></div>
<script async src="//cdn.embedly.com/widgets/platform.js" charset="UTF-8"></script>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

.done {
  color: rgba(0, 0, 0, 0.3);
  text-decoration: line-through;
}

input {
  margin-right: 5px;
}

React

class TodoApp extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
    	urls: ['https://google.com', 'https://stackoverflow.com/', 'https://github.com/', 'https://translate.google.com/', 'https://about.gitlab.com/'],
      currentUrl: 0
    }
  }
  
  nextClickHandler = () => {
  	const { urls, currentUrl } = this.state;
    
  	this.setState({
    	currentUrl: urls.length - 1 > currentUrl ? currentUrl + 1 : 0
    })
  }
  
  prevClickHandler = () => {
  	const { urls, currentUrl } = this.state;
    
  	this.setState({
    	currentUrl: currentUrl <= 0 ? urls.length - 1 : currentUrl - 1
    })
  }
  
  render() {
  	const { urls, currentUrl } = this.state;
    return (
      <div>
        <button onClick={this.prevClickHandler}>Prev</button>
        <button onClick={this.nextClickHandler}>Next</button>
        <div key={urls[currentUrl]}>
          <a
            className="embedly-card"
            data-card-controls="0"
            data-card-branding="0"
            data-card-type="article"
            href={urls[currentUrl]}
          />
        </div>
      </div>
    )
  }
}

ReactDOM.render(<TodoApp />, document.querySelector("#app"))