generated from Code-4-Community/frontend-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 3
Optimize for landing page mobile #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
55249d4
Create hook to use window dimensions
SofieDunt 866f06e
New global styles
SofieDunt 7958651
Create link carousel component
SofieDunt 342bd24
Optimize for mobile, use styled components only
SofieDunt 2dc03ef
Merge branch 'master' into SD.optimizeForMobile
SofieDunt 5f3ced5
Add autoplay
SofieDunt 4d9d954
Merge branch 'master' into SD.optimizeForMobile
SofieDunt 6e82bfb
prettier
SofieDunt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import React from 'react'; | ||
| import { Carousel } from 'antd'; | ||
| import styled from 'styled-components'; | ||
| import { LIGHT_GREEN } from '../../colors'; | ||
| import LinkCard from '../linkcard/LinkCard'; | ||
| import useWindowDimensions, { WindowTypes } from '../window-dimensions'; | ||
|
|
||
| const StyledCarousel = styled(Carousel)` | ||
| max-width: 1350px; | ||
| margin: auto; | ||
| border: solid; | ||
| border-radius: 10px; | ||
| border-width: 5px 5px 5px 5px; | ||
| border-color: ${LIGHT_GREEN}; | ||
| `; | ||
|
|
||
| const CarouselSlide = styled.div` | ||
| padding: 10px; | ||
| border: solid; | ||
| border-width: 0px 0px 50px 0px; | ||
| border-color: ${LIGHT_GREEN}; | ||
| text-align: center; | ||
| `; | ||
|
|
||
| const LinkCarousel: React.FC = () => { | ||
| const { windowType } = useWindowDimensions(); | ||
| const slidesPerPage = Number( | ||
| `${ | ||
| windowType === WindowTypes.Desktop | ||
| ? 4 | ||
| : `${ | ||
| windowType === WindowTypes.NarrowDesktop | ||
| ? 3 | ||
| : `${windowType === WindowTypes.Mobile ? 1 : 2}` | ||
florisdobber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }` | ||
| }`, | ||
| ); | ||
| return ( | ||
| <> | ||
| <StyledCarousel | ||
| {...{ | ||
| slidesToShow: slidesPerPage, | ||
| slidesToScroll: slidesPerPage, | ||
| autoplay: true, | ||
florisdobber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }} | ||
| > | ||
| <CarouselSlide> | ||
| <LinkCard text="My Blocks" path="/" background="img1" /> | ||
| </CarouselSlide> | ||
| <CarouselSlide> | ||
| <LinkCard text="View Teams" path="/" background="img2" /> | ||
| </CarouselSlide> | ||
| <CarouselSlide> | ||
| <LinkCard text="Volunteer Leaderboard" path="/" background="img3" /> | ||
| </CarouselSlide> | ||
| <CarouselSlide> | ||
| <LinkCard text="Team Leaderboard" path="/" background="img4" /> | ||
| </CarouselSlide> | ||
| <CarouselSlide> | ||
| <LinkCard text="5th Card" path="/" background="img1" /> | ||
| </CarouselSlide> | ||
| <CarouselSlide> | ||
| <LinkCard text="6th Card" path="/" background="img2" /> | ||
| </CarouselSlide> | ||
| </StyledCarousel> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default LinkCarousel; | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { useState, useEffect } from 'react'; | ||
florisdobber marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const breakpointDesktop = 1150; | ||
| const breakpointTablet = 900; | ||
| const breakpointMobile = 650; | ||
|
|
||
| export enum WindowTypes { | ||
| Mobile = 'MOBILE', | ||
| Tablet = 'TABLET', | ||
| NarrowDesktop = 'NARROW', | ||
| Desktop = 'DESKTOP', | ||
| } | ||
|
|
||
| function getWindowDimensions() { | ||
| const { innerWidth: width, innerHeight: height } = window; | ||
| const windowType = `${ | ||
| width < breakpointMobile | ||
| ? WindowTypes.Mobile | ||
| : width < breakpointTablet | ||
| ? WindowTypes.Tablet | ||
| : `${ | ||
| width < breakpointDesktop | ||
| ? WindowTypes.NarrowDesktop | ||
| : WindowTypes.Desktop | ||
| }` | ||
| }`; | ||
| return { | ||
| width, | ||
| height, | ||
| windowType, | ||
| }; | ||
| } | ||
|
|
||
| export default function useWindowDimensions() { | ||
| const [windowDimensions, setWindowDimensions] = useState( | ||
| getWindowDimensions(), | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| function handleResize() { | ||
| setWindowDimensions(getWindowDimensions()); | ||
| } | ||
|
|
||
| window.addEventListener('resize', handleResize); | ||
| return () => window.removeEventListener('resize', handleResize); | ||
| }, []); | ||
|
|
||
| return windowDimensions; | ||
| } | ||
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
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.