diff --git a/src/pages/about.tsx b/src/pages/about.tsx index 4a0a0c7..b4e02f5 100644 --- a/src/pages/about.tsx +++ b/src/pages/about.tsx @@ -31,10 +31,12 @@ Also note that, whatever other redeeming features they might have, prediction ma const AboutPage: NextPage = () => { return ( - -
- -
+ +
); diff --git a/src/web/display/Card.tsx b/src/web/display/Card.tsx index 636d739..0a62820 100644 --- a/src/web/display/Card.tsx +++ b/src/web/display/Card.tsx @@ -4,17 +4,22 @@ const CardTitle: React.FC = ({ children }) => ( interface Props { highlightOnHover?: boolean; + large?: boolean; } type CardType = React.FC & { Title: typeof CardTitle; }; -export const Card: CardType = ({ children, highlightOnHover = true }) => ( +export const Card: CardType = ({ + children, + large = false, + highlightOnHover = true, +}) => (
{children}
diff --git a/src/web/display/Layout.tsx b/src/web/display/Layout.tsx index 6993e90..4d1e84f 100644 --- a/src/web/display/Layout.tsx +++ b/src/web/display/Layout.tsx @@ -151,7 +151,7 @@ export const Layout: React.FC = ({ page, children }) => {
-
+
{children}
diff --git a/src/web/questions/components/HistoryChart.tsx b/src/web/questions/components/HistoryChart.tsx index 20666d6..bba5ec0 100644 --- a/src/web/questions/components/HistoryChart.tsx +++ b/src/web/questions/components/HistoryChart.tsx @@ -143,94 +143,88 @@ export const HistoryChart: React.FC = ({ question }) => { })); return ( -
-
- `Not shown`} - labelComponent={ - - `${datum.name}: ${Math.round(datum.y * 100)}%` - } - style={{ - fontSize: 15, - fill: "black", - strokeWidth: 0.05, - }} - flyoutStyle={{ - stroke: "black", - fill: "white", - }} - cornerRadius={0} - flyoutPadding={7} - /> - } - voronoiBlacklist={ - ["line-0", "line-1", "line-2", "line-3", "line-4"] - //Array.from(Array(5).keys()).map((x, i) => `line${i}`) - // see: https://github.com/FormidableLabs/victory/issues/545 + `Not shown`} + labelComponent={ + + `${datum.name}: ${Math.round(datum.y * 100)}%` } + style={{ + fontSize: 15, + fill: "black", + strokeWidth: 0.05, + }} + flyoutStyle={{ + stroke: "black", + fill: "white", + }} + cornerRadius={0} + flyoutPadding={7} /> } - domain={{ - y: [0, domainMax], - }} - > - + voronoiBlacklist={ + ["line-0", "line-1", "line-2", "line-3", "line-4"] + //Array.from(Array(5).keys()).map((x, i) => `line${i}`) + // see: https://github.com/FormidableLabs/victory/issues/545 + } + /> + } + domain={{ + y: [0, domainMax], + }} + > + - {dataSets - .slice(0, 5) - .map((dataset, i) => getVictoryGroup(dataset, i))} - datum.x)} - // tickFormat={dataAsXy.map((datum) => datum.x)} - tickCount={7} - style={{ - grid: { stroke: null, strokeWidth: 0.5 }, - }} - //axisLabelComponent={ - // - //} - // label="Date (dd/mm/yy)" - tickLabelComponent={ - - } + {dataSets.slice(0, 5).map((dataset, i) => getVictoryGroup(dataset, i))} + datum.x)} + // tickFormat={dataAsXy.map((datum) => datum.x)} + tickCount={7} + style={{ + grid: { stroke: null, strokeWidth: 0.5 }, + }} + //axisLabelComponent={ + // + //} + // label="Date (dd/mm/yy)" + tickLabelComponent={ + - `${x * 100}%`} - style={{ - grid: { stroke: "#D3D3D3", strokeWidth: 0.5 }, - }} - tickLabelComponent={ - - } - /> - -
-
+ } + /> + `${x * 100}%`} + style={{ + grid: { stroke: "#D3D3D3", strokeWidth: 0.5 }, + }} + tickLabelComponent={ + + } + /> + ); }; diff --git a/src/web/questions/components/IndicatorsTable.tsx b/src/web/questions/components/IndicatorsTable.tsx new file mode 100644 index 0000000..ff183b9 --- /dev/null +++ b/src/web/questions/components/IndicatorsTable.tsx @@ -0,0 +1,69 @@ +import { + formatIndicatorValue, qualityIndicatorLabels, UsedIndicatorName +} from "../../display/DisplayQuestion/QuestionFooter"; +import { Stars } from "../../display/Stars"; +import { QuestionFragment } from "../../fragments.generated"; + +interface Props { + question: QuestionFragment; +} + +const TableRow: React.FC<{ title: string }> = ({ title, children }) => ( + + + {title} + + {children} + +); + +export const IndicatorsTable: React.FC = ({ question }) => ( +
+ + + + + + + + + + + + {question.platform.label} + {question.qualityIndicators.numForecasts ? ( + + {question.qualityIndicators.numForecasts} + + ) : null} + {Object.keys(question.qualityIndicators) + .filter( + (indicator) => + question.qualityIndicators[indicator] != null && + !!qualityIndicatorLabels[indicator] + ) + .map((indicator: UsedIndicatorName) => { + return ( + + {formatIndicatorValue( + question.qualityIndicators[indicator], + indicator, + question.platform.id + )} + + ); + })} + +
+ Indicator + + Value +
+
+); diff --git a/src/web/questions/pages/QuestionPage.tsx b/src/web/questions/pages/QuestionPage.tsx index 7188fc9..443a5aa 100644 --- a/src/web/questions/pages/QuestionPage.tsx +++ b/src/web/questions/pages/QuestionPage.tsx @@ -5,15 +5,12 @@ import ReactMarkdown from "react-markdown"; import { Query } from "../../common/Query"; import { Card } from "../../display/Card"; import { DisplayOneQuestionForCapture } from "../../display/DisplayOneQuestionForCapture"; -import { - formatIndicatorValue, qualityIndicatorLabels, UsedIndicatorName -} from "../../display/DisplayQuestion/QuestionFooter"; import { Layout } from "../../display/Layout"; import { LineHeader } from "../../display/LineHeader"; -import { Stars } from "../../display/Stars"; import { QuestionWithHistoryFragment } from "../../fragments.generated"; import { ssrUrql } from "../../urql"; import { HistoryChart } from "../components/HistoryChart"; +import { IndicatorsTable } from "../components/IndicatorsTable"; import { QuestionPageDocument } from "../queries.generated"; interface Props { @@ -42,11 +39,18 @@ export const getServerSideProps: GetServerSideProps = async ( }; }; +const Section: React.FC<{ title: string }> = ({ title, children }) => ( +
+

{title}

+
{children}
+
+); + const QuestionCardContents: React.FC<{ question: QuestionWithHistoryFragment; }> = ({ question }) => ( -
-

+
+

- - -

- Question description -

- - {question.description.replaceAll("---", "")} - - -

- Indicators -

-
- - - - - - - - - - - - - - - - - {question.qualityIndicators.numForecasts ? ( - - - - - ) : null} - {Object.keys(question.qualityIndicators) - .filter( - (indicator) => - question.qualityIndicators[indicator] != null && - !!qualityIndicatorLabels[indicator] - ) - .map((indicator: UsedIndicatorName) => { - return ( - - - - - ); - })} - -
- Indicator - - Value -
- Stars - - -
- Platform - {question.platform.label}
- Number of forecasts - - {question.qualityIndicators.numForecasts} -
- {qualityIndicatorLabels[indicator]} - - {formatIndicatorValue( - question.qualityIndicators[indicator], - indicator, - question.platform.id - )} -
+
+
+ +
+ + {question.description.replaceAll("---", "")} + +
+ +
+ +
); const QuestionPage: NextPage = ({ id }) => { return ( -
+
{({ data }) => (
- +