From d580a7028391eb3e6f98096fec54e4346d6b3bed Mon Sep 17 00:00:00 2001 From: mattyl006 Date: Tue, 26 Jul 2022 13:34:41 +0200 Subject: [PATCH] Readme section without Example on mobile --- src/components/elements/IconLabel.js | 13 +-- src/components/sections/Readme.js | 116 +++++++++++++++++++++++++-- src/pages/Challenge.js | 9 ++- src/utils/globals.js | 12 ++- 4 files changed, 126 insertions(+), 24 deletions(-) diff --git a/src/components/elements/IconLabel.js b/src/components/elements/IconLabel.js index 8fc2b87..ac4f3c3 100644 --- a/src/components/elements/IconLabel.js +++ b/src/components/elements/IconLabel.js @@ -2,7 +2,7 @@ import React from "react"; import {FlexRow, Svg} from "../../utils/containers"; import {Body, Medium} from "../../utils/fonts"; import styled from "styled-components"; -import {RENDER_ICO} from "../../utils/globals"; +import {RENDER_DEADLINE_TIME, RENDER_ICO} from "../../utils/globals"; const HoverLabel = styled(Body)` position: absolute; @@ -18,15 +18,6 @@ const HoverLabel = styled(Body)` color: ${({theme}) => theme.colors.white}; `; -const renderDeadlineTime = (time) => { - if (time) { - const date = time.slice(0, 10); - const hour = time.slice(11, 16); - return `${date} ${hour}`; - } - return ''; -} - const renderHoverLabel = (type, time) => { const hoverLabel = (label) => @@ -41,7 +32,7 @@ const renderHoverLabel = (type, time) => { case 'baseline': return hoverLabel('baseline'); case 'deadline': - return hoverLabel(`deadline ${renderDeadlineTime(time)}`); + return hoverLabel(`deadline ${RENDER_DEADLINE_TIME(time)}`); case 'bestScore': return hoverLabel('best score'); case 'text': diff --git a/src/components/sections/Readme.js b/src/components/sections/Readme.js index 9d50ed9..c03fa0b 100644 --- a/src/components/sections/Readme.js +++ b/src/components/sections/Readme.js @@ -1,14 +1,114 @@ import React from "react"; -import {FlexColumn} from "../../utils/containers"; -import {H2} from "../../utils/fonts"; +import {FlexColumn, FlexRow, Svg} from "../../utils/containers"; +import {Body, H2, Medium} from "../../utils/fonts"; +import Media from "react-media"; +import theme from "../../utils/theme"; +import baselineIco from '../../assets/baseline_ico.svg'; +import bestScoreIco from '../../assets/cup_ico.svg'; +import timeIco from '../../assets/clock_ico.svg'; +import metricIco from '../../assets/metric_ico.svg'; +import coinsIco from '../../assets/coins_ico.svg'; +import textIco from '../../assets/text_ico.svg'; +import {RENDER_DEADLINE_TIME} from "../../utils/globals"; + +const Readme = (props) => { + const mobileRender = () => { + return ( + + +

+ Info +

+ + + + + The word-processing challenge + + + + + + Metrics: {props.metric ? props.metric : 'xxx'} + + + + + + Best score: {props.bestScore ? props.bestScore : 'xxx'} + + + + + + Baseline: {props.baseline ? props.baseline : 'xxx'} + + + + + + Deadline: {props.deadline ? RENDER_DEADLINE_TIME(props.deadline) : 'xxx'} + + + + + + Prize: {props.prize ? props.prize : 'xxx'} + + + +
+ +

+ Description +

+ + {props.description} + +
+ +

+ Baseline +

+ + + In metus ex, venenatis quis risus eget, sodales venenatis nibh. Sed ullamcorper leo non nunc + euismod, id faucibus justo finibus. Nullam malesuada eros quam, eu lobortis leo feugiat non. + + + See notebook  + + here. + + + +
+
+ ); + } + + const desktopRender = () => { + return ( + <> + + ); + } -const Readme = () => { return ( - -

- Readme -

-
+ <> + + {mobileRender()} + + + + + ); } diff --git a/src/pages/Challenge.js b/src/pages/Challenge.js index 6627807..9616d24 100644 --- a/src/pages/Challenge.js +++ b/src/pages/Challenge.js @@ -29,13 +29,14 @@ const Challenge = () => { case 0: return case 1: - return + return case 2: - return + return case 3: - return + return case 4: - return + return default: return } diff --git a/src/utils/globals.js b/src/utils/globals.js index 79c3a66..63941cd 100644 --- a/src/utils/globals.js +++ b/src/utils/globals.js @@ -49,6 +49,15 @@ const CALC_PAGES = (objects) => { return Math.ceil(objects.length / ELEMENTS_PER_PAGE); } +const RENDER_DEADLINE_TIME = (time) => { + if (time) { + const date = time.slice(0, 10); + const hour = time.slice(11, 16); + return `${date} ${hour}`; + } + return ''; +} + export { ELEMENTS_PER_PAGE, API, @@ -57,5 +66,6 @@ export { MINI_DESCRIPTION_LENGTH, MINI_DESCRIPTION_RENDER, RENDER_ICO, - CALC_PAGES + CALC_PAGES, + RENDER_DEADLINE_TIME }; \ No newline at end of file