-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeopleListItem.svelte
53 lines (48 loc) · 1.13 KB
/
PeopleListItem.svelte
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
<script>
// here we render a link to a single person. the active person
// should be highlighted with a red border.
import { isActive } from "@roxi/routify";
export let person;
export let personId;
// create the permalink for this user
$: permalink = `/${personId}`;
// attempt to detect the active person via reactive statement
$: isPersonActive = $isActive(permalink);
</script>
<!--
the active class should be applied to the li when we are
on the route for this user!
-->
<li class:active={$isActive(permalink)}>
<a href={permalink}>
<img src={person.picture.thumbnail} alt={person.name.first} />
{person.name.first}
{person.name.last}
<!-- the active should also be applied here! -->
<span class="bubble" class:active={isPersonActive}>◉</span>
</a>
</li>
<style>
li {
margin: 0;
padding: 0;
text-indent: 0;
list-style-type: none;
display: block;
border: 2px solid lightblue;
}
li.active {
border: 2px solid red;
}
li img {
height: 24px;
width: 24px;
}
.bubble {
color: lightblue;
float: right;
}
.bubble.active {
color: red;
}
</style>