diff options
| author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-11-06 10:54:17 +0900 | 
|---|---|---|
| committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-11-06 10:54:17 +0900 | 
| commit | 5dbd1c675383c4c8c1d884d94c7e664bc50b1c7a (patch) | |
| tree | 5c5653fc9fbbdb6ea226fff992609b216ff6ff36 /src | |
| parent | bb3a5c93dfc394c3186587fde0c9c834c12da06f (diff) | |
More responsive tab switching
Diffstat (limited to 'src')
| -rw-r--r-- | src/App.js | 83 | 
1 files changed, 42 insertions, 41 deletions
| @@ -44,6 +44,7 @@ import NavigateBeforeIcon from '@material-ui/icons/NavigateBefore';  import Grow from '@material-ui/core/Grow';  import LazyLoad from 'react-lazyload';  import { CarouselProvider, Slider, Slide, ButtonBack, ButtonNext } from 'pure-react-carousel'; +import useTimeout from 'use-timeout'  import { useWindowDimensions } from './utils.js';  import 'pure-react-carousel/dist/react-carousel.es.css';  import 'fontsource-roboto'; @@ -242,27 +243,27 @@ function StoreList(props) {  function StoreView(props) {     const [state, setState] = useState({data: [], loaded: false}); -   useEffect(() => { -         async function fetchData() { -            function getRandomInt(max) { -               return Math.floor(Math.random() * Math.floor(max)); -            } -            var result = await fetch('https://cors-anywhere.herokuapp.com/https://www.eisys-bcs.jp/data.json?key[]=dlsite-doujin_home_center2').then(result => result.json()); -            result = result.data.['dlsite-doujin_home_center2'].banners.map(item => { return { -               id: 'no-id', -               author: he.decode(item.title), -               title: he.decode(item.title), -               shortdesc: 'foobar', -               desc: 'foobar', -               img: 'https:' + item.ssl_path, -               cat: 'Misc', -               price: getRandomInt(3000) + '円', -               rating: getRandomInt(5), -            }}) -            setState({data: result, loaded: true}); +   useTimeout(() => { +      async function fetchData() { +         function getRandomInt(max) { +            return Math.floor(Math.random() * Math.floor(max));           } -         fetchData(); -   }, []); +         var result = await fetch('https://cors-anywhere.herokuapp.com/https://www.eisys-bcs.jp/data.json?key[]=dlsite-doujin_home_center2').then(result => result.json()); +         result = result.data.['dlsite-doujin_home_center2'].banners.map(item => { return { +            id: 'no-id', +            author: he.decode(item.title), +            title: he.decode(item.title), +            shortdesc: 'foobar', +            desc: 'foobar', +            img: 'https:' + item.ssl_path, +            cat: 'Misc', +            price: getRandomInt(3000) + '円', +            rating: getRandomInt(5), +         }}) +         setState({data: result, loaded: true}); +      } +      fetchData(); +   }, 600);     return (       <> @@ -275,27 +276,27 @@ function StoreView(props) {  function LibraryView(props) {     const [state, setState] = useState({data: [], loaded: false}); -   useEffect(() => { -         async function fetchData() { -            function getRandomInt(max) { -               return Math.floor(Math.random() * Math.floor(max)); -            } -            var result = await fetch('https://cors-anywhere.herokuapp.com/https://www.eisys-bcs.jp/data.json?key[]=dlsite-doujin_home_center2').then(result => result.json()); -            result = result.data.['dlsite-doujin_home_center2'].banners.map(item => { return { -               id: 'no-id', -               author: he.decode(item.title), -               title: he.decode(item.title), -               shortdesc: 'foobar', -               desc: 'foobar', -               img: 'https:' + item.ssl_path, -               cat: 'Misc', -               price: getRandomInt(3000) + '円', -               rating: getRandomInt(5), -            }}) -            setState({data: result, loaded: true}); +   useTimeout(() => { +      async function fetchData() { +         function getRandomInt(max) { +            return Math.floor(Math.random() * Math.floor(max));           } -         fetchData(); -   }, []); +         var result = await fetch('https://cors-anywhere.herokuapp.com/https://www.eisys-bcs.jp/data.json?key[]=dlsite-doujin_home_center2').then(result => result.json()); +         result = result.data.['dlsite-doujin_home_center2'].banners.map(item => { return { +            id: 'no-id', +            author: he.decode(item.title), +            title: he.decode(item.title), +            shortdesc: 'foobar', +            desc: 'foobar', +            img: 'https:' + item.ssl_path, +            cat: 'Misc', +            price: getRandomInt(3000) + '円', +            rating: getRandomInt(5), +         }}) +         setState({data: result, loaded: true}); +      } +      fetchData(); +   }, 600);     return (       <> @@ -432,7 +433,7 @@ function TopBar(props) {                 </StyledBadge>              </IconButton>           </Toolbar> -         {props.search ? <ItemSearch/> : null} +         <Collapse in={props.search} timeout='auto' unmountOnExit><ItemSearch/></Collapse>        </AppBar>     );  } | 
