more posts button
This commit is contained in:
parent
547063bfc0
commit
e07cd844db
4 changed files with 92 additions and 19 deletions
|
@ -1,23 +1,49 @@
|
|||
<script lang="ts">
|
||||
import { ButtonType } from "$lib/IO/ButtonType.ts";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let text : string = 'button';
|
||||
export let color : string;
|
||||
export let type : ButtonType = ButtonType.Primary;
|
||||
let cssName : string;
|
||||
|
||||
const buttonTypeColors = {
|
||||
[ButtonType.Primary]: '--primary',
|
||||
[ButtonType.Secondary]: '--secondary',
|
||||
[ButtonType.Accent]: '--accent',
|
||||
};
|
||||
|
||||
onMount(() => {
|
||||
if (!color || color.length === 0)
|
||||
{
|
||||
color = window.getComputedStyle(document.documentElement).getPropertyValue('--primary');
|
||||
}
|
||||
cssName = buttonTypeColors[type];
|
||||
});
|
||||
</script>
|
||||
|
||||
<button style="--button-color: {color};" class="button">
|
||||
{text}
|
||||
<button class="button" style="--button-color: var({cssName});">
|
||||
<div class="content">
|
||||
<slot name="content">
|
||||
Click Me!
|
||||
</slot>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<style>
|
||||
.button {
|
||||
width: 100%;
|
||||
border-radius: 6px;
|
||||
border: none;
|
||||
background-color: var(--button-color);
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
color: var(--text1);
|
||||
|
||||
padding: 0.8em 4em;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue