forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuidanceTagDetails.js
More file actions
96 lines (89 loc) · 2.77 KB
/
GuidanceTagDetails.js
File metadata and controls
96 lines (89 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import React from 'react'
import { object, string } from 'prop-types'
import { Box, Icon, Link, Stack, Text } from '@chakra-ui/core'
import { Trans } from '@lingui/macro'
export function GuidanceTagDetails({ guidanceTag, tagType }) {
const cccsGuidance =
guidanceTag.refLinks[0]?.description !== null &&
guidanceTag.refLinks.length !== 0 ? (
<Stack isInline={guidanceTag.refLinks.length <= 1}>
<Text fontWeight="bold">
<Trans>For in-depth CCCS implementation guidance:</Trans>
</Text>
{guidanceTag.refLinks.map((node, index) => (
<Link
key={index}
color="teal.600"
href={node.refLink}
target="_blank"
>
<Stack isInline spacing="2px" align="center">
<Text>{node.description}</Text>
<Icon name="external-link" />
</Stack>
</Link>
))}
</Stack>
) : (
''
)
const technicalGuidance =
guidanceTag.refLinksTech.length !== 0 &&
guidanceTag.refLinksTech[0]?.description !== null ? (
<Stack isInline={guidanceTag.refLinksTech.length <= 1}>
<Text fontWeight="bold">
<Trans>For technical implementation guidance:</Trans>
</Text>
{guidanceTag.refLinksTech.map((node, index) => (
<Link
key={index}
color="teal.600"
href={node.refLink}
target="_blank"
>
<Stack isInline spacing="2px" align="center">
<Text>{node.description}</Text>
<Icon name="external-link" />
</Stack>
</Link>
))}
</Stack>
) : (
''
)
const smallDevice = window.matchMedia('(max-width: 500px)').matches
const negativeIcon = <Icon name="warning" color="weak" />
const neutralIcon = <Icon name="info" color="info" />
const positiveIcon = <Icon name="check-circle" color="strong" />
const tagIcon = () => {
if (tagType === 'negative') return negativeIcon
else if (tagType === 'neutral') return neutralIcon
else if (tagType === 'positive') return positiveIcon
}
return (
<Stack isInline align="center" px="2" pt={['2', '0']}>
{!smallDevice && tagIcon()}
<Box>
<Stack isInline align="center">
{smallDevice && tagIcon()}
<Text fontWeight="bold">
<Trans>Result:</Trans>
</Text>
<Text>{guidanceTag.tagName}</Text>
</Stack>
<Stack isInline>
<Text fontWeight="bold">
<Trans>Guidance:</Trans>
</Text>
<Text>{guidanceTag.guidance}</Text>
</Stack>
{cccsGuidance}
{technicalGuidance}
</Box>
</Stack>
)
}
GuidanceTagDetails.propTypes = {
guidanceTag: object,
tagType: string,
}