2024-06-24 15:42:31 +02:00
|
|
|
<script lang="ts">
|
2024-07-07 17:51:46 +02:00
|
|
|
import { page } from "$app/stores";
|
2024-08-31 11:32:02 +02:00
|
|
|
import { t } from "$lib/i18n/translations";
|
2024-09-17 16:05:25 +02:00
|
|
|
import { copyURL as _copyURL } from "$lib/download";
|
|
|
|
import CopyIcon from "$components/misc/CopyIcon.svelte";
|
2024-07-07 17:51:46 +02:00
|
|
|
|
2024-06-24 19:05:51 +02:00
|
|
|
export let title: string;
|
2024-08-30 13:15:05 +02:00
|
|
|
export let sectionId: string;
|
|
|
|
|
|
|
|
export let disabled = false;
|
2024-08-31 11:32:02 +02:00
|
|
|
export let beta = false;
|
2024-07-07 17:51:46 +02:00
|
|
|
|
2024-09-08 20:10:53 +02:00
|
|
|
let focus = false;
|
2024-09-17 16:05:25 +02:00
|
|
|
let animate = false;
|
|
|
|
let copied = false;
|
|
|
|
let showCopy = false;
|
|
|
|
|
|
|
|
const copyURL = () => _copyURL(`${$page.url.origin}${$page.url.pathname}#${sectionId}`);
|
2024-07-07 17:51:46 +02:00
|
|
|
|
|
|
|
$: hash = $page.url.hash.replace("#", "");
|
|
|
|
|
|
|
|
$: if (hash === sectionId) {
|
2024-09-08 20:10:53 +02:00
|
|
|
focus = true;
|
2024-07-07 17:51:46 +02:00
|
|
|
}
|
2024-09-17 16:05:25 +02:00
|
|
|
|
|
|
|
$: if (copied) {
|
|
|
|
setTimeout(() => {
|
|
|
|
copied = false;
|
|
|
|
}, 1500);
|
|
|
|
}
|
2024-06-24 15:42:31 +02:00
|
|
|
</script>
|
|
|
|
|
2024-07-07 17:51:46 +02:00
|
|
|
<section
|
|
|
|
id={sectionId}
|
|
|
|
class="settings-content"
|
2024-09-08 20:10:53 +02:00
|
|
|
class:focus
|
2024-08-30 13:15:05 +02:00
|
|
|
class:disabled
|
|
|
|
aria-hidden={disabled}
|
2024-07-07 17:51:46 +02:00
|
|
|
>
|
2024-09-17 16:05:25 +02:00
|
|
|
<div
|
|
|
|
class="settings-content-header"
|
|
|
|
on:mouseenter={() => showCopy = true}
|
|
|
|
on:mouseleave={() => showCopy = false}
|
|
|
|
role="link"
|
|
|
|
tabindex="0"
|
|
|
|
>
|
2024-08-31 11:32:02 +02:00
|
|
|
<h3 class="settings-content-title">{title}</h3>
|
|
|
|
{#if beta}
|
2024-09-05 04:00:18 +02:00
|
|
|
<div class="beta-label">{$t("general.beta")}</div>
|
2024-08-31 11:32:02 +02:00
|
|
|
{/if}
|
2024-09-17 16:05:25 +02:00
|
|
|
{#if showCopy}
|
|
|
|
<button
|
|
|
|
class="settings-link-copy"
|
|
|
|
on:click={() => {
|
|
|
|
copied = true;
|
|
|
|
copyURL();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<CopyIcon check={copied} />
|
|
|
|
</button>
|
|
|
|
{/if}
|
2024-08-31 11:32:02 +02:00
|
|
|
</div>
|
2024-06-24 19:05:51 +02:00
|
|
|
<slot></slot>
|
2024-07-07 15:14:49 +02:00
|
|
|
</section>
|
2024-06-24 15:42:31 +02:00
|
|
|
|
2024-06-24 19:05:51 +02:00
|
|
|
<style>
|
2024-09-17 16:05:25 +02:00
|
|
|
.settings-link-copy {
|
|
|
|
background: transparent;
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.settings-link-copy :global(.copy-animation) {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
|
|
|
|
.settings-link-copy :global(.copy-animation *) {
|
|
|
|
width: 16px;
|
|
|
|
height: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.settings-link-copy :global(.copy-animation):hover {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
2024-06-24 19:05:51 +02:00
|
|
|
.settings-content {
|
2024-06-24 15:42:31 +02:00
|
|
|
display: flex;
|
2024-06-24 19:05:51 +02:00
|
|
|
flex-direction: column;
|
2024-07-10 15:35:23 +02:00
|
|
|
gap: var(--padding);
|
2024-09-04 13:50:47 +02:00
|
|
|
padding: calc(var(--subnav-padding) / 2);
|
2024-07-07 17:51:46 +02:00
|
|
|
border-radius: 18px;
|
2024-08-30 13:15:05 +02:00
|
|
|
transition: opacity 0.2s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.settings-content.disabled {
|
|
|
|
opacity: 0.5;
|
2024-07-07 17:51:46 +02:00
|
|
|
}
|
|
|
|
|
2024-09-08 20:10:53 +02:00
|
|
|
.settings-content.focus {
|
2024-07-07 17:51:46 +02:00
|
|
|
animation: highlight 2s;
|
|
|
|
}
|
|
|
|
|
2024-09-08 20:10:53 +02:00
|
|
|
:global([data-reduce-motion="true"]) .settings-content.focus {
|
2024-07-12 14:49:29 +02:00
|
|
|
animation: highlight-lite 2s !important;
|
|
|
|
}
|
|
|
|
|
2024-07-07 17:51:46 +02:00
|
|
|
@keyframes highlight {
|
|
|
|
0% {
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
10% {
|
|
|
|
box-shadow: 0 0 0 3.5px var(--blue) inset;
|
|
|
|
}
|
|
|
|
20%, 50% {
|
|
|
|
box-shadow: 0 0 0 3px var(--blue) inset;
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-12 14:49:29 +02:00
|
|
|
@keyframes highlight-lite {
|
|
|
|
0% {
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
10%, 50% {
|
|
|
|
box-shadow: 0 0 0 3px var(--blue) inset;
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
box-shadow: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-31 11:32:02 +02:00
|
|
|
.settings-content-header {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
flex-wrap: wrap;
|
2024-09-17 16:05:25 +02:00
|
|
|
gap: 6px;
|
2024-08-31 11:32:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.beta-label {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
border-radius: 5px;
|
|
|
|
padding: 0 5px;
|
|
|
|
background: var(--secondary);
|
|
|
|
color: var(--primary);
|
|
|
|
font-size: 11px;
|
|
|
|
font-weight: 500;
|
|
|
|
line-height: 0;
|
|
|
|
text-transform: uppercase;
|
|
|
|
}
|
|
|
|
|
2024-07-07 17:51:46 +02:00
|
|
|
@media screen and (max-width: 750px) {
|
|
|
|
.settings-content {
|
|
|
|
padding: var(--padding);
|
|
|
|
}
|
2024-06-24 15:42:31 +02:00
|
|
|
}
|
|
|
|
</style>
|