Skip to content

Commit

Permalink
chore: More misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kiosion committed Sep 22, 2023
1 parent e72a95b commit 629ac88
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 178 deletions.
2 changes: 1 addition & 1 deletion svelte-app/src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ img {
body {
@apply h-full w-full overflow-x-hidden;

background-color: $dark;
background-color: $black;
--textColour: $light;

&.light {
Expand Down
6 changes: 3 additions & 3 deletions svelte-app/src/components/about/timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import Hoverable from '$components/hoverable.svelte';
import Icon from '$components/icon.svelte';
import PortableText from '$components/portable-text/portable-text.svelte';
import Tags from '$components/tags.svelte';
// import Tags from '$components/tags.svelte';
import Tooltip from '$components/tooltip.svelte';
import type { AuthorTimelineItem } from '$types';
Expand Down Expand Up @@ -111,9 +111,9 @@
easing: circInOut
}}
>
{#if item.skills}
<!-- {#if item.skills}
<Tags model="project" data={item.skills} class="mt-4 select-none" />
{/if}
{/if} -->
<div class="-mb-5">
<PortableText text={item.body} />
</div>
Expand Down
14 changes: 5 additions & 9 deletions svelte-app/src/components/code-block.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</svelte:head>

<div
class="relative -mx-1 my-7 overflow-hidden rounded-sm border border-dark/40 duration-150 dark:border-light/40 {hovered
class="relative -mx-1 my-7 overflow-hidden rounded-sm border border-dark/40 duration-75 dark:border-light/40 {hovered
? 'border-dark/60 dark:border-light/60'
: ''}"
role="group"
Expand All @@ -134,7 +134,7 @@
>
{#if filename}
<div
class="border-b border-dark/40 bg-dark/5 py-[13px] pl-5 font-mono text-base duration-150 dark:border-light/40 dark:bg-dark/40 {hovered
class="border-b border-dark/40 bg-dark/5 py-[13px] pl-5 font-mono text-base duration-75 dark:border-light/40 dark:bg-dark/40 {hovered
? 'border-dark/60 dark:border-light/60'
: ''}"
id="{id}-filename"
Expand All @@ -143,10 +143,10 @@
</div>
{/if}
<Hoverable>
<Tooltip text={$t('Copy to clipboard')} position="left" delay={150} fixed>
<Tooltip text={$t('Copy to clipboard')} position="left" delay={200} fixed>
{#key copied}
<button
class="focusOutline-sm absolute right-0 top-0 z-[2] cursor-pointer rounded-sm pb-3 pl-3 pr-4 pt-4 text-dark/60 opacity-0 transition-opacity duration-150 hover:text-dark dark:text-light/60 dark:hover:text-light"
class="focusOutline-sm absolute right-0 top-0 z-[2] cursor-pointer rounded-sm pb-3 pl-3 pr-4 pt-4 text-dark/60 opacity-0 transition-opacity duration-75 hover:text-dark dark:text-light/60 dark:hover:text-light"
class:opacity-100={hovered || filename}
on:click={() => copy()}
in:fade={{ duration: 100, delay: 100 }}
Expand All @@ -162,9 +162,7 @@
bind:this={codeContainer}
>
<div
class="h-fit w-full min-w-full rounded-sm p-1 transition-all dark:bg-dark/10 {hovered
? 'bg-dark/[0.025] dark:bg-light/5'
: ''}"
class="h-fit w-full min-w-full rounded-sm p-1 transition-all dark:bg-dark/10"
id="hljs-container"
bind:clientHeight={innerHeight}
>
Expand All @@ -181,8 +179,6 @@
<svelte:component this={hlAuto} code={content} />
{:else}
{#await hlLang then resolvedLang}
<!-- <div class="mx-auto my-4 w-fit"><Spinner /></div> -->
<!-- {:then resolvedLang} -->
{#if showLineNumbers === true}
<svelte:component
this={hlHighlight}
Expand Down
29 changes: 29 additions & 0 deletions svelte-app/src/components/controls/arrow-button.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher(),
self = $$props.href ? 'a' : 'button',
handleClick = (e: MouseEvent | KeyboardEvent) => {
if (e instanceof KeyboardEvent && e.key !== 'Enter') {
return;
}
dispatch('click');
};
</script>

<svelte:element
this={self}
href={$$props.href || undefined}
class="inline-block font-code text-accent-light hover:text-dark dark:text-accent-dark dark:hover:text-light {$$props.class ||
''}"
aria-label={$$props['aria-label'] || undefined}
role="button"
tabindex="0"
on:click={handleClick}
on:keydown={handleClick}
data-sveltekit-preload-code={$$props.preload ? 'hover' : 'off'}
data-sveltekit-preload-data={$$props.preload ? 'hover' : 'off'}
>
<slot />
</svelte:element>
13 changes: 6 additions & 7 deletions svelte-app/src/components/document/content/common/footer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { linkTo, t } from '$i18n';
import ArrowButton from '$components/controls/arrow-button.svelte';
import Divider from '$components/divider.svelte';
import type { PostDocument, ProjectDocument } from '$types';
Expand All @@ -11,13 +12,11 @@

<div class="mt-4">
<Divider />
<a
<ArrowButton
class="w-full text-right"
href={$linkTo(model === 'post' ? '/blog' : '/work')}
class="focusOutline inline-block w-full rounded-sm pl-[8px] text-right font-code text-accent-light hover:text-dark dark:text-accent-dark dark:hover:text-light"
aria-label={$t('See more')}
data-sveltekit-preload-code
data-sveltekit-preload-data
preload
>
&larr; Read more
</a>
&larr; {$t('Read more')}
</ArrowButton>
</div>
56 changes: 36 additions & 20 deletions svelte-app/src/components/document/content/common/header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
import { currentLang, t } from '$i18n';
import BulletPoint from '$components/bullet-point.svelte';
import ArrowButton from '$components/controls/arrow-button.svelte';
import Divider from '$components/divider.svelte';
import SummaryItems from '$components/document/content/common/summary/items.svelte';
import PostHeader from '$components/document/content/post/header.svelte';
import ProjectHeader from '$components/document/content/project/header.svelte';
import Hoverable from '$components/hoverable.svelte';
import Tags from '$components/tags.svelte';
import type { PostDocument, ProjectDocument, PTBlock } from '$types';
import type { DocumentHeadings, PostDocument, ProjectDocument, PTBlock } from '$types';
export let model: 'post' | 'project', data: PostDocument | ProjectDocument;
export let data: PostDocument | ProjectDocument,
model = data._type,
headings: DocumentHeadings[] | undefined;
let dateFormat: 'med' | 'rel' | 'full' = model === 'project' ? 'med' : 'rel',
readingTime = getReadingTime(getTotalWords((data?.body ?? []) as PTBlock[]));
readingTime = getReadingTime(getTotalWords((data?.body ?? []) as PTBlock[])),
summaryExpanded = false;
const switchDate = () => {
if (model === 'project') {
Expand Down Expand Up @@ -44,27 +48,39 @@
</h1>
</svelte:fragment>
<svelte:fragment slot="meta">
<div class="flex flex-row flex-wrap items-center justify-start gap-y-2">
<Hoverable>
<button
class="focusOutline inline cursor-pointer rounded-sm font-mono text-base"
on:click={() => switchDate()}
tabindex="0"
>
{date ? date : $t('Unknown date')}
</button>
</Hoverable>
<BulletPoint />
<p class="cursor-default font-mono text-base">
{$t('{length} min read', { length: Math.floor(readingTime / 60) })}
</p>
{#if data.tags && data.tags.length > 0}
<div class="flex flex-row items-center justify-between">
<div class="flex flex-row flex-wrap items-center justify-start gap-y-2">
<Hoverable>
<button
class="focusOutline inline cursor-pointer rounded-sm font-mono text-base"
on:click={() => switchDate()}
tabindex="0"
>
{date ? date : $t('Unknown date')}
</button>
</Hoverable>
<BulletPoint />
<Tags {model} data={data.tags} size="sm" />
<p class="cursor-default font-mono text-base">
{$t('{length} min read', { length: Math.floor(readingTime / 60) })}
</p>
</div>
{#if headings?.length}
<ArrowButton
class="text-right"
on:click={() => (summaryExpanded = !summaryExpanded)}
>
<span class="inline-block {summaryExpanded ? 'rotate-90' : '-rotate-90'}"
>&larr;</span
>
{$t(summaryExpanded ? 'Hide Contents' : 'Show Contents')}
</ArrowButton>
{/if}
</div>
</svelte:fragment>
</svelte:component>
</div>
{#if headings?.length && summaryExpanded}
<SummaryItems {headings} />
{/if}
<Divider />
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import Heading from '$components/document/content/common/summary/heading.svelte';
import Items from '$components/document/content/common/summary/items.svelte';
import Heading from '$components/document/content/common/summary_old/heading.svelte';
import Items from '$components/document/content/common/summary_old/items.svelte';
import type { DocumentHeadings } from '$types';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,47 +1,19 @@
<script lang="ts">
import BulletPoint from '$components/bullet-point.svelte';
import Hoverable from '$components/hoverable.svelte';
import type { DocumentHeadings } from '$types';
export let headings: DocumentHeadings[];
$: localHeadings = headings as (DocumentHeadings & { active: boolean })[];
</script>

<div
class="relative flex h-fit w-full flex-col items-start justify-start text-ellipsis {$$props.class ||
''}"
>
{#each localHeadings as heading}
<Hoverable bind:hovered={heading.active}>
<a href={`#${heading.key}`} class="focusOutline-sm" class:active={heading.active}>
<BulletPoint />
{heading.text}
</a>
</Hoverable>
<div class={$$props.class}>
{#each headings as heading}
<a
href={`#${heading.key}`}
class="focusOutline-sm block w-full select-none overflow-hidden text-ellipsis whitespace-nowrap rounded-sm py-2 text-base font-medium hover:text-accent-light dark:hover:text-accent-dark"
>
&bull;&nbsp;&nbsp;{heading.text}
</a>
{#if heading.children?.length}
<svelte:self headings={heading.children} class="ml-6" />
<svelte:self headings={heading.children} class="ml-5" />
{/if}
{/each}
</div>

<style lang="scss">
a {
@apply ml-3 flex w-full select-none flex-row items-center gap-1 overflow-hidden text-ellipsis whitespace-nowrap rounded-sm py-[.65rem] text-[15px] text-sm font-medium text-dark/80 transition-[color];
&.active {
@apply text-dark;
}
}
:global(.dark) {
a {
@apply text-light/80;
&.active {
@apply text-light;
}
}
}
</style>
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<script lang="ts">
import { circInOut } from 'svelte/easing';
import { cubicInOut } from 'svelte/easing';
import { slide } from 'svelte/transition';
import Divider from '$components/divider.svelte';
import Item from '$components/document/content/common/summary/item.svelte';
import SummaryItem from '$components/document/content/common/summary/item.svelte';
import type { DocumentHeadings } from '$types';
export let headings: DocumentHeadings[],
headingsExist = false;
export let headings: DocumentHeadings[];
</script>

<div
class="mx-7 h-fit overflow-hidden px-1 pb-3"
transition:slide={{ duration: 200 + headings.length * 10, easing: circInOut }}
class="relative my-6 border-t border-dark/50 px-4 pt-4 dark:border-light/50"
transition:slide={{
duration: 250 + headings.length * 10,
easing: cubicInOut
}}
>
<Divider classes="mb-3 mt-0" />

{#if headingsExist}
<Item {headings} />
{/if}
<SummaryItem {headings} />
</div>
10 changes: 1 addition & 9 deletions svelte-app/src/components/document/content/content.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<script lang="ts">
import Divider from '$components/divider.svelte';
import Footer from '$components/document/content/common/footer.svelte';
import Header from '$components/document/content/common/header.svelte';
import Summary from '$components/document/content/common/summary.svelte';
import EmptyContent from '$components/empty-content.svelte';
import PortableText from '$components/portable-text/portable-text.svelte';
Expand All @@ -20,13 +18,7 @@
container: HTMLDivElement | undefined = undefined;
</script>

<Header {model} {data} />
{#if headings && headings.length > 0}
<div>
<Summary {headings} />
<Divider />
</div>
{/if}
<Header {data} {headings} />
<div class="mt-4 font-sans text-base" bind:this={container}>
{#if data.body}
<PortableText text={data.body} {routeFetch} />
Expand Down
Loading

0 comments on commit 629ac88

Please sign in to comment.