Files
classroomio/src/components/PageNav/index.svelte
T

90 lines
1.8 KiB
Svelte
Raw Normal View History

2021-05-06 08:22:25 +03:00
<script>
import NewButton from "../PrimaryContainedButton/index.svelte";
2021-05-06 08:22:25 +03:00
export let title = "";
2021-05-29 20:47:46 +03:00
export let overidableStyle = "";
2021-05-06 08:22:25 +03:00
export let navItems = [];
2021-05-08 11:47:18 +03:00
export let addButtonHref;
export let addButtonLabel;
export let disableSticky = false;
2021-05-07 03:43:37 +03:00
let dynamicRootClass = "";
$: dynamicRootClass =
Array.isArray(navItems) && navItems.length > 4 ? "bring-down" : "";
2021-05-06 08:22:25 +03:00
</script>
<style>
.header {
border-bottom: 1px solid var(--border-color);
padding: 15px;
2021-05-07 03:43:37 +03:00
min-height: 61px;
background-color: #fff;
}
.header.sticky {
2021-05-07 03:43:37 +03:00
position: sticky;
top: 0;
2021-05-06 08:22:25 +03:00
}
.title {
font-size: 20px;
}
h4 {
font-size: 16px;
font-weight: 900;
word-break: break-word;
overflow-wrap: break-word;
margin: 0;
}
.active {
position: relative;
display: inline-block;
}
.active::after {
position: absolute;
content: "";
width: 100%;
height: 3px;
background-color: var(--main-primary-color);
display: block;
}
2021-05-07 03:43:37 +03:00
.header.bring-down {
flex-direction: column;
align-items: flex-start;
}
.spacing {
flex-grow: 1;
}
2021-05-07 03:43:37 +03:00
2021-05-06 08:22:25 +03:00
@media only screen and (max-width: 1002px) {
.header {
flex-direction: column;
align-items: flex-start;
}
}
</style>
2021-05-29 20:47:46 +03:00
<div
class="header flex items-center justify-between mb-2 {!disableSticky && 'sticky'} {dynamicRootClass}"
style={overidableStyle}>
{#if !!title}
<h4 class="title">{title}</h4>
{/if}
{#if Array.isArray(navItems) && navItems.length}
<div class="flex justify-evenly items-center">
{#each navItems as item}
<a class="mr-5 text-sm {item.isActive && 'active'}" href={item.href}>
{item.label}
</a>
{/each}
{#if addButtonHref}
<NewButton href={addButtonHref} label={addButtonLabel} />
{/if}
</div>
{/if}
<slot name="widget" />
</div>