From f5d15d59986e9747d550f4848b2d582d7d16c8b5 Mon Sep 17 00:00:00 2001 From: mattyl006 Date: Tue, 26 Jul 2022 17:02:40 +0200 Subject: [PATCH] refactor Readme section component --- src/components/elements/InfoItem.js | 18 +++++ src/components/elements/InfoList.js | 57 ++++++++++++++++ src/components/sections/Readme.js | 101 ++-------------------------- 3 files changed, 79 insertions(+), 97 deletions(-) create mode 100644 src/components/elements/InfoItem.js create mode 100644 src/components/elements/InfoList.js diff --git a/src/components/elements/InfoItem.js b/src/components/elements/InfoItem.js new file mode 100644 index 0000000..18e14a5 --- /dev/null +++ b/src/components/elements/InfoItem.js @@ -0,0 +1,18 @@ +import React from "react"; +import {FlexRow, Svg} from "../../utils/containers"; +import theme from "../../utils/theme"; +import {Medium} from "../../utils/fonts"; + +const InfoItem = (props) => { + return ( + + + + {props.children ? props.children : 'xxx'} + + + ); +} + +export default InfoItem; diff --git a/src/components/elements/InfoList.js b/src/components/elements/InfoList.js new file mode 100644 index 0000000..ee8c08e --- /dev/null +++ b/src/components/elements/InfoList.js @@ -0,0 +1,57 @@ +import React from "react"; +import {FlexColumn} from "../../utils/containers"; +import InfoItem from "./InfoItem"; +import textIco from "../../assets/text_ico.svg"; +import metricIco from "../../assets/metric_ico.svg"; +import bestScoreIco from "../../assets/cup_ico.svg"; +import baselineIco from "../../assets/baseline_ico.svg"; +import timeIco from "../../assets/clock_ico.svg"; +import {RENDER_DEADLINE_TIME} from "../../utils/globals"; +import coinsIco from "../../assets/coins_ico.svg"; +import Media from "react-media"; +import theme from "../../utils/theme"; + +const InfoList = (props) => { + const itemsRender = (gap, iconsSize) => { + return ( + <> + + 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'} + + + ); + } + + return ( + <> + + + {itemsRender('10px', props.iconsSize)} + + + + + {itemsRender('20px', props.iconsSize)} + + + + ); +} + +export default InfoList; \ No newline at end of file diff --git a/src/components/sections/Readme.js b/src/components/sections/Readme.js index 8fec011..983d170 100644 --- a/src/components/sections/Readme.js +++ b/src/components/sections/Readme.js @@ -1,18 +1,12 @@ import React from "react"; -import {FlexColumn, FlexRow, Svg} from "../../utils/containers"; +import {FlexColumn} 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"; import getChallengeFullDescription from "../../api/getChallengeFullDescription"; import {markdown} from "markdown"; import styled from "styled-components"; +import InfoList from "../elements/InfoList"; const ReadmeStyle = styled(Body)` h3 { @@ -66,50 +60,7 @@ const Readme = (props) => {

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'} - - - +

@@ -148,51 +99,7 @@ const Readme = (props) => {

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'} - - - +