svelte-testing/src/components/misc/navbutton.svelte

50 lines
962 B
Svelte
Raw Normal View History

2022-07-01 22:10:08 +02:00
<script>
2022-07-02 18:19:16 +02:00
import {page} from '$app/stores';
2022-07-01 22:10:08 +02:00
export let link = '';
export let text = '';
</script>
2022-07-03 21:45:45 +02:00
<a href="{link}" class="">
2022-07-02 23:48:39 +02:00
<button class="{$page.url.pathname == link ? "active-now" : ""} text-murasaki md:text-xl py-2 px-4 font-montserrat font-semibold link-underline">
2022-07-01 22:18:26 +02:00
{text}
2022-07-01 22:10:08 +02:00
</button>
2022-07-01 22:18:26 +02:00
</a>
2022-07-02 11:13:43 +02:00
<style>
2022-07-02 18:19:16 +02:00
.active-now:before {
content: '';
position: absolute;
width: 100%;
transform: scaleX(1);
height: 2px;
bottom: 0;
left: 0;
2022-07-02 23:48:39 +02:00
background-color: #421727;
2022-07-02 18:19:16 +02:00
}
2022-07-02 11:13:43 +02:00
.link-underline {
display: inline-block;
position: relative;
2022-07-03 21:45:45 +02:00
z-index: 0;
2022-07-02 11:13:43 +02:00
}
.link-underline:after {
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);
height: 2px;
bottom: 0;
left: 0;
2022-07-02 23:48:39 +02:00
background-color: #421727;
2022-07-02 11:13:43 +02:00
transform-origin: bottom right;
transition: transform 0.25s ease-out;
2022-07-03 21:45:45 +02:00
z-index: 0;
2022-07-02 11:13:43 +02:00
}
.link-underline:hover:after {
transform: scaleX(1);
transform-origin: bottom left;
2022-07-02 23:48:39 +02:00
background-color: #421727;
2022-07-03 21:45:45 +02:00
z-index: 0;
2022-07-02 11:13:43 +02:00
}
</style>