Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nerdfont iconts to the preview #1411

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/vercel/src/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
let showMenu: boolean;

const languages: Language[] = Object.entries(data as Languages).map(
([name, { type, ascii, colors }]) => ({
([name, { type, ascii, colors, icon }]) => ({
name,
type,
ascii,
colors,
icon,
})
);

Expand All @@ -30,6 +31,15 @@
return languages.filter(({ type }) => $filter.checkboxes.includes(type));
});

function escapeToUnicode(unicodeEscape: string): string {
if (unicodeEscape) {
let codePoint = parseInt(unicodeEscape.slice(3, -1), 16); // extract the relevent portion of the escape
return String.fromCodePoint(codePoint);
} else {
return '\u{25CF}';
}
}

onMount(async () => {
const response = await fetch(
'https://api.github.com/repos/o2sh/onefetch/releases/latest'
Expand Down Expand Up @@ -102,7 +112,8 @@
ansi={language.colors.ansi}
hex={language.colors.hex}
ascii={language.ascii}
chip={language.colors.chip} />
chipColor={language.colors.chip}
chipIcon={escapeToUnicode(language.icon)} />
{/each}
</main>

Expand Down
8 changes: 5 additions & 3 deletions docs/vercel/src/components/AsciiPreview.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script lang="ts">
import { mapToDefaultTerminalFgColor } from '../lib/utils';
import Chip from './Chip.svelte';
import TitleLink from './TitleLink.svelte';

export let name: string;
export let ansi: string[];
export let hex: string[] | null = null;
export let chip: string;
export let chipColor: string;
export let ascii: string = '';
export let chipIcon: string;

let dark = true;
let trueColor = hex != null;
Expand All @@ -32,7 +32,7 @@

<div class="title-row">
<div class="language-name">
<Chip id={name} color={chip} width={24} height={24} />
<h3 class="nerd-font" style="color: {chipColor}">{chipIcon}</h3>
<TitleLink {name} />
</div>
<div class="checkbox">
Expand All @@ -54,6 +54,8 @@
</div>

<style>
@import url('https://www.nerdfonts.com/assets/css/webfont.css');

.logo-container {
display: flex;
justify-content: center;
Expand Down
19 changes: 0 additions & 19 deletions docs/vercel/src/components/Chip.svelte

This file was deleted.

1 change: 1 addition & 0 deletions docs/vercel/src/yaml.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ declare module '*/languages.yaml' {
type: string;
ascii: string;
colors: LanguageColors;
icon: string;
}

export type Languages = Record<string, Language>;
Expand Down