This file contains 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, { useState, useReducer, useContext } from "react"; | |
import ReactDOM from "react-dom"; | |
import "./styles.css"; | |
const reducer = (todos, action) => { | |
switch (action.type) { | |
case "ADD_TODO": | |
const newTodo = { id: todos.length + 1, name: action.payload }; | |
return [...todos, newTodo]; | |
case "REMOVE_TODO": |
This file contains 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, { useState } from "react"; | |
import ReactDOM from "react-dom"; | |
import "./styles.css"; | |
const Header = ({ children, count }) => ( | |
<h1> | |
{children} ({count}) | |
</h1> | |
); |
This file contains 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, { useState, useCallback, useContext, useReducer } from "react"; | |
import ReactDOM from "react-dom"; | |
import "./styles.css"; | |
const TodoContext = React.createContext(); | |
const reducer = (state, action) => { | |
switch (action.type) { | |
case "ADD_TODO": | |
return [...state, action.payload]; |
This file contains 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, { useState, useCallback } from "react"; | |
import ReactDOM from "react-dom"; | |
import "./styles.css"; | |
const AddTodo = ({ onClickAdd }) => { | |
const [todo, setTodo] = useState({ name: "", checked: false }); | |
const handleChangeTodo = evt => { | |
setTodo({ name: evt.target.value, checked: false }); | |
}; |
This file contains 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 { useState, useRef, useEffect } from 'react' | |
const PADDINGS = 110; | |
const useSliding = (elementWidth, countElements) => { | |
const containerRef = useRef(null); | |
const [containerWidth, setContainerWidth] = useState(0); | |
const [distance, setDistance] = useState(0); | |
const [totalInViewport, setTotalInViewport] = useState(0) | |
const [viewed, setViewed] = useState(0); |
This file contains 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 { useState, useRef, useEffect } from 'react' | |
const useSizeElement = () => { | |
const elementRef = useRef(null); | |
const [width, setWidth] = useState(0); | |
useEffect(() => { | |
setWidth(elementRef.current.clientWidth); | |
}, [elementRef.current]); |
This file contains 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 cx from 'classnames'; | |
import SliderContext from './context' | |
import ShowDetailsButton from './ShowDetailsButton' | |
import Mark from './Mark' | |
import './Item.scss' | |
const Item = ({ movie }) => ( | |
<SliderContext.Consumer> | |
{({ onSelectSlide, currentSlide, elementRef }) => { |
This file contains 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, { useState } from 'react'; | |
import cx from 'classnames'; | |
import SliderContext from './context' | |
import Content from './Content' | |
import SlideButton from './SlideButton' | |
import SliderWrapper from './SliderWrapper' | |
import useSliding from './useSliding' | |
import useSizeElement from './useSizeElement' | |
import './Slider.scss' |
This file contains 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
.content { | |
margin-top: 40px; | |
height: 300px; | |
position: relative; | |
} | |
.background { | |
display: flex; | |
height: 100%; | |
} |
This file contains 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="content"> | |
<div class="background"> | |
<div class="left">left</div> | |
<div class="right">right</div> | |
</div> | |
<div class="content-container">content here...</div> | |
</div> |
NewerOlder