Skip to content

Commit

Permalink
feat: Replace tippy with custom tooltip component
Browse files Browse the repository at this point in the history
  • Loading branch information
kiosion committed Feb 16, 2024
1 parent eb093ae commit 93fc49b
Show file tree
Hide file tree
Showing 15 changed files with 297 additions and 125 deletions.
1 change: 0 additions & 1 deletion svelte-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"svelte-eslint-parser": "0.33.1",
"svelte-highlight": "7.6.0",
"tailwindcss": "3.4.1",
"tippy.js": "6.3.7",
"twemoji": "14.0.2",
"typescript": "5.3.3",
"vite": "5.1.1",
Expand Down
13 changes: 0 additions & 13 deletions svelte-app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions svelte-app/src/components/code-block.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { genericAsyncImport, getLangType } from '$components/code-block/imports';
import Icon from '$components/icon.svelte';
import Spinner from '$components/loading/spinner.svelte';
import Tooltip from '$components/tooltip.svelte';
import Tooltip from '$components/tooltips/tooltip.svelte';
import type { ResolvedComponentType } from '$components/code-block/imports';
import type { Unsubscriber } from 'svelte/store';
Expand Down Expand Up @@ -110,7 +110,7 @@
{filename}
</div>
{/if}
<Tooltip text={$t('Copy to clipboard')} delay={200} offset={[0, 2]} fixed>
<Tooltip text={$t('Copy to clipboard')} delay={200} offset={[0, 2]}>
<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 hover:text-dark/80 dark:text-light/60 dark:hover:text-light/80"
on:click={() => copy()}
Expand Down
4 changes: 1 addition & 3 deletions svelte-app/src/components/controls/language-toggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import Hoverable from '$components/hoverable.svelte';
import Icon from '$components/icon.svelte';
import Tooltip from '$components/tooltip.svelte';
import Tooltip from '$components/tooltips/tooltip.svelte';
const handleClick = (event: Event, lang: (typeof APP_LANGS)[number]) => {
event.preventDefault();
Expand All @@ -27,8 +27,6 @@
<Hoverable>
<Tooltip
text={$t($currentLang === APP_LANGS[0] ? 'Switch to French' : 'Switch to English')}
delay={150}
fixed
>
<button
aria-label={$t(
Expand Down
4 changes: 2 additions & 2 deletions svelte-app/src/components/controls/theme-toggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import Hoverable from '$components/hoverable.svelte';
import Icon from '$components/icon.svelte';
import Tooltip from '$components/tooltip.svelte';
import Tooltip from '$components/tooltips/tooltip.svelte';
const { theme } = Settings;
$: tooltipText = $theme === APP_THEMES.LIGHT ? 'Use dark mode' : 'Use light mode';
</script>

<Hoverable>
<Tooltip text={$t(tooltipText)} delay={150} fixed>
<Tooltip text={$t(tooltipText)}>
<button
aria-label={$t(tooltipText)}
data-test-id="theme-toggle"
Expand Down
11 changes: 3 additions & 8 deletions svelte-app/src/components/footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import Divider from '$components/divider.svelte';
import Icon from '$components/icon.svelte';
import BaseLink from '$components/nav/base-link.svelte';
import Tooltip from '$components/tooltip.svelte';
import Tooltip from '$components/tooltips/tooltip.svelte';
import type { SiteConfig } from '$types';
Expand All @@ -26,7 +26,7 @@
{#if socials?.length}
<div>
{#each socials as social, i}
<Tooltip text={social.url} delay={500} position="top" fixed>
<Tooltip text={social.url} delay={500} position="top">
<BaseLink
text={social.name}
href={social.url}
Expand All @@ -43,12 +43,7 @@
{/if}
{#if APP_VERSION?.length}
<div>
<Tooltip
text={$t('View latest commit on GitHub')}
position="top"
delay={150}
fixed
>
<Tooltip text={$t('View latest commit on GitHub')} position="top">
<BaseLink
target="_blank"
rel="noopener noreferrer"
Expand Down
3 changes: 1 addition & 2 deletions svelte-app/src/components/link.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { linkTo, t } from '$lib/i18n';
import Hoverable from '$components/hoverable.svelte';
import Tooltip from '$components/tooltip.svelte';
import Tooltip from '$components/tooltips/tooltip.svelte';
const dispatch = createEventDispatcher(),
type = $$props.href ? 'a' : 'button';
Expand All @@ -20,7 +20,6 @@
<Tooltip
text={link?.length > 50 ? `${link.slice(0, 50)}...` : link ?? $t('Visit')}
delay={500}
fixed
>
<svelte:element
this={type}
Expand Down
4 changes: 2 additions & 2 deletions svelte-app/src/components/portable-text/footnote.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { t } from '$lib/i18n';
import Tooltip from '$components/tooltip.svelte';
import Tooltip from '$components/tooltips/tooltip.svelte';
import type { MarkComponentProps } from '@portabletext/svelte';
import type {
Expand Down Expand Up @@ -38,7 +38,7 @@

<span>
<slot />&nbsp;
<Tooltip text={$t('Go to footnote')} delay={200}>
<Tooltip text={$t('Go to footnote')}>
<sup
><a
href={`#note-${portableText.value._key}`}
Expand Down
4 changes: 2 additions & 2 deletions svelte-app/src/components/portable-text/portable-text.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import NullMark from '$components/portable-text/serializers/null-mark.svelte';
import OlWrapper from '$components/portable-text/serializers/ol-wrapper.svelte';
import UlWrapper from '$components/portable-text/serializers/ul-wrapper.svelte';
import Tooltip from '$components/tooltip.svelte';
import Tooltip from '$components/tooltips/tooltip.svelte';
import { PortableText } from '@portabletext/svelte';
Expand Down Expand Up @@ -143,7 +143,7 @@
<li class="list-item">
<span class="flex flex-row flex-wrap items-center break-all">
<svelte:self text={note.note} plaintext />
<Tooltip text={$t('Go to footnote source')} delay={200}>
<Tooltip text={$t('Go to footnote source')}>
<a
class="ml-2"
href={`#src-${note._key}`}
Expand Down
90 changes: 0 additions & 90 deletions svelte-app/src/components/tooltip.svelte

This file was deleted.

Loading

0 comments on commit 93fc49b

Please sign in to comment.