sectionRender in Challenge component
This commit is contained in:
parent
5317dc9625
commit
757cf72e12
@ -1,9 +1,39 @@
|
||||
import React from "react";
|
||||
import {FlexRow} from "../../utils/containers";
|
||||
import styled from "styled-components";
|
||||
import {Medium} from "../../utils/fonts";
|
||||
|
||||
const MobileChallengeMenu = () => {
|
||||
const MenuOption = styled(Medium)`
|
||||
cursor: pointer;
|
||||
transition: color 0.3s ease-in-out;
|
||||
|
||||
&:hover {
|
||||
color: ${({theme}) => theme.colors.green};
|
||||
}
|
||||
`;
|
||||
|
||||
const MobileChallengeMenu = (props) => {
|
||||
return (
|
||||
<>
|
||||
|
||||
<FlexRow gap='32px'>
|
||||
<MenuOption as='button' to='/' onClick={() => props.setSection(0)}>
|
||||
Leaderboard
|
||||
</MenuOption>
|
||||
<MenuOption as='button' to='/' onClick={() => props.setSection(1)}>
|
||||
Readme
|
||||
</MenuOption>
|
||||
<MenuOption as='button' to='/' onClick={() => props.setSection(2)}>
|
||||
How to
|
||||
</MenuOption>
|
||||
</FlexRow>
|
||||
<FlexRow gap='36px'>
|
||||
<MenuOption as='button' to='/' onClick={() => props.setSection(4)}>
|
||||
My entries
|
||||
</MenuOption>
|
||||
<MenuOption as='button' to='/' onClick={() => props.setSection(3)}>
|
||||
Submit
|
||||
</MenuOption>
|
||||
</FlexRow>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
15
src/components/sections/HowTo.js
Normal file
15
src/components/sections/HowTo.js
Normal file
@ -0,0 +1,15 @@
|
||||
import React from "react";
|
||||
import {FlexColumn} from "../../utils/containers";
|
||||
import {H2} from "../../utils/fonts";
|
||||
|
||||
const HowTo = () => {
|
||||
return (
|
||||
<FlexColumn padding='24px'>
|
||||
<H2>
|
||||
How to
|
||||
</H2>
|
||||
</FlexColumn>
|
||||
);
|
||||
}
|
||||
|
||||
export default HowTo;
|
15
src/components/sections/Leaderboard.js
Normal file
15
src/components/sections/Leaderboard.js
Normal file
@ -0,0 +1,15 @@
|
||||
import React from "react";
|
||||
import {FlexColumn} from "../../utils/containers";
|
||||
import {H2} from "../../utils/fonts";
|
||||
|
||||
const Leaderboard = () => {
|
||||
return (
|
||||
<FlexColumn padding='24px'>
|
||||
<H2>
|
||||
Leaderboard
|
||||
</H2>
|
||||
</FlexColumn>
|
||||
);
|
||||
}
|
||||
|
||||
export default Leaderboard;
|
15
src/components/sections/MyEntries.js
Normal file
15
src/components/sections/MyEntries.js
Normal file
@ -0,0 +1,15 @@
|
||||
import React from "react";
|
||||
import {FlexColumn} from "../../utils/containers";
|
||||
import {H2} from "../../utils/fonts";
|
||||
|
||||
const MyEntries = () => {
|
||||
return (
|
||||
<FlexColumn padding='24px'>
|
||||
<H2>
|
||||
My entries
|
||||
</H2>
|
||||
</FlexColumn>
|
||||
);
|
||||
}
|
||||
|
||||
export default MyEntries;
|
15
src/components/sections/Readme.js
Normal file
15
src/components/sections/Readme.js
Normal file
@ -0,0 +1,15 @@
|
||||
import React from "react";
|
||||
import {FlexColumn} from "../../utils/containers";
|
||||
import {H2} from "../../utils/fonts";
|
||||
|
||||
const Readme = () => {
|
||||
return (
|
||||
<FlexColumn padding='24px'>
|
||||
<H2>
|
||||
Readme
|
||||
</H2>
|
||||
</FlexColumn>
|
||||
);
|
||||
}
|
||||
|
||||
export default Readme;
|
15
src/components/sections/Submit.js
Normal file
15
src/components/sections/Submit.js
Normal file
@ -0,0 +1,15 @@
|
||||
import React from "react";
|
||||
import {FlexColumn} from "../../utils/containers";
|
||||
import {H2} from "../../utils/fonts";
|
||||
|
||||
const Submit = () => {
|
||||
return (
|
||||
<FlexColumn padding='24px'>
|
||||
<H2>
|
||||
Submit
|
||||
</H2>
|
||||
</FlexColumn>
|
||||
);
|
||||
}
|
||||
|
||||
export default Submit;
|
@ -1,24 +1,24 @@
|
||||
import React from "react";
|
||||
import {Container, FlexColumn, FlexRow} from "../utils/containers";
|
||||
import {Link, useParams} from "react-router-dom";
|
||||
import {H1, Medium} from "../utils/fonts";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {H1} from "../utils/fonts";
|
||||
import getChallenges from "../api/getChallenges";
|
||||
import theme from "../utils/theme";
|
||||
import styled from "styled-components";
|
||||
|
||||
const ChallengeLink = styled(Medium)`
|
||||
cursor: pointer;
|
||||
transition: color 0.3s ease-in-out;
|
||||
|
||||
&:hover {
|
||||
color: ${({theme}) => theme.colors.green};
|
||||
}
|
||||
`;
|
||||
|
||||
import MobileChallengeMenu from "../components/elements/MobileChallengeMenu";
|
||||
import Leaderboard from "../components/sections/Leaderboard";
|
||||
import Readme from "../components/sections/Readme";
|
||||
import HowTo from "../components/sections/HowTo";
|
||||
import MyEntries from "../components/sections/MyEntries";
|
||||
import Submit from "../components/sections/Submit";
|
||||
|
||||
const Challenge = () => {
|
||||
const challengeName = useParams().challengeId;
|
||||
const [challenges, setChallenges] = React.useState([]);
|
||||
const [section, setSection] = React.useState([0]);
|
||||
|
||||
React.useEffect(() => {
|
||||
getChallenges(setChallenges);
|
||||
}, []);
|
||||
|
||||
const getChallenge = () => {
|
||||
if (challenges.length !== 0) {
|
||||
@ -30,35 +30,31 @@ const Challenge = () => {
|
||||
return '';
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
getChallenges(setChallenges);
|
||||
}, []);
|
||||
const sectionRender = () => {
|
||||
switch (section) {
|
||||
case 0:
|
||||
return <Leaderboard/>
|
||||
case 1:
|
||||
return <Readme/>
|
||||
case 2:
|
||||
return <HowTo/>
|
||||
case 3:
|
||||
return <MyEntries/>
|
||||
case 4:
|
||||
return <Submit/>
|
||||
default:
|
||||
return <Leaderboard/>
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<FlexColumn minHeight='100vh' gap='12px' alignmentY='flex-start' padding='66px 0 0 0'>
|
||||
<H1 margin='0 0 8px 0'>
|
||||
{getChallenge().title}
|
||||
</H1>
|
||||
<FlexRow gap='32px'>
|
||||
<ChallengeLink as={Link} to='/'>
|
||||
Leaderboard
|
||||
</ChallengeLink>
|
||||
<ChallengeLink as={Link} to='/'>
|
||||
Readme
|
||||
</ChallengeLink>
|
||||
<ChallengeLink as={Link} to='/'>
|
||||
How to
|
||||
</ChallengeLink>
|
||||
</FlexRow>
|
||||
<FlexRow gap='32px'>
|
||||
<ChallengeLink as={Link} to='/'>
|
||||
Submit
|
||||
</ChallengeLink>
|
||||
<ChallengeLink as={Link} to='/'>
|
||||
My entries
|
||||
</ChallengeLink>
|
||||
</FlexRow>
|
||||
<MobileChallengeMenu setSection={setSection}/>
|
||||
<Container width='75%' height='1px' backgroundColor={theme.colors.dark}/>
|
||||
{sectionRender()}
|
||||
</FlexColumn>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user