Merge branch 'master' into pagination-refactor
This commit is contained in:
commit
8b82ddb36c
@ -3,87 +3,90 @@ const filterOptions = [
|
|||||||
{
|
{
|
||||||
name: 'Closing',
|
name: 'Closing',
|
||||||
sort: true,
|
sort: true,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Closing',
|
name: 'Closing',
|
||||||
sort: true,
|
sort: true,
|
||||||
rotate: '180deg'
|
rotate: '180deg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Hotness',
|
name: 'Hotness',
|
||||||
sort: true,
|
sort: true,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Hotness',
|
name: 'Hotness',
|
||||||
sort: true,
|
sort: true,
|
||||||
rotate: '180deg'
|
rotate: '180deg',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Reward',
|
name: 'Reward',
|
||||||
sort: true,
|
sort: true,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Reward',
|
name: 'Reward',
|
||||||
sort: true,
|
sort: true,
|
||||||
rotate: '180deg'
|
rotate: '180deg',
|
||||||
}
|
},
|
||||||
], [
|
],
|
||||||
|
[
|
||||||
{
|
{
|
||||||
name: 'Both',
|
name: 'Both',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Completed',
|
name: 'Closed',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Active',
|
name: 'Active',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
], [
|
],
|
||||||
|
[
|
||||||
{
|
{
|
||||||
name: 'All',
|
name: 'All',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Tabular',
|
name: 'Tabular',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Text',
|
name: 'Text',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Image',
|
name: 'Image',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
], [
|
],
|
||||||
|
[
|
||||||
{
|
{
|
||||||
name: 'Both',
|
name: 'Both',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Yes',
|
name: 'Yes',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'No',
|
name: 'No',
|
||||||
sort: false,
|
sort: false,
|
||||||
rotate: ''
|
rotate: '0',
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
export default filterOptions;
|
export default filterOptions;
|
@ -7,6 +7,8 @@ import {
|
|||||||
CALC_PAGES,
|
CALC_PAGES,
|
||||||
EVALUATIONS_FORMAT,
|
EVALUATIONS_FORMAT,
|
||||||
RENDER_WHEN
|
RENDER_WHEN
|
||||||
|
IS_MOBILE,
|
||||||
|
RENDER_WHEN,
|
||||||
} from '../../../utils/globals';
|
} from '../../../utils/globals';
|
||||||
import Loading from '../../generic/Loading';
|
import Loading from '../../generic/Loading';
|
||||||
import Pager from '../../generic/Pager';
|
import Pager from '../../generic/Pager';
|
||||||
@ -55,10 +57,11 @@ const AllEntries = (props) => {
|
|||||||
|
|
||||||
const getAllEntriesHeader = () => {
|
const getAllEntriesHeader = () => {
|
||||||
let header = ['#', 'submitter'];
|
let header = ['#', 'submitter'];
|
||||||
|
if (IS_MOBILE()) header.push('when');
|
||||||
for (let metric of getPossibleMetrics()) {
|
for (let metric of getPossibleMetrics()) {
|
||||||
header.push(metric);
|
header.push(metric);
|
||||||
}
|
}
|
||||||
header.push('when');
|
if (!IS_MOBILE()) header.push('when');
|
||||||
return header;
|
return header;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,12 +138,57 @@ const AllEntries = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const mobileRender = () => {
|
const mobileRender = () => {
|
||||||
return <></>;
|
return (
|
||||||
|
<FlexColumn padding="24px 12px" width="70%" as="section" id="start">
|
||||||
|
<H2 as="h2" margin="0 0 12px 0">
|
||||||
|
All Entries
|
||||||
|
</H2>
|
||||||
|
{!loading ? (
|
||||||
|
<>
|
||||||
|
<Search searchQueryHandler={searchQueryHandler} />
|
||||||
|
<Table
|
||||||
|
challengeName={props.challengeName}
|
||||||
|
headerElements={getAllEntriesHeader()}
|
||||||
|
possibleMetrics={getPossibleMetrics()}
|
||||||
|
tableType="allEntries"
|
||||||
|
gridTemplateColumns={
|
||||||
|
'1fr ' + '4fr '.repeat(getAllEntriesHeader().length - 1)
|
||||||
|
}
|
||||||
|
staticColumnElements={[
|
||||||
|
{ name: 'id', format: null, order: 1, align: 'left' },
|
||||||
|
{ name: 'submitter', format: null, order: 2, align: 'left' },
|
||||||
|
{ name: 'when', format: RENDER_WHEN, order: 5, align: 'right' },
|
||||||
|
]}
|
||||||
|
iterableColumnElement={{
|
||||||
|
name: 'evaluations',
|
||||||
|
format: EVALUATIONS_FORMAT,
|
||||||
|
order: 3,
|
||||||
|
align: 'left',
|
||||||
|
}}
|
||||||
|
pageNr={pageNr}
|
||||||
|
elements={entries}
|
||||||
|
sortByUpdate={sortByUpdate}
|
||||||
|
/>
|
||||||
|
<Pager
|
||||||
|
pageNr={pageNr}
|
||||||
|
width="48px"
|
||||||
|
borderRadius="64px"
|
||||||
|
pages={CALC_PAGES(entries)}
|
||||||
|
nextPage={nextPage}
|
||||||
|
previousPage={previousPage}
|
||||||
|
number={`${pageNr} / ${CALC_PAGES(entries)}`}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Loading />
|
||||||
|
)}
|
||||||
|
</FlexColumn>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const desktopRender = () => {
|
const desktopRender = () => {
|
||||||
return (
|
return (
|
||||||
<FlexColumn padding="24px" as="section" width="100%" maxWidth="1400px">
|
<FlexColumn padding="24px" as="section" width="100%" maxWidth="1600px">
|
||||||
<H2 as="h2" margin="0 0 32px 0">
|
<H2 as="h2" margin="0 0 32px 0">
|
||||||
All Entries
|
All Entries
|
||||||
</H2>
|
</H2>
|
||||||
|
@ -115,7 +115,7 @@ const Challenge = (props) => {
|
|||||||
<FlexColumn
|
<FlexColumn
|
||||||
minHeight="100vh"
|
minHeight="100vh"
|
||||||
alignmentY="flex-start"
|
alignmentY="flex-start"
|
||||||
padding="64px 24px 64px 310px"
|
padding="64px 24px 64px 280px"
|
||||||
id="start"
|
id="start"
|
||||||
>
|
>
|
||||||
<FlexRow gap="32px" margin="0 0 32px 0" padding="16px">
|
<FlexRow gap="32px" margin="0 0 32px 0" padding="16px">
|
||||||
|
@ -9,7 +9,8 @@ const ColumnFilterIcon = (props) => {
|
|||||||
if (props.index === props.active) {
|
if (props.index === props.active) {
|
||||||
return (
|
return (
|
||||||
<Svg
|
<Svg
|
||||||
width="8px"
|
minWidth="8px"
|
||||||
|
maxWidth="8px"
|
||||||
src={filterIco}
|
src={filterIco}
|
||||||
cursor={props.cursor}
|
cursor={props.cursor}
|
||||||
backgroundColor={theme.colors.dark}
|
backgroundColor={theme.colors.dark}
|
||||||
@ -20,7 +21,8 @@ const ColumnFilterIcon = (props) => {
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<Svg
|
<Svg
|
||||||
width="8px"
|
minWidth="8px"
|
||||||
|
maxWidth="8px"
|
||||||
src={arrow}
|
src={arrow}
|
||||||
cursor={props.cursor}
|
cursor={props.cursor}
|
||||||
backgroundColor={theme.colors.dark}
|
backgroundColor={theme.colors.dark}
|
||||||
@ -33,7 +35,8 @@ const ColumnFilterIcon = (props) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Svg
|
<Svg
|
||||||
width="8px"
|
minWidth="8px"
|
||||||
|
maxWidth="8px"
|
||||||
rotate="180deg"
|
rotate="180deg"
|
||||||
src={arrow}
|
src={arrow}
|
||||||
cursor={props.cursor}
|
cursor={props.cursor}
|
||||||
|
@ -8,6 +8,7 @@ import { Link } from 'react-router-dom';
|
|||||||
import {
|
import {
|
||||||
MENU_CHALLENGE_SECTIONS_WITH_LOGIN,
|
MENU_CHALLENGE_SECTIONS_WITH_LOGIN,
|
||||||
MENU_CHALLENGE_SECTIONS_NO_LOGIN,
|
MENU_CHALLENGE_SECTIONS_NO_LOGIN,
|
||||||
|
IS_MOBILE,
|
||||||
} from '../../utils/globals';
|
} from '../../utils/globals';
|
||||||
|
|
||||||
const DesktopChallengeMenuStyle = styled(FlexColumn)`
|
const DesktopChallengeMenuStyle = styled(FlexColumn)`
|
||||||
@ -15,7 +16,7 @@ const DesktopChallengeMenuStyle = styled(FlexColumn)`
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
left: 0;
|
left: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
width: 280px;
|
width: 240px;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
top: 50px;
|
top: 50px;
|
||||||
padding: 64px 0 0 0;
|
padding: 64px 0 0 0;
|
||||||
@ -58,7 +59,12 @@ const DesktopChallengeMenu = (props) => {
|
|||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(' ', '')}`}
|
.replace(' ', '')}`}
|
||||||
>
|
>
|
||||||
<H3 textTransform="uppercase">{option}</H3>
|
<H3
|
||||||
|
fontSize={IS_MOBILE() ? '18px' : '22px'}
|
||||||
|
textTransform="uppercase"
|
||||||
|
>
|
||||||
|
{option}
|
||||||
|
</H3>
|
||||||
</Option>
|
</Option>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -167,7 +167,7 @@ const Leaderboard = (props) => {
|
|||||||
<Table
|
<Table
|
||||||
challengeName={props.challengeName}
|
challengeName={props.challengeName}
|
||||||
headerElements={getLeaderboardHeaderMobile()}
|
headerElements={getLeaderboardHeaderMobile()}
|
||||||
tableType="Leaderboard"
|
tableType="leaderboard"
|
||||||
gridTemplateColumns={
|
gridTemplateColumns={
|
||||||
entries[0]
|
entries[0]
|
||||||
? '1fr 3fr ' +
|
? '1fr 3fr ' +
|
||||||
@ -212,7 +212,7 @@ const Leaderboard = (props) => {
|
|||||||
|
|
||||||
const desktopRender = () => {
|
const desktopRender = () => {
|
||||||
return (
|
return (
|
||||||
<FlexColumn padding="24px" as="section" width="100%" maxWidth="1200px">
|
<FlexColumn padding="24px" as="section" width="100%" maxWidth="1600px">
|
||||||
<H2 as="h2" margin="0 0 32px 0">
|
<H2 as="h2" margin="0 0 32px 0">
|
||||||
Leaderboard
|
Leaderboard
|
||||||
</H2>
|
</H2>
|
||||||
|
@ -161,9 +161,9 @@ const MyEntries = (props) => {
|
|||||||
|
|
||||||
const desktopRender = () => {
|
const desktopRender = () => {
|
||||||
return (
|
return (
|
||||||
<FlexColumn padding="24px" as="section" width="100%" maxWidth="1400px">
|
<FlexColumn padding="24px" as="section" width="100%" maxWidth="1600px">
|
||||||
<FlexColumn padding="24px 12px" width="70%" as="section" id="start">
|
<FlexColumn padding="24px 12px" width="70%" as="section" id="start">
|
||||||
<H2 as="h2" margin="0 0 12px 0">
|
<H2 as="h2" margin="0 0 32px 0">
|
||||||
My Entries
|
My Entries
|
||||||
</H2>
|
</H2>
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
@ -175,7 +175,7 @@ const MyEntries = (props) => {
|
|||||||
headerElements={getMyEntriesHeader()}
|
headerElements={getMyEntriesHeader()}
|
||||||
possibleMetrics={getPossibleMetrics()}
|
possibleMetrics={getPossibleMetrics()}
|
||||||
gridTemplateColumns={
|
gridTemplateColumns={
|
||||||
'1fr ' + '4fr '.repeat(getMyEntriesHeader().length - 1)
|
'1fr ' + '3fr '.repeat(getMyEntriesHeader().length - 2) + ' 4fr'
|
||||||
}
|
}
|
||||||
staticColumnElements={[
|
staticColumnElements={[
|
||||||
{ name: 'id', format: null, order: 1, align: 'left' },
|
{ name: 'id', format: null, order: 1, align: 'left' },
|
||||||
|
@ -95,7 +95,9 @@ const Table = (props) => {
|
|||||||
elem = newElem;
|
elem = newElem;
|
||||||
}
|
}
|
||||||
let indexModificator = 2;
|
let indexModificator = 2;
|
||||||
if (props.tableType === 'Leaderboard') indexModificator = 4;
|
if (props.tableType === 'leaderboard') indexModificator = 4;
|
||||||
|
if (props.tableType === 'allEntries') indexModificator = 3;
|
||||||
|
|
||||||
return elem.map((iterableElem, i) => {
|
return elem.map((iterableElem, i) => {
|
||||||
return (
|
return (
|
||||||
<Body
|
<Body
|
||||||
@ -104,6 +106,8 @@ const Table = (props) => {
|
|||||||
order={props.iterableColumnElement.order}
|
order={props.iterableColumnElement.order}
|
||||||
textAlign={props.iterableColumnElement.align}
|
textAlign={props.iterableColumnElement.align}
|
||||||
minWidth="72px"
|
minWidth="72px"
|
||||||
|
margin="auto 0"
|
||||||
|
overflowWrap="anywhere"
|
||||||
>
|
>
|
||||||
{IS_MOBILE() && (
|
{IS_MOBILE() && (
|
||||||
<Container className="mobile-table-header">
|
<Container className="mobile-table-header">
|
||||||
@ -128,6 +132,8 @@ const Table = (props) => {
|
|||||||
as="td"
|
as="td"
|
||||||
order={elemName.order}
|
order={elemName.order}
|
||||||
textAlign={elemName.align}
|
textAlign={elemName.align}
|
||||||
|
margin="auto 0"
|
||||||
|
overflowWrap="anywhere"
|
||||||
>
|
>
|
||||||
{IS_MOBILE() && (
|
{IS_MOBILE() && (
|
||||||
<Container className="mobile-table-header">
|
<Container className="mobile-table-header">
|
||||||
@ -154,7 +160,8 @@ const Table = (props) => {
|
|||||||
gridGap="20px"
|
gridGap="20px"
|
||||||
position="relative"
|
position="relative"
|
||||||
width="100%"
|
width="100%"
|
||||||
padding="4px"
|
padding="0 6px"
|
||||||
|
minHeight="44px"
|
||||||
margin="0 0 6px 0"
|
margin="0 0 6px 0"
|
||||||
gridTemplateColumns={props.gridTemplateColumns}
|
gridTemplateColumns={props.gridTemplateColumns}
|
||||||
>
|
>
|
||||||
@ -181,8 +188,8 @@ const Table = (props) => {
|
|||||||
cursor={elem !== '#' ? 'pointer' : ''}
|
cursor={elem !== '#' ? 'pointer' : ''}
|
||||||
textAlign={elem === 'when' ? 'right' : 'left'}
|
textAlign={elem === 'when' ? 'right' : 'left'}
|
||||||
width={elem === 'when' ? '100%' : 'auto'}
|
width={elem === 'when' ? '100%' : 'auto'}
|
||||||
padding="0 6px 0 0"
|
padding="0 4px 0 0"
|
||||||
overflowWrap="break-word"
|
overflowWrap="anywhere"
|
||||||
minWidth={elem === 'result' ? '72px' : 'none'}
|
minWidth={elem === 'result' ? '72px' : 'none'}
|
||||||
>
|
>
|
||||||
{elem.replace('.', ' ')}
|
{elem.replace('.', ' ')}
|
||||||
@ -198,7 +205,12 @@ const Table = (props) => {
|
|||||||
</FlexRow>
|
</FlexRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<Line height="2px" top="100%" as="td" shadow={theme.shadow} />
|
<Line
|
||||||
|
height="2px"
|
||||||
|
top="calc(100% + 2px)"
|
||||||
|
as="td"
|
||||||
|
shadow={theme.shadow}
|
||||||
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
{elementsToMap.map((elem, index) => {
|
{elementsToMap.map((elem, index) => {
|
||||||
return (
|
return (
|
||||||
@ -213,6 +225,7 @@ const Table = (props) => {
|
|||||||
position="relative"
|
position="relative"
|
||||||
width="100%"
|
width="100%"
|
||||||
padding="4px"
|
padding="4px"
|
||||||
|
minHeight="48px"
|
||||||
>
|
>
|
||||||
{rowRender(elem)}
|
{rowRender(elem)}
|
||||||
{props.headerElements ? metricsRender(elem) : ''}
|
{props.headerElements ? metricsRender(elem) : ''}
|
||||||
|
@ -5,13 +5,14 @@ import Search from '../../components/generic/Search';
|
|||||||
import Pager from '../../components/generic/Pager';
|
import Pager from '../../components/generic/Pager';
|
||||||
import FiltersMenu from '../../components/challenges_list/FiltersMenu';
|
import FiltersMenu from '../../components/challenges_list/FiltersMenu';
|
||||||
import challengeSearchQueryHandler from './challengeSearchQueryHandler';
|
import challengeSearchQueryHandler from './challengeSearchQueryHandler';
|
||||||
import _renderChallenges from './_renderChallenges';
|
import renderChallenges from './renderChallenges';
|
||||||
import Media from 'react-media';
|
import Media from 'react-media';
|
||||||
import theme from '../../utils/theme';
|
import theme from '../../utils/theme';
|
||||||
import cupIco from '../../assets/cup_ico.svg';
|
import cupIco from '../../assets/cup_ico.svg';
|
||||||
import getChallenges from '../../api/getChallenges';
|
import getChallenges from '../../api/getChallenges';
|
||||||
import { CALC_PAGES } from '../../utils/globals';
|
import { CALC_PAGES, CHALLENGES_STATUS_FILTER } from '../../utils/globals';
|
||||||
import Loading from '../../components/generic/Loading';
|
import Loading from '../../components/generic/Loading';
|
||||||
|
import ChallengesStyle from './ChallengesStyle';
|
||||||
|
|
||||||
const Challenges = () => {
|
const Challenges = () => {
|
||||||
const [pageNr, setPageNr] = React.useState(1);
|
const [pageNr, setPageNr] = React.useState(1);
|
||||||
@ -19,7 +20,7 @@ const Challenges = () => {
|
|||||||
const [challenges, setChallenges] = React.useState([]);
|
const [challenges, setChallenges] = React.useState([]);
|
||||||
const [filtersMenu, setFiltersMenu] = React.useState(false);
|
const [filtersMenu, setFiltersMenu] = React.useState(false);
|
||||||
const [sortBy, setSortBy] = React.useState(0);
|
const [sortBy, setSortBy] = React.useState(0);
|
||||||
const [status, setStatus] = React.useState(0);
|
const [status, setStatus] = React.useState(CHALLENGES_STATUS_FILTER.BOTH);
|
||||||
const [challengeType, setChallengeType] = React.useState(0);
|
const [challengeType, setChallengeType] = React.useState(0);
|
||||||
const [commercial, setCommercial] = React.useState(0);
|
const [commercial, setCommercial] = React.useState(0);
|
||||||
const [loading, setLoading] = React.useState(true);
|
const [loading, setLoading] = React.useState(true);
|
||||||
@ -33,22 +34,6 @@ const Challenges = () => {
|
|||||||
getChallenges(setChallenges, setLoading);
|
getChallenges(setChallenges, setLoading);
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortByHandler = (value) => {
|
|
||||||
setSortBy(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const statusHandler = (value) => {
|
|
||||||
setStatus(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const challengeTypeHandler = (value) => {
|
|
||||||
setChallengeType(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const commercialHandler = (value) => {
|
|
||||||
setCommercial(value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const searchQueryHandler = (event) => {
|
const searchQueryHandler = (event) => {
|
||||||
challengeSearchQueryHandler(
|
challengeSearchQueryHandler(
|
||||||
event,
|
event,
|
||||||
@ -58,10 +43,6 @@ const Challenges = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderChallenges = () => {
|
|
||||||
return _renderChallenges(pageNr, challenges);
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleFiltersMenu = () => {
|
const toggleFiltersMenu = () => {
|
||||||
let newFiltersMenu = !filtersMenu;
|
let newFiltersMenu = !filtersMenu;
|
||||||
setFiltersMenu(newFiltersMenu);
|
setFiltersMenu(newFiltersMenu);
|
||||||
@ -74,27 +55,18 @@ const Challenges = () => {
|
|||||||
translateX={filtersMenu ? '0' : '100vw'}
|
translateX={filtersMenu ? '0' : '100vw'}
|
||||||
opacity={filtersMenu ? '1' : '0'}
|
opacity={filtersMenu ? '1' : '0'}
|
||||||
toggleFiltersMenu={toggleFiltersMenu}
|
toggleFiltersMenu={toggleFiltersMenu}
|
||||||
sortByHandler={sortByHandler}
|
sortByHandler={setSortBy}
|
||||||
statusHandler={statusHandler}
|
statusHandler={setStatus}
|
||||||
challengeTypeHandler={challengeTypeHandler}
|
challengeTypeHandler={setChallengeType}
|
||||||
commercialHandler={commercialHandler}
|
commercialHandler={setCommercial}
|
||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
status={status}
|
status={status}
|
||||||
challengeType={challengeType}
|
challengeType={challengeType}
|
||||||
commercial={commercial}
|
commercial={commercial}
|
||||||
/>
|
/>
|
||||||
<FlexColumn
|
<ChallengesStyle as="main" id="start">
|
||||||
as="main"
|
<FlexColumn className="ChallengesStyle__page-container">
|
||||||
alignmentY="flex-start"
|
<H1 as="h1">Challenges</H1>
|
||||||
width="100%"
|
|
||||||
id="start"
|
|
||||||
minHeight="100vh"
|
|
||||||
padding="90px 0 32px 0"
|
|
||||||
>
|
|
||||||
<FlexColumn alignmentX="flex-start" width="80%">
|
|
||||||
<H1 as="h1" margin="0 0 20px 0">
|
|
||||||
Challenges
|
|
||||||
</H1>
|
|
||||||
<Search
|
<Search
|
||||||
searchQueryHandler={searchQueryHandler}
|
searchQueryHandler={searchQueryHandler}
|
||||||
filterButton
|
filterButton
|
||||||
@ -102,10 +74,10 @@ const Challenges = () => {
|
|||||||
/>
|
/>
|
||||||
<FlexColumn width="100%">
|
<FlexColumn width="100%">
|
||||||
<Loading visible={loading} />
|
<Loading visible={loading} />
|
||||||
{renderChallenges()}
|
{renderChallenges(pageNr, challenges)}
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
{!loading ? (
|
{!loading && (
|
||||||
<Pager
|
<Pager
|
||||||
elements={challenges}
|
elements={challenges}
|
||||||
pageNr={pageNr}
|
pageNr={pageNr}
|
||||||
@ -115,10 +87,8 @@ const Challenges = () => {
|
|||||||
borderRadius="64px"
|
borderRadius="64px"
|
||||||
number={`${pageNr} / ${CALC_PAGES(challenges)}`}
|
number={`${pageNr} / ${CALC_PAGES(challenges)}`}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
''
|
|
||||||
)}
|
)}
|
||||||
</FlexColumn>
|
</ChallengesStyle>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -129,65 +99,45 @@ const Challenges = () => {
|
|||||||
<FiltersMenu
|
<FiltersMenu
|
||||||
toggleFiltersMenu={toggleFiltersMenu}
|
toggleFiltersMenu={toggleFiltersMenu}
|
||||||
transBackDisplay="none"
|
transBackDisplay="none"
|
||||||
sortByHandler={sortByHandler}
|
sortByHandler={setSortBy}
|
||||||
statusHandler={statusHandler}
|
statusHandler={setStatus}
|
||||||
challengeTypeHandler={challengeTypeHandler}
|
challengeTypeHandler={setChallengeType}
|
||||||
commercialHandler={commercialHandler}
|
commercialHandler={setCommercial}
|
||||||
sortBy={sortBy}
|
sortBy={sortBy}
|
||||||
status={status}
|
status={status}
|
||||||
challengeType={challengeType}
|
challengeType={challengeType}
|
||||||
commercial={commercial}
|
commercial={commercial}
|
||||||
/>
|
/>
|
||||||
<FlexColumn
|
<ChallengesStyle as="main" id="start">
|
||||||
as="main"
|
<FlexColumn className="ChallengesStyle__page-container">
|
||||||
alignmentY="flex-start"
|
<FlexRow className="ChallengesStyle__page-header-container">
|
||||||
width="100%"
|
<FlexColumn className="ChallengesStyle__page-header">
|
||||||
id="start"
|
|
||||||
minHeight="100vh"
|
|
||||||
padding="112px 0 82px 310px"
|
|
||||||
>
|
|
||||||
<FlexColumn alignmentX="flex-start" width="80%">
|
|
||||||
<FlexRow width="100%" gap="32px">
|
|
||||||
<FlexColumn
|
|
||||||
alignmentX="flex-start"
|
|
||||||
gap="32px"
|
|
||||||
width="75%"
|
|
||||||
maxWidth="720px"
|
|
||||||
>
|
|
||||||
<H1 as="h1">Challenges</H1>
|
<H1 as="h1">Challenges</H1>
|
||||||
<Body margin="0 0 12px 0" maxWidth="400px">
|
<Body className="ChallengesStyle__header-content">
|
||||||
Increase your machine learning skills by competing in our
|
Increase your machine learning skills by competing in our
|
||||||
exciting challenges.
|
exciting challenges.
|
||||||
</Body>
|
</Body>
|
||||||
<Search searchQueryHandler={searchQueryHandler} />
|
<Search searchQueryHandler={searchQueryHandler} />
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
<Svg
|
<Svg src={cupIco} className="ChallengesStyle__main-image" />
|
||||||
src={cupIco}
|
|
||||||
size="contain"
|
|
||||||
width="25%"
|
|
||||||
height="160px"
|
|
||||||
backgroundColor={theme.colors.green}
|
|
||||||
/>
|
|
||||||
</FlexRow>
|
</FlexRow>
|
||||||
<FlexColumn width="100%">
|
<FlexColumn width="100%">
|
||||||
<Loading visible={loading} />
|
<Loading visible={loading} />
|
||||||
{renderChallenges()}
|
{renderChallenges(pageNr, challenges)}
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
</FlexColumn>
|
</FlexColumn>
|
||||||
{!loading ? (
|
{!loading && (
|
||||||
<Pager
|
<Pager
|
||||||
pageNr={pageNr}
|
pageNr={pageNr}
|
||||||
setPageNr={setPageNr}
|
setPageNr={setPageNr}
|
||||||
elements={challenges}
|
elements={challenges}
|
||||||
pages={CALC_PAGES(challenges)}
|
pages={CALC_PAGES(challenges)}
|
||||||
borderRadius="64px"
|
|
||||||
width="72px"
|
width="72px"
|
||||||
|
borderRadius="64px"
|
||||||
number={`${pageNr} / ${CALC_PAGES(challenges)}`}
|
number={`${pageNr} / ${CALC_PAGES(challenges)}`}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
''
|
|
||||||
)}
|
)}
|
||||||
</FlexColumn>
|
</ChallengesStyle>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
50
src/pages/Challanges/ChallengesStyle.js
Normal file
50
src/pages/Challanges/ChallengesStyle.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
import { FlexColumn } from '../../utils/containers';
|
||||||
|
|
||||||
|
const ChallengesStyle = styled(FlexColumn)`
|
||||||
|
justify-content: flex-start;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 90px 0 32px 0;
|
||||||
|
|
||||||
|
@media (min-width: ${({ theme }) => theme.overMobile}) {
|
||||||
|
padding: 112px 0 82px 310px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ChallengesStyle__page-container {
|
||||||
|
align-items: flex-start;
|
||||||
|
width: 80%;
|
||||||
|
h1 {
|
||||||
|
margin: 0 0 20px 0;
|
||||||
|
@media (min-width: ${({ theme }) => theme.overMobile}) {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.ChallengesStyle__page-header-container {
|
||||||
|
width: 100%;
|
||||||
|
gap: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ChallengesStyle__page-header {
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 32px;
|
||||||
|
width: 75%;
|
||||||
|
max-width: 720px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ChallengesStyle__header-content {
|
||||||
|
margin: 0 0 12px 0;
|
||||||
|
max-width: 600px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ChallengesStyle__main-image {
|
||||||
|
width: 25%;
|
||||||
|
height: 160px;
|
||||||
|
background-color: ${({ theme }) => theme.colors.green};
|
||||||
|
mask-size: contain;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default ChallengesStyle;
|
@ -1,40 +0,0 @@
|
|||||||
import {ELEMENTS_PER_PAGE} from '../../utils/globals';
|
|
||||||
import MiniChallenge from '../../components/challenges_list/MiniChallenge';
|
|
||||||
import {Grid} from '../../utils/containers';
|
|
||||||
import styled from 'styled-components';
|
|
||||||
|
|
||||||
const ChallengesGrid = styled(Grid)`
|
|
||||||
margin: 32px 0;
|
|
||||||
grid-gap: 32px 0;
|
|
||||||
|
|
||||||
@media (min-width: 1200px) {
|
|
||||||
margin: 96px 0;
|
|
||||||
grid-gap: 64px;
|
|
||||||
grid-template-columns: 1fr 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 1600px) {
|
|
||||||
grid-template-columns: 1fr 1fr 1fr;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const _renderChallenges = (pageNr, challenges) => {
|
|
||||||
const n = (pageNr - 1) * ELEMENTS_PER_PAGE;
|
|
||||||
if (challenges && challenges !== []) {
|
|
||||||
return (
|
|
||||||
<ChallengesGrid margin='32px 0' gridGap='32px 0'>
|
|
||||||
{challenges.slice(n, n + ELEMENTS_PER_PAGE).map(
|
|
||||||
({title, type, description, mainMetric, bestScore, baseline, prize, deadline, name}, index) => {
|
|
||||||
return (
|
|
||||||
<MiniChallenge key={`challenge-${index}`} title={title} type={type}
|
|
||||||
description={description} metric={mainMetric} bestScore={bestScore}
|
|
||||||
baseline={baseline} prize={prize} deadline={deadline} name={name}/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</ChallengesGrid>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
};
|
|
||||||
|
|
||||||
export default _renderChallenges;
|
|
65
src/pages/Challanges/renderChallenges.js
Normal file
65
src/pages/Challanges/renderChallenges.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import { ELEMENTS_PER_PAGE } from '../../utils/globals';
|
||||||
|
import MiniChallenge from '../../components/challenges_list/MiniChallenge';
|
||||||
|
import { Grid } from '../../utils/containers';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const ChallengesGrid = styled(Grid)`
|
||||||
|
margin: 32px 0;
|
||||||
|
grid-gap: 32px 0;
|
||||||
|
|
||||||
|
@media (min-width: 1200px) {
|
||||||
|
margin: 96px 0;
|
||||||
|
grid-gap: 64px;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1600px) {
|
||||||
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const renderChallenges = (pageNr, challenges) => {
|
||||||
|
const n = (pageNr - 1) * ELEMENTS_PER_PAGE;
|
||||||
|
if (challenges && challenges !== []) {
|
||||||
|
return (
|
||||||
|
<ChallengesGrid margin="32px 0" gridGap="32px 0">
|
||||||
|
{challenges
|
||||||
|
.slice(n, n + ELEMENTS_PER_PAGE)
|
||||||
|
.map(
|
||||||
|
(
|
||||||
|
{
|
||||||
|
title,
|
||||||
|
type,
|
||||||
|
description,
|
||||||
|
mainMetric,
|
||||||
|
bestScore,
|
||||||
|
baseline,
|
||||||
|
prize,
|
||||||
|
deadline,
|
||||||
|
name,
|
||||||
|
},
|
||||||
|
index
|
||||||
|
) => {
|
||||||
|
return (
|
||||||
|
<MiniChallenge
|
||||||
|
key={`challenge-${index}`}
|
||||||
|
title={title}
|
||||||
|
type={type}
|
||||||
|
description={description}
|
||||||
|
metric={mainMetric}
|
||||||
|
bestScore={bestScore}
|
||||||
|
baseline={baseline}
|
||||||
|
prize={prize}
|
||||||
|
deadline={deadline}
|
||||||
|
name={name}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</ChallengesGrid>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
export default renderChallenges;
|
@ -25,9 +25,12 @@ const H2 = styled(H1)`
|
|||||||
const H3 = styled(H1)`
|
const H3 = styled(H1)`
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
line-height: 22px;
|
line-height: 22px;
|
||||||
|
font-size: ${({ fontSize }) => (fontSize ? fontSize : '18px')};
|
||||||
|
|
||||||
@media (min-width: ${({ theme }) => theme.overMobile}) {
|
@media (min-width: ${({ theme }) => theme.overMobile}) {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
line-height: 26px;
|
line-height: 26px;
|
||||||
|
font-size: ${({ fontSize }) => (fontSize ? fontSize : '24px')};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -48,7 +51,7 @@ const Medium = styled(Body)`
|
|||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
@media (min-width: ${({ theme }) => theme.overMobile}) {
|
@media (min-width: ${({ theme }) => theme.overMobile}) {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: ${({fontSize}) => fontSize ? fontSize : '16px'}
|
font-size: ${({ fontSize }) => (fontSize ? fontSize : '16px')};
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -80,7 +83,7 @@ const Code = styled(Container)`
|
|||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
display: ${({before}) => before ? 'inline-block' : 'none'};
|
display: ${({ before }) => (before ? 'inline-block' : 'none')};
|
||||||
content: '~$';
|
content: '~$';
|
||||||
color: ${({ theme }) => theme.colors.green};
|
color: ${({ theme }) => theme.colors.green};
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
@ -42,6 +42,12 @@ const CHALLENGE_SECTIONS = {
|
|||||||
SUBMIT: 5,
|
SUBMIT: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const CHALLENGES_STATUS_FILTER = {
|
||||||
|
BOTH: 0,
|
||||||
|
CLOSED: 1,
|
||||||
|
ACTIVE: 2,
|
||||||
|
};
|
||||||
|
|
||||||
const MINI_DESCRIPTION_RENDER = (description) => {
|
const MINI_DESCRIPTION_RENDER = (description) => {
|
||||||
if (description) {
|
if (description) {
|
||||||
if (description.length <= MINI_DESCRIPTION_LENGTH) return description;
|
if (description.length <= MINI_DESCRIPTION_LENGTH) return description;
|
||||||
@ -127,6 +133,7 @@ export {
|
|||||||
CHALLENGE_SECTIONS,
|
CHALLENGE_SECTIONS,
|
||||||
MENU_CHALLENGE_SECTIONS_NO_LOGIN,
|
MENU_CHALLENGE_SECTIONS_NO_LOGIN,
|
||||||
MENU_CHALLENGE_SECTIONS_WITH_LOGIN,
|
MENU_CHALLENGE_SECTIONS_WITH_LOGIN,
|
||||||
|
CHALLENGES_STATUS_FILTER,
|
||||||
MINI_DESCRIPTION_RENDER,
|
MINI_DESCRIPTION_RENDER,
|
||||||
RENDER_ICO,
|
RENDER_ICO,
|
||||||
CALC_PAGES,
|
CALC_PAGES,
|
||||||
|
Loading…
Reference in New Issue
Block a user