This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
COR-990 the topical page component (#4363)
* the topical page component * Restore old topical-tile component * Fixed data input instead of static mockup * fixed width and height * set right padding for kpiIcon * Update packages/app/src/domain/topical/components/topical-tile/index.ts Thanks for noticing Co-authored-by: MN <[email protected]> * Update packages/app/src/domain/topical/components/topical-tile/topical-tile.tsx Nice, I bet it's from some old mockup. Co-authored-by: MN <[email protected]> Co-authored-by: MN <[email protected]>
- Loading branch information
1 parent
ab5cb1a
commit 60540f1
Showing
3 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
packages/app/src/domain/topical/components/topical-tile/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './topical-tile'; |
137 changes: 137 additions & 0 deletions
137
packages/app/src/domain/topical/components/topical-tile/topical-tile.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
import { Box } from '~/components/base'; | ||
import css from '@styled-system/css'; | ||
import styled from 'styled-components'; | ||
import { Heading } from '~/components/typography'; | ||
import { LinkWithIcon } from '~/components/link-with-icon'; | ||
import { asResponsiveArray } from '~/style/utils'; | ||
import { colors } from '@corona-dashboard/common'; | ||
import DynamicIcon from '~/components/get-icon-by-name'; | ||
import { Chevron, Down, Up } from '@corona-dashboard/icons'; | ||
import { Markdown } from '~/components/markdown'; | ||
import { TopicalIcon } from '@corona-dashboard/common/src/types'; | ||
import { isDefined } from 'ts-is-present'; | ||
|
||
interface IconWrapperProps { | ||
iconColor: string; | ||
} | ||
|
||
type TrendIcon = { | ||
direction: 'UP' | 'DOWN'; | ||
color: 'GREEN' | 'RED'; | ||
} | null; | ||
|
||
type Cta = { | ||
label: string; | ||
href: string; | ||
} | null; | ||
|
||
interface TopicalTileProps { | ||
title: string; | ||
tileIcon: TopicalIcon; | ||
trendIcon?: TrendIcon; | ||
dynamicDescription: string; | ||
cta?: Cta; | ||
} | ||
|
||
export function TopicalTile({ | ||
title, | ||
tileIcon, | ||
trendIcon, | ||
dynamicDescription, | ||
cta, | ||
}: TopicalTileProps) { | ||
return ( | ||
<Box | ||
spacing={3} | ||
borderColor={colors.gray} | ||
borderWidth="1px" | ||
borderStyle="solid" | ||
position="relative" | ||
display="flex" | ||
flexDirection={'column'} | ||
justifyContent={'space-between'} | ||
> | ||
<Box | ||
display="flex" | ||
flexDirection={'column'} | ||
justifyContent={'start'} | ||
textAlign={'left'} | ||
p={{ _: 3, xs: 4 }} | ||
> | ||
<KpiIcon> | ||
<DynamicIcon name={tileIcon} /> | ||
</KpiIcon> | ||
|
||
<Box | ||
display="block" | ||
fontSize={{ _: 6, xs: 7 }} | ||
paddingRight={5} | ||
marginBottom={3} | ||
> | ||
<Heading | ||
level={3} | ||
color={colors.blue} | ||
css={css({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
})} | ||
> | ||
{title} | ||
{isDefined(trendIcon) && trendIcon !== null && ( | ||
<IconWrapper iconColor={trendIcon.color}> | ||
{trendIcon.direction === 'DOWN' && <Down />} | ||
{trendIcon.direction === 'UP' && <Up />} | ||
</IconWrapper> | ||
)} | ||
</Heading> | ||
</Box> | ||
|
||
<Box display="flex" alignItems={'center'}> | ||
<Markdown content={dynamicDescription} /> | ||
</Box> | ||
</Box> | ||
|
||
<Box | ||
display="flex" | ||
justifyContent={'center'} | ||
bg={colors.lightBlue} | ||
color={colors.blue} | ||
padding={3} | ||
> | ||
{isDefined(cta) && cta !== null && ( | ||
<LinkWithIcon | ||
href={cta.href} | ||
icon={<Chevron />} | ||
iconPlacement="right" | ||
> | ||
{cta.label} | ||
</LinkWithIcon> | ||
)} | ||
</Box> | ||
</Box> | ||
); | ||
} | ||
|
||
const IconWrapper = styled.span<IconWrapperProps>((x) => | ||
css({ | ||
color: x.iconColor, | ||
display: 'inline-flex', | ||
alignItems: 'center', | ||
width: '20px', | ||
marginLeft: '15px;', | ||
}) | ||
); | ||
|
||
const KpiIcon = styled.span( | ||
css({ | ||
color: colors.white, | ||
backgroundColor: colors.blue, | ||
position: 'absolute', | ||
display: 'block', | ||
width: asResponsiveArray({ _: 40, sm: 50 }), | ||
height: asResponsiveArray({ _: 40, sm: 50 }), | ||
right: 0, | ||
top: 0, | ||
padding: asResponsiveArray(2), | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters