summaryrefslogtreecommitdiff
path: root/examples/hackernews/src/components/Story.astro
blob: e91748a30a4b224a04b41c2b0a0397807bab6237 (plain) (blame)
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
---
import type { IStory } from '../types.js';
import Show from './Show.astro';

interface Props {
	story: IStory;
}

const { story } = Astro.props;
---

<li>
	<span class="score">{story.points}</span>
	<span class="title">
		<Show when={story.url}>
			<a href={story.url} target="_blank" rel="noreferrer">
				{story.title}
			</a>
			<span class="host"> ({story.domain})</span>
			<a slot="fallback" href={`/item/${story.id}`}>{story.title}</a>
		</Show>
	</span>
	<br />
	<span class="meta">
		<Show when={story.type !== 'job'}>
			by <a href={`/users/${story.user}`}>{story.user}</a>{' '}
			{story.time_ago}{' '}|{' '}
			<a href={`/stories/${story.id}`}>
				{story.comments_count ? `${story.comments_count} comments` : 'discuss'}
			</a>
			<a slot="fallback" href={`/stories/${story.id}`}>{story.time_ago}</a>
		</Show>
	</span>
	<Show when={story.type !== 'link'}>
		&nbsp;
		<span class="label">{story.type}</span>
	</Show>
</li>

<style>
	li {
		background-color: rgb(248 250 252);
		padding: 20px 30px 20px 80px;
		border-bottom: 1px solid #eee;
		position: relative;
		line-height: 20px;
	}

	.score {
		color: rgb(88 28 135);
		font-size: 1.1em;
		font-weight: 700;
		position: absolute;
		top: 50%;
		left: 0;
		width: 80px;
		text-align: center;
		margin-top: -10px;
	}

	.host,
	.meta {
		font-size: 0.85em;
		color: rgb(51 65 85);
	}

	.host a,
	.meta a {
		color: rgb(51 65 85);
		text-decoration: underline;
	}

	.host a:hover,
	.meta a:hover {
		color: #335d92;
	}
</style>