Compare commits
2 Commits
a451b6f2ca
...
6667747e50
Author | SHA1 | Date |
---|---|---|
trivernis | 6667747e50 | 4 months ago |
trivernis | 2152586f49 | 4 months ago |
@ -0,0 +1,62 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
|
||||
type Props = {
|
||||
children?: Snippet;
|
||||
onclick?: (...args: any) => void;
|
||||
color?: string;
|
||||
pageBackground?: string;
|
||||
label?: string;
|
||||
};
|
||||
|
||||
const {
|
||||
label,
|
||||
children,
|
||||
onclick,
|
||||
color = "primary",
|
||||
pageBackground = "background",
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
<button
|
||||
class="button"
|
||||
{onclick}
|
||||
style={`--button-color: var(--color-${color}); --button-page-background: var(--color-${pageBackground})`}
|
||||
>
|
||||
<span class="button-label">{label}</span>
|
||||
{#if children}
|
||||
{@render children()}
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<style lang="scss">
|
||||
@import "$lib/styles/mixins.scss";
|
||||
|
||||
@layer component {
|
||||
.button {
|
||||
@include lighten-color(--button-border-color, var(--button-color));
|
||||
color: transparent;
|
||||
border: none !important;
|
||||
background: var(--button-color) !important;
|
||||
border-radius: 7.5px;
|
||||
padding: 0.25em 0.5em;
|
||||
color: black;
|
||||
mix-blend-mode: screen;
|
||||
|
||||
box-shadow: 0 0 10px var(--button-color);
|
||||
text-shadow: inset 0 0 10px var(--button-color);
|
||||
transition-duration: 0.25s;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
box-shadow: 0 0 20px var(--button-color);
|
||||
color: #222;
|
||||
}
|
||||
}
|
||||
|
||||
.button-label {
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,109 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from "svelte";
|
||||
import Box from "../atoms/Box.svelte";
|
||||
import Heading from "../atoms/Heading.svelte";
|
||||
|
||||
type Props = {
|
||||
children: Snippet;
|
||||
title: string;
|
||||
};
|
||||
|
||||
const { children, title }: Props = $props();
|
||||
let expanded = $state(false);
|
||||
|
||||
function toggleExpanded() {
|
||||
expanded = !expanded;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if expanded}
|
||||
<Box color="cyan">
|
||||
{#snippet titleElement()}
|
||||
<button class="hidden-button info-collapse" onclick={toggleExpanded}>
|
||||
<span class="arrow up-arrow">⌃</span><span class="info-text">Info</span>
|
||||
</button>
|
||||
{/snippet}
|
||||
<Heading depth={2}>{title}</Heading>
|
||||
{@render children()}
|
||||
</Box>
|
||||
{:else}
|
||||
<button class="hidden-button info-expand" onclick={toggleExpanded}>
|
||||
<span class="arrow collapsed-arrow">></span><span class="info-text">
|
||||
Info: {title}
|
||||
</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
@layer component {
|
||||
.hidden-button {
|
||||
border: none !important;
|
||||
background: inherit !important;
|
||||
color: inherit !important;
|
||||
margin: none !important;
|
||||
padding: none !important;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
font-family: var(--font-monospace);
|
||||
font-weight: bold;
|
||||
animation-duration: 2s;
|
||||
animation-iteration-count: infinite;
|
||||
animation-timing-function: cubic-bezier();
|
||||
}
|
||||
|
||||
.info-expand {
|
||||
font-size: 1.5em;
|
||||
cursor: pointer;
|
||||
|
||||
.info-text {
|
||||
font-family: var(--font-primary);
|
||||
margin: 0.2em 0;
|
||||
text-decoration: underline 0.2em var(--color-cyan);
|
||||
}
|
||||
|
||||
.collapsed-arrow {
|
||||
margin-right: 0.5em;
|
||||
position: relative;
|
||||
transition-duration: 1s;
|
||||
color: var(--color-cyan);
|
||||
}
|
||||
}
|
||||
|
||||
.info-collapse {
|
||||
transform: translateY(-0.1em);
|
||||
display: inline !important;
|
||||
cursor: pointer;
|
||||
font-size: 1.2em;
|
||||
|
||||
.up-arrow {
|
||||
position: relative;
|
||||
top: 0.1em;
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
font-family: var(--font-primary);
|
||||
margin: 0.2em 0;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.up-arrow {
|
||||
animation-name: pull-up;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pull-up {
|
||||
0% {
|
||||
top: 0.1em;
|
||||
}
|
||||
50% {
|
||||
top: -0.3em;
|
||||
}
|
||||
100% {
|
||||
top: 0.1em;
|
||||
}
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue