Commit 94966dc256

94966dc256c8c29f842fa08f5a63d43290cf68a9

parent: 90cdaed1fb

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-24 13:00 UTC

Writes component to show reddit info

Layout: unified · split

web/src/components/things/RedditDetailedInfo.astro added +164
@@ -0,0 +1,164 @@
1---
2
3import type { RedditData } from '@utils/fetch-reddit-info';
4import { timestampToDate, timeAgo } from '@utils/dates-n-stuff';
5import FontAwesome from "@components/form/FontAwesome.svelte"
6
7
8interface Props {
9 redditData: RedditData;
10};
11
12const { redditData } = Astro.props;
13
14
15---
16
17<div class="reddit-info-wrapper">
18 <h3>Reddit</h3>
19
20 <p class="website-title">
21 <img src={redditData.info.icon} width="16" />
22 {redditData.info.title || redditData.info.name}
23 </p>
24 <p class="website-description">{redditData.info.description}</p>
25 {redditData.info.banner && (<img class="banner" width="300" src={redditData.info.banner} alt="Banner" />)}
26 <ul class="list-table">
27 {redditData.info.dateCreated && (
28 <li>
29 <span class="lbl">Created at</span>
30 <span class="val">{timestampToDate(redditData.info.dateCreated * 1000)}</span>
31 </li>
32 )}
33 <li>
34 <span class="lbl">Members</span>
35 <span class="val">{redditData.info.subscribers}</span>
36 </li>
37 <li>
38 <span class="lbl">Join</span>
39 <span class="val"><a href={`https://reddit.com/${redditData.info.name}`}>{redditData.info.name}</a></span>
40 </li>
41 </ul>
42
43 <h4>Posts</h4>
44 <ul class="posts">
45 {redditData.posts.map((post) => (
46 <li title={post.body}>
47 ○ <a href={post.url} target="_blank">{post.title}</a>
48 <span class="votes">(▲ {post.upVotes} ▼ {post.downVotes})</span>
49 </li>
50 ))}
51 </ul>
52</div>
53
54
55<style lang="scss">
56.reddit-info-wrapper {
57 display: flex;
58 flex-direction: column;
59 max-width: 500px;
60}
61
62.banner {
63 margin: 0.5rem auto;
64 border-radius: var(--curve-md);
65 width: 100%;
66}
67
68h3 {
69 margin: 0 0 1rem 0;
70 font-size: 1.6rem;
71}
72
73h4 {
74 margin: 1rem 0 0 0;
75 font-size: 1.2rem;
76}
77p {
78 margin: 0;
79 display: flex;
80 align-items: center;
81 gap: 0.25rem;
82 :global(svg) {
83 width: 1rem;
84 }
85 img {
86 border-radius: var(--curve-sm);
87 }
88}
89
90ul {
91 padding-left: 0;
92 list-style: none;
93 max-height: 300px;
94 overflow-y: auto;
95 overflow-x: hidden;
96 img {
97 border-radius: var(--curve-sm);
98 }
99 .list-item {
100 display: flex;
101 flex-direction: column;
102 margin-bottom: 0.5rem;
103 }
104 &.list-table {
105 font-size: 0.9rem;
106 padding-left: 0;
107 li {
108 display: flex;
109 justify-content: space-between;
110 padding: 0.1rem 0;
111 .lbl {
112 font-weight: 400;
113 }
114 &:not(:last-child) {
115 border-bottom: 1px solid #5f53f440;
116 }
117 }
118 }
119}
120
121.posts {
122 list-style: circle;
123 padding-left: 1rem;
124 font-size: 0.9rem;
125 li {
126 display: -webkit-box;
127 -webkit-line-clamp: 1;
128 -webkit-box-orient: vertical;
129 overflow: hidden;
130 a {
131 max-width: 80%;
132 }
133 .votes {
134 font-size: 0.8rem;
135 opacity: 0.5;
136 }
137 }
138}
139
140.website-title, .website-description {
141 font-size: 0.9rem;
142 opacity: 0.8;
143 display: -webkit-box;
144 -webkit-line-clamp: 1;
145 -webkit-box-orient: vertical;
146 overflow: hidden;
147 border-left: 2px solid var(--accent-3);
148 padding-left: 0.5rem;
149}
150.website-title {
151 font-weight: 500;
152}
153.website-description {
154 font-style: italic;
155 -webkit-line-clamp: 3;
156}
157.explainer {
158 font-size: 0.8rem;
159 opacity: 0.8;
160 font-style: italic;
161}
162
163
164</style>