Skip to content

Commit

Permalink
Remove ReportBox
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Sep 18, 2023
1 parent 8941583 commit fae10a1
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 108 deletions.
37 changes: 0 additions & 37 deletions components/ReportBox.js

This file was deleted.

104 changes: 48 additions & 56 deletions components/landing/HighlightBox.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -21,62 +20,56 @@ const HighlightBox = ({
countryCode,
title,
text,
report,
explore,
tileColor = 'black'
dates,
footer
}) => {
const intl = useIntl()

return (
<Box width={[1, 1/3]}>
<StyledFlex flexDirection='column' p={4} mx={[0, 3]} my={3} bg={tileColor} color='white'>
<Flex flexWrap='wrap' alignItems='center' my={3}>
<Flag countryCode={countryCode} size={40} border />
<Text fontSize={24} fontWeight='bold' mx={3}>{getLocalisedRegionName(countryCode, intl.locale)}</Text>
</Flex>
<FlexGrowBox flexWrap='wrap' my={1}>
{title &&
<Box my={2}>
<Text fontSize={24} fontWeight='bold'>{intl.formatMessage({id: title})}</Text>
</Box>
}
<Box mb={3}>
<Text fontSize={20}>
<Markdown
options={{
overrides: {
a: {
component: Link,
props: {
color: theme.colors.blue3
}
},
<Flex
py={4}
px={24}
sx={{
flexDirection: 'column',
justifyContent: 'space-between',
border: '1px solid',
borderColor: 'gray3',
borderLeft: '10px solid',
borderLeftColor: 'blue5',
minHeight: '328px'
}}
>
<Box>
{countryCode && (
<Flex alignItems="center">
<Flag countryCode={countryCode} size={32} />
<Heading h={28} ml={2} my={0}>
{getLocalisedRegionName(countryCode, intl.locale)}
</Heading>
</Flex>
)}
{dates}
{/* <Text color="gray6">{startDate && formatLongDate(startDate, intl.locale)} - {endDate ? formatLongDate(endDate, intl.locale) : 'ongoing'}</Text> */}
<Heading h={4} lineHeight='1.1'>{title}</Heading>
<Text fontSize={20} as='p'>
<Markdown
options={{
overrides: {
a: {
component: Link,
props: {
color: theme.colors.blue3
}
}}
>
{intl.formatMessage({id: text})}
</Markdown>
</Text>
</Box>
</FlexGrowBox>
<Flex>
{explore &&
<Box my={2} width={1/2}>
<Text fontSize={20}>
<NLink href={explore} passHref><Link color='white'>{intl.formatMessage({id: 'Home.Highlights.Explore'})}</Link></NLink>
</Text>
</Box>
}
{report &&
<Box my={2} width={1/2}>
<Text fontSize={20}>
<Link href={report} color='white'>{intl.formatMessage({id: 'Home.Highlights.ReadReport'})}</Link>
</Text>
</Box>
}
</Flex>
</StyledFlex>
</Box>
},
}
}}
>
{text}
</Markdown>
</Text>
</Box>
{footer}
</Flex>
)
}

Expand All @@ -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
42 changes: 37 additions & 5 deletions components/landing/HighlightsSection.js
Original file line number Diff line number Diff line change
@@ -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 (
<section>
<Box mt={4} mb={3}>
Expand All @@ -22,17 +32,39 @@ const HighlightSection = ({
{description && <Box mt={4} mb={3}>
<Text fontSize={20}>{description}</Text>
</Box>}
<Flex flexWrap='wrap'>
<StyledGrid>
{/* HighlightBoxes */}
{
highlights.map((item, index) => (
<HighlightBox
key={index}
{...item}
title={item.title ? intl.formatMessage({id: item.title}) : ''}
text={item.text ? intl.formatMessage({id: item.text}) : ''}
countryCode={item.countryCode}
footer={
<Flex justifyContent={'space-between'}>
{item.explore &&
<Box>
<NLink href={item.explore}>
<Button type='button' hollow btnSize='small'>
{intl.formatMessage({id: 'Home.Highlights.Explore'})}
</Button>
</NLink>
</Box>
}
{item.report &&
<Box>
<a href={item.report}>
<Button type='button' hollow btnSize='small'>{intl.formatMessage({id: 'Home.Highlights.ReadReport'})}</Button>
</a>
</Box>
}
</Flex>
}
/>
))
}
</Flex>
</StyledGrid>
</section>
)
}
Expand Down
30 changes: 20 additions & 10 deletions pages/incidents/index.js
Original file line number Diff line number Diff line change
@@ -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' },
Expand All @@ -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()
Expand Down Expand Up @@ -117,14 +118,23 @@ const ReportIndex = () => {
</StyledStickySubMenu>
<StyledGrid mt={4}>
{sortedAndFilteredData.map((incident) => (
<ReportBox
<HighlightBox
key={incident.id}
id={incident.id}
country={incident.CCs[0]}
countryCode={incident.CCs[0]}
title={incident.title}
startDate={incident.start_time}
shortDescription={incident.short_description}
endDate={incident.end_time}
text={incident.short_description}
dates={
<Text color="gray6">
{incident.start_time && formatLongDate(incident.start_time, intl.locale)} - {incident.end_time ? formatLongDate(incident.end_time, intl.locale) : 'ongoing'}
</Text>
}
footer={
<Box textAlign="center" mt={2}>
<NLink href={`/incidents/${incident.id}`}>
<Button btnSize="small" hollow>Read More</Button>
</NLink>
</Box>
}
/>
))}
</StyledGrid>
Expand Down

0 comments on commit fae10a1

Please sign in to comment.