-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNav.js
More file actions
79 lines (72 loc) · 1.68 KB
/
Nav.js
File metadata and controls
79 lines (72 loc) · 1.68 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
import { getUser, getUserScoreRatio } from "@/server/lib/dal"
import styled from "styled-components"
import Link from "next/link"
import { List, Plus, Play } from "@/components/icons"
const Container = styled.div`
position: fixed;
right: 20px;
bottom: 20px;
display: flex;
gap: 10px;
`
const User = styled(Link)`
height: 30px;
display: flex;
gap: 10px;
align-items: center;
background-color: rgba(255, ${({ $green }) => $green}, 0, 0.3);
border-radius: 15px;
color: white;
text-decoration: none;
`
const Color = styled.div`
height: 30px;
width: 30px;
background-color: rgb(255, ${({ $green }) => $green}, 0);
border-radius: 50%;
`
const Score = styled.span`
font-size: 1.2rem;
font-weight: bold;
padding-right: 15px;
`
const CircleLink = styled(Link)`
height: 30px;
width: 30px;
border-radius: 50%;
color: white;
text-decoration: none;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(255, 255, 255, 0.1);
& svg {
height: 20px;
width: 20px;
}
`
const HomeLink = styled(CircleLink)`
& svg {
transform: translateX(2px);
}
`
export default async function Nav() {
const [user, scoreRatio] = await Promise.all([getUser(), getUserScoreRatio()])
return (
<Container>
<User href={`/users/${user?.id}`} $green={255 * (1 - scoreRatio)}>
<Color $green={255 * (1 - scoreRatio)} />
<Score>{user?.score ?? 0}</Score>
</User>
<HomeLink href="/" prefetch={false}>
<Play />
</HomeLink>
<CircleLink href="/jokes" prefetch={false}>
<List />
</CircleLink>
<CircleLink href="/post">
<Plus />
</CircleLink>
</Container>
)
}