web/src/components/things/PrivacyPolicyDetails.astro

175 lines · 4017 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---
 24
 25{priv && (
 26<div class="privacy-policy-wrapper">
 27  
 28  {(priv.points && priv.points.length) > 0 && (
 29    <div class="left">
 30      <h4>Privacy Policy Summary</h4>
 31      <ul class="no-point">
 32        {priv.points.map((point) => (
 33          <li class={`clasification ${point.case.classification}`}>
 34            <FontAwesome iconName={getIconName(point.case.classification)} />
 35            {point.title}
 36          </li>
 37        ))}
 38      </ul>
 39    </div>
 40  )}
 41  
 42  <div class="right">
 43    { priv.rating && (
 44      <h4>Score</h4>
 45      <div class={`rating rating-${priv.rating}`}>
 46        <p>{priv.rating}</p>
 47      </div>
 48    )}
 49    {priv.documents && priv.documents.length > 0 && (
 50      <h4>Documents</h4>
 51      <ul>
 52        {priv.documents.map((document) => (
 53          <li class="list-item">
 54            <a href={document.url} target="_blank">{document.name}</a>
 55            <div class="date-block">
 56              Created {formatDate(document.created_at)},
 57              Last modified {timeAgo(document.updated_at)}
 58            </div>
 59          </li>
 60        ))}
 61      </ul>
 62    )}
 63    {priv.urls && priv.urls.length > 1 && (
 64      <h4>Domains Covered by Policy</h4>
 65      <ul>
 66        {priv.urls.map((url) => (
 67          <li>{url}</li>
 68        ))}
 69      </ul>
 70    )}
 71    {priv.points && priv.points.length > 0 && (
 72      <h4>About the Data</h4>
 73      <p class="about-tosdr">
 74        This data is kindly provided by <a href="https://tosdr.org/">tosdr.org</a>.
 75        Read full report at: <a href={`https://tosdr.org/en/service/${priv.id}`}>#{priv.id}</a>
 76      
 77        </p>
 78    )}
 79  </div>
 80</div>
 81)}
 82
 83<style lang="scss">
 84
 85.privacy-policy-wrapper {
 86  display: flex;
 87  flex-wrap: wrap;
 88  justify-content: space-between;
 89  gap: 1rem;
 90  .left, .right {
 91    width: calc(50% - 1rem);
 92    @media screen and (max-width: 768px){
 93      width: 100%;
 94    }
 95  }
 96}
 97
 98h4 {
 99    margin: 1rem 0 0 0;
100    font-size: 1.2rem;
101  }
102  p {
103    margin: 0;
104    display: flex;
105    align-items: center;
106    gap: 0.25rem;
107    :global(svg) {
108      width: 1rem;
109    }
110    img {
111      border-radius: var(--curve-sm);
112    }
113  }
114  li {
115    :global(svg) {
116      width: 1rem;
117      margin-right: 0.2rem;
118    }
119    &.clasification {
120      &.good :global(svg) { color: #35b969; }
121      &.neutral :global(svg) { color: #ecd40f; }
122      &.bad :global(svg) { color: #e3154f; }
123    }
124  }
125  ul {
126    padding-left: 1rem;
127    list-style: circle;
128    max-height: 700px;
129    overflow-y: auto;
130    overflow-x: hidden;
131    img {
132      border-radius: var(--curve-sm);
133    }
134    .list-item {
135      display: flex;
136      flex-direction: column;
137      margin-bottom: 0.5rem;
138      .date-block {
139        
140        font-size: 0.8rem;
141        opacity: 0.7;
142      }
143    }
144    &.no-point {
145      list-style: none;
146      padding-left: 0.25rem;
147    }
148  }
149
150  .rating {
151    font-size: 4rem;
152    width: fit-content;
153    padding: 0.5rem 1.5rem;
154    border-radius: var(--curve-lg);
155    border: 4px solid;
156    margin: 0 auto;
157    font-weight: bold;
158
159    &.rating-A { --rating-color: #35b969; }
160    &.rating-B { --rating-color: #6bb935; }
161    &.rating-C { --rating-color: #c7cc22; }
162    &.rating-D { --rating-color: #e1bb23; }
163    &.rating-E { --rating-color: #df8b1e; }
164    &.rating-F { --rating-color: #df541e; }
165    &.rating-G { --rating-color: #df1e1e; }
166    color: var(--rating-color);
167    border-color: var(--rating-color);
168  }
169
170  .about-tosdr {
171    display: inline;
172    font-size: 0.8rem;
173    opacity: 0.7;
174  }
175</style>