-
Notifications
You must be signed in to change notification settings - Fork 286
/
Copy pathIndex.svelte
129 lines (112 loc) · 3.24 KB
/
Index.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
<script lang="ts">
import AsciiPreview from './lib/AsciiPreview.svelte';
import data from '../../../languages.yaml';
import type { Languages, Language } from '../../../languages.yaml';
import { onMount } from 'svelte';
import { writable, derived } from 'svelte/store';
let tagName: string;
let htmlUrl: string;
const languages: Language[] = Object.entries(data as Languages).map(
([name, { type, ascii, colors }]) => ({
name,
type,
ascii,
colors,
})
);
const languageTypes: string[] = Array.from(
new Set<string>(Object.values(data as Languages).map(({ type }) => type))
);
const filter = writable({
checkboxes: languageTypes,
});
const filteredLanguages = derived(filter, ($filter) => {
return languages.filter(({ type }) => $filter.checkboxes.includes(type));
});
onMount(async () => {
const response = await fetch(
'https://api.github.com/repos/o2sh/onefetch/releases/latest'
);
const data = await response.json();
tagName = data.tag_name;
htmlUrl = data.html_url;
});
</script>
<header>
{#if tagName && htmlUrl}
<div class="banner">
<small
>Version {tagName} is available 🎉 Check the
<a href={htmlUrl}>release notes</a>!!</small>
</div>
{/if}
<h1>Onefetch</h1>
<p>
<small>
<a href="https://github.com/o2sh/onefetch/wiki">wiki</a> |
<a href="https://github.com/o2sh/onefetch/tree/main/docs/vercel"
>github</a>
| Built with ❤ by
<a href="https://github.com/spenserblack">@spenserblack</a> and
<a href="https://github.com/o2sh">@o2sh</a></small>
</p>
</header>
<main>
<p>
This page shows you an ASCII preview for all the programming languages
supported by onefetch. Like the binary, the data is taken from the <a
href="https://raw.githubusercontent.com/o2sh/onefetch/main/languages.yaml"
><code>Languages.yaml</code></a> file and the layout is meant to mimic the
way the logo would look inside a terminal.
</p>
<p>
Suggestions and PRs are welcome at <a
href="https://github.com/o2sh/onefetch">github.com/o2sh/onefetch</a>
</p>
<h3>Languages <small>({$filteredLanguages.length})</small></h3>
<strong>Filter by type</strong>
<div class="checkbox-group">
{#each languageTypes as type}
<label for={type}>
<input
id={type}
type="checkbox"
value={type}
bind:group={$filter.checkboxes} />
{type}
</label>
{/each}
</div>
<small
>Note: By default, onefetch will only recognize <strong>programming</strong>
and <strong>markup</strong> types. Use the
<code>--type</code> flag to configure.</small>
{#each $filteredLanguages as language}
<AsciiPreview
name={language.name}
ansi={language.colors.ansi}
hex={language.colors.hex}
ascii={language.ascii}
chip={language.colors.chip} />
{/each}
</main>
<style>
.banner {
background-color: #e1f6e5;
position: absolute;
top: 0;
left: 0;
width: 100%;
text-align: center;
padding: 0.5rem 0;
}
.checkbox-group {
margin-top: 1.5rem;
}
.checkbox-group label {
width: fit-content;
}
.checkbox-group label {
text-transform: capitalize;
}
</style>