This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from "react"; | |
| import Loading from "./../components/Loading"; | |
| import fetchData from "./../data"; | |
| /* | |
| variables - function that returns parameters (based on the component props) for the fetchData() | |
| */ | |
| const withLoadingData = variables => WrappedComponent => { | |
| class WithLoadingData extends Component { | |
| state = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| const ListContext = React.createContext(); | |
| export default ListContext; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from "react"; | |
| import ListContext from "./context"; | |
| import "./List.css"; | |
| class List extends Component { | |
| state = { | |
| selectedItem: null | |
| }; | |
| handleSelectItem = selectedItem => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react"; | |
| import ListContext from "./context"; | |
| import "./Item.css"; | |
| const Item = ({ id, icon, className, info, children }) => ( | |
| <ListContext.Consumer> | |
| {value => ( | |
| <button | |
| className={["item", className].join(" ")} | |
| key={id} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import List from "./List"; | |
| import Item from "./Item"; | |
| List.Item = Item; | |
| export default List; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const calcDuration = duration => { | |
| const totalMinutes = duration / 60; | |
| const minutes = ~~totalMinutes; | |
| const seconds = ~~((totalMinutes - minutes) * 100); | |
| return `${minutes}m ${seconds}s`; | |
| }; | |
| export default calcDuration; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from "react"; | |
| class ImageResource extends Component { | |
| constructor(props) { | |
| super(props); | |
| const image = new Image(); | |
| image.onload = this.handleLoadImage; | |
| this.state = { image, src: props.lowQuality }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="container"> | |
| <div class="item">1</div> | |
| <div class="item">2</div> | |
| <div class="item">3</div> | |
| <div class="item">4</div> | |
| <div class="item">5</div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .container { | |
| display: flex; | |
| padding: 0 55px; | |
| } | |
| .item { | |
| background: green; | |
| flex: 0 0 19.7%; | |
| text-align: center; | |
| margin: 0 2px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .container:hover .item { | |
| transform: translateX(-25%); | |
| } |
OlderNewer