-
Notifications
You must be signed in to change notification settings - Fork 21
/
+page.svelte
140 lines (133 loc) · 3.42 KB
/
+page.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<script lang="ts">
import oss from '$lib/oss.yml'
import Icon from '@iconify/svelte'
import { highlight_matches } from 'svelte-zoo'
import { flip } from 'svelte/animate'
let sort_by: 'commits' | 'stars' | 'alphabetical' = `commits`
const sort_by_options = [`commits`, `stars`, `alphabetical`] as const
$: projects = oss.projects
.filter((proj) => {
if (!query) return true
return JSON.stringify(proj).toLowerCase().includes(query.toLowerCase())
})
.sort((p1, p2) => {
if (sort_by === `alphabetical`) {
return p1.name.localeCompare(p2.name)
} else if ([`commits`, `stars`].includes(sort_by)) {
return p2[sort_by] - p1[sort_by]
} else {
throw new Error(`Unknown sort_by: ${sort_by}`)
}
})
let query = ``
</script>
<h2 class="section-title">
<Icon inline icon="ri:open-source-line" /> Open Source
</h2>
<ul class="buttons">
Sort by
{#each sort_by_options as title}
<button on:click={() => (sort_by = title)} class:active={sort_by === title}>
{title}
</button>
{/each}
<input type="text" placeholder="Search..." bind:value={query} />
</ul>
<ul class="projects grid" use:highlight_matches={{ query, css_class: `highlight-match` }}>
{#each projects as { url, repo, name, description, stars, logo, commits, role } (name)}
{@const logo_url = logo ?? `${url}/favicon.svg`}
<li animate:flip={{ duration: 400 }}>
<h3>
<a href={url ?? repo} target="_blank" rel="noreferrer">
<img src={logo_url} alt="{name} Logo" />
{name}
</a>
</h3>
<section>
{#if stars}
<a href="{repo}/stargazers">
<Icon inline icon="octicon:mark-github" />
{stars} ⭐
</a>
{/if}
{#if commits}
<a href="{repo}/commits?author=janosh">
<Icon inline icon="octicon:git-commit" />
<span>
{commits} <small>commits</small>
</span>
</a>
{/if}
<a href="{repo}/graphs/contributors">
<Icon inline icon="octicon:people-16" />
{role ?? (repo.includes(`/janosh/`) ? `Lead` : `Contributor`)}
</a>
</section>
<!-- <p class="langs">{languages.slice(0, 3).join(`, `)}</p> -->
<p>{description}</p>
</li>
{/each}
<li style="visibility: hidden;"></li>
<li style="visibility: hidden;"></li>
</ul>
<style>
h2 {
text-align: center;
}
h3 a {
display: flex;
place-items: center;
}
h3 img {
width: 3ex;
height: 3ex;
margin-right: 5pt;
}
section {
display: flex;
gap: 2pt 1em;
place-content: center;
place-items: center;
font-weight: 200;
font-size: 11pt;
flex-wrap: wrap;
}
section a {
display: flex;
gap: 1ex;
place-items: center;
color: inherit;
}
ul.buttons {
display: flex;
place-content: center;
gap: 9pt;
margin: auto;
}
button {
transition: background-color 0.2s ease-in-out;
}
button.active {
background-color: darkslategrey;
}
ul.projects {
margin: 1em auto 2em;
}
ul.projects > li {
display: grid;
gap: 12px;
grid-row: span 3;
grid-template-columns: subgrid;
grid-template-rows: subgrid;
background-color: rgba(255, 255, 255, 0.04);
padding: 9px 12px;
border-radius: 4pt;
}
p {
margin: 0;
font-size: 11pt;
font-weight: 250;
max-height: 6em;
overflow: scroll;
}
</style>