web/src/components/things/PrivacyPolicyDetails.astro
187 lines · 4660 bytes
1---
2import type { PrivacyPolicyResponse } from '@utils/fetch-privacy-policy';
3
4import { formatDate, timeAgo } from '@utils/dates-n-stuff';
5import FontAwesome from "@components/form/FontAwesome.svelte"
6
7
8interface Props {
9 privacyData: PrivacyPolicyResponse;
10}
11
12const { privacyData } = Astro.props;
13
14const priv = privacyData.parameters;
15
16const getIconName = (clasification: string) => {
17 if (clasification === 'good') return 'faceGood';
18 if (clasification === 'neutral') return 'faceMeh';
19 if (clasification === 'bad') return 'faceBad';
20 return '';
21}
22
23// If two or more objects in privacyPolicy.points have the same title, remove the duplicates
24const removeDuplicates = () => {
25 const seen = new Set();
26 return priv.points = priv.points.filter((point) => {
27 if (seen.has(point.title)) {
28 return false;
29 }
30 seen.add(point.title);
31 return true;
32 });
33}
34
35---
36
37{priv && (
38<div class="privacy-policy-wrapper">
39
40 {(priv.points && priv.points.length) > 0 && (
41 <div class="left">
42 <h4>Privacy Policy Summary</h4>
43 <ul class="no-point">
44 {removeDuplicates().map((point) => (
45 <li class={`clasification ${point.case.classification}`}>
46 <FontAwesome iconName={getIconName(point.case.classification)} />
47 {point.title}
48 </li>
49 ))}
50 </ul>
51 </div>
52 )}
53
54 <div class="right">
55 { priv.rating && (
56 <h4>Score</h4>
57 <div class={`rating rating-${priv.rating}`}>
58 <p>{priv.rating}</p>
59 </div>
60 )}
61 {priv.documents && priv.documents.length > 0 && (
62 <h4>Documents</h4>
63 <ul>
64 {(priv.documents || []).map((document) => (
65 <li class="list-item">
66 <a href={document.url} target="_blank">{document.name}</a>
67 <div class="date-block">
68 Created {formatDate(document.created_at)},
69 Last modified {timeAgo(document.updated_at)}
70 </div>
71 </li>
72 ))}
73 </ul>
74 )}
75 {priv.urls && priv.urls.length > 1 && (
76 <h4>Domains Covered by Policy</h4>
77 <ul>
78 {priv.urls.map((url) => (
79 <li>{url}</li>
80 ))}
81 </ul>
82 )}
83 {priv.points && priv.points.length > 0 && (
84 <h4>About the Data</h4>
85 <p class="about-tosdr">
86 This data is kindly provided by <a href="https://tosdr.org/" target="_blank" rel="noopener noreferrer">tosdr.org</a>.
87 Read full report at: <a href={`https://tosdr.org/en/service/${priv.id}`} target="_blank" rel="noopener noreferrer">#{priv.id}</a>
88
89 </p>
90 )}
91 </div>
92</div>
93)}
94
95<style lang="scss">
96
97.privacy-policy-wrapper {
98 display: flex;
99 flex-wrap: wrap;
100 justify-content: space-between;
101 gap: var(--space-md);
102 .left, .right {
103 width: calc(50% - 1rem);
104 @media screen and (max-width: 768px){
105 width: 100%;
106 }
107 }
108}
109
110h4 {
111 margin: var(--space-md) 0 0 0;
112 font-size: var(--text-md);
113 }
114 p {
115 margin: 0;
116 display: flex;
117 align-items: center;
118 gap: var(--space-xs);
119 :global(svg) {
120 width: var(--text-base);
121 }
122 img {
123 border-radius: var(--curve-sm);
124 }
125 }
126 li {
127 :global(svg) {
128 width: var(--text-base);
129 margin-right: 0.2rem;
130 }
131 &.clasification {
132 &.good :global(svg) { color: var(--rating-a); }
133 &.neutral :global(svg) { color: var(--rating-neutral); }
134 &.bad :global(svg) { color: var(--rating-g); }
135 }
136 }
137 ul {
138 padding-left: var(--space-md);
139 list-style: circle;
140 max-height: 700px;
141 overflow-y: auto;
142 overflow-x: hidden;
143 img {
144 border-radius: var(--curve-sm);
145 }
146 .list-item {
147 display: flex;
148 flex-direction: column;
149 margin-bottom: var(--space-sm);
150 .date-block {
151
152 font-size: var(--text-sm);
153 opacity: var(--opacity-soft);
154 }
155 }
156 &.no-point {
157 list-style: none;
158 padding-left: var(--space-xs);
159 }
160 }
161
162 .rating {
163 font-size: 4rem;
164 width: fit-content;
165 padding: var(--space-sm) 1.5rem;
166 border-radius: var(--curve-lg);
167 border: 4px solid;
168 margin: 0 auto;
169 font-weight: bold;
170
171 &.rating-A { --rating-color: var(--rating-a); }
172 &.rating-B { --rating-color: var(--rating-b); }
173 &.rating-C { --rating-color: var(--rating-c); }
174 &.rating-D { --rating-color: var(--rating-d); }
175 &.rating-E { --rating-color: var(--rating-e); }
176 &.rating-F { --rating-color: var(--rating-f); }
177 &.rating-G { --rating-color: var(--rating-g); }
178 color: var(--rating-color);
179 border-color: var(--rating-color);
180 }
181
182 .about-tosdr {
183 display: inline;
184 font-size: var(--text-sm);
185 opacity: var(--opacity-soft);
186 }
187</style>