From fae10a16a412fd2898c500b68531a3e341410b9b Mon Sep 17 00:00:00 2001 From: majakomel Date: Mon, 18 Sep 2023 16:50:35 +0200 Subject: [PATCH] Remove ReportBox --- components/ReportBox.js | 37 --------- components/landing/HighlightBox.js | 104 +++++++++++------------- components/landing/HighlightsSection.js | 42 ++++++++-- pages/incidents/index.js | 30 ++++--- 4 files changed, 105 insertions(+), 108 deletions(-) delete mode 100644 components/ReportBox.js diff --git a/components/ReportBox.js b/components/ReportBox.js deleted file mode 100644 index b2846662c..000000000 --- a/components/ReportBox.js +++ /dev/null @@ -1,37 +0,0 @@ -import { Flex, Heading, Box, Button, Text } from 'ooni-components' -import Flag from 'components/Flag' -import { getLocalisedRegionName } from 'utils/i18nCountries' -import { formatLongDate } from 'utils' -import { useIntl } from 'react-intl' -import NLink from 'next/link' - -const ReportBox = ({country, startDate, endDate, title, id, shortDescription, ...props}) => { - const intl = useIntl() - - return ( - - {country && ( - - - - {getLocalisedRegionName(country, intl.locale)} - - - )} - {startDate && formatLongDate(startDate, intl.locale)} - {endDate ? formatLongDate(endDate, intl.locale) : 'ongoing'} - {title} -

{shortDescription}

- - - - - -
- ) -} - -export default ReportBox \ No newline at end of file diff --git a/components/landing/HighlightBox.js b/components/landing/HighlightBox.js index 4276bd149..11786a416 100644 --- a/components/landing/HighlightBox.js +++ b/components/landing/HighlightBox.js @@ -1,8 +1,7 @@ import React from 'react' import { useIntl } from 'react-intl' import PropTypes from 'prop-types' -import NLink from 'next/link' -import { Flex, Box, Link, theme, Text } from 'ooni-components' +import { Flex, Box, Text, Heading, Link, theme } from 'ooni-components' import styled from 'styled-components' import Markdown from 'markdown-to-jsx' import { getLocalisedRegionName } from 'utils/i18nCountries' @@ -21,62 +20,56 @@ const HighlightBox = ({ countryCode, title, text, - report, - explore, - tileColor = 'black' + dates, + footer }) => { const intl = useIntl() return ( - - - - - {getLocalisedRegionName(countryCode, intl.locale)} - - - {title && - - {intl.formatMessage({id: title})} - - } - - - + + {countryCode && ( + + + + {getLocalisedRegionName(countryCode, intl.locale)} + + + )} + {dates} + {/* {startDate && formatLongDate(startDate, intl.locale)} - {endDate ? formatLongDate(endDate, intl.locale) : 'ongoing'} */} + {title} + + - {intl.formatMessage({id: text})} - - - - - - {explore && - - - {intl.formatMessage({id: 'Home.Highlights.Explore'})} - - - } - {report && - - - {intl.formatMessage({id: 'Home.Highlights.ReadReport'})} - - - } - - - + }, + } + }} + > + {text} + + + + {footer} + ) } @@ -87,9 +80,8 @@ HighlightBox.propTypes = { countryName: PropTypes.string.isRequired, title: PropTypes.string, text: PropTypes.string.isRequired, - report: PropTypes.string, - explore: PropTypes.string, - tileColor: PropTypes.string + footer: PropTypes.element, + dates: PropTypes.element } export default HighlightBox diff --git a/components/landing/HighlightsSection.js b/components/landing/HighlightsSection.js index 7af266ea3..0f4ffffc4 100644 --- a/components/landing/HighlightsSection.js +++ b/components/landing/HighlightsSection.js @@ -1,14 +1,24 @@ import React from 'react' import PropTypes from 'prop-types' -import { Flex, Box, Text } from 'ooni-components' - +import { Flex, Box, Text, Button } from 'ooni-components' +import NLink from 'next/link' import HighlightBox from './HighlightBox' +import { styled } from 'styled-components' +import { useIntl } from 'react-intl' + +const StyledGrid = styled(Box)` +display: grid; +grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); +gap: 24px; +` const HighlightSection = ({ title, highlights, description }) => { + const intl = useIntl() + return (
@@ -22,17 +32,39 @@ const HighlightSection = ({ {description && {description} } - + {/* HighlightBoxes */} { highlights.map((item, index) => ( + {item.explore && + + + + + + } + {item.report && + + + + + + } + + } /> )) } - +
) } diff --git a/pages/incidents/index.js b/pages/incidents/index.js index 1ddd97c3a..2aefadf41 100644 --- a/pages/incidents/index.js +++ b/pages/incidents/index.js @@ -1,16 +1,17 @@ import Head from 'next/head' import NavBar from 'components/NavBar' -import { Container, Heading, Box, Flex, Input, Select, Button } from 'ooni-components' +import { Container, Heading, Box, Flex, Input, Select, Button, Text } from 'ooni-components' import { StyledStickyNavBar, StyledStickySubMenu } from 'components/SharedStyledComponents' import useFilterWithSort from 'hooks/useFilterWithSort' import useSWR from 'swr' import { apiEndpoints, fetcher } from '/lib/api' -import ReportBox from '../../components/ReportBox' +import HighlightBox from 'components/landing/HighlightBox' import { styled } from 'styled-components' import { useIntl } from 'react-intl' import { useMemo } from 'react' import useUser from 'hooks/useUser' import NLink from 'next/link' +import { formatLongDate } from 'utils' const sortOptions = [ { key: 'start_asc', intlKey: 'Sort.StartAsc' }, @@ -21,10 +22,10 @@ const sortOptions = [ const StyledGrid = styled(Box)` display: grid; -grid-template-columns: 1fr 1fr; -grid-auto-rows: 1fr; +grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 24px; ` + const ReportIndex = () => { const intl = useIntl() const { user } = useUser() @@ -117,14 +118,23 @@ const ReportIndex = () => { {sortedAndFilteredData.map((incident) => ( - + {incident.start_time && formatLongDate(incident.start_time, intl.locale)} - {incident.end_time ? formatLongDate(incident.end_time, intl.locale) : 'ongoing'} + + } + footer={ + + + + + + } /> ))}