2021-05-06 08:22:25 +03:00
|
|
|
<script>
|
2021-08-18 19:47:02 +03:00
|
|
|
import NewButton from '../PrimaryContainedButton/index.svelte';
|
|
|
|
|
import TextField from '../Form/TextField.svelte';
|
2021-08-31 21:59:17 +03:00
|
|
|
import Chip from '../Chip/index.svelte';
|
2023-08-05 04:44:32 +01:00
|
|
|
|
2021-08-18 19:47:02 +03:00
|
|
|
export let title = '';
|
|
|
|
|
export let overidableStyle = '';
|
2021-05-06 08:22:25 +03:00
|
|
|
export let navItems = [];
|
2021-08-24 10:45:43 +03:00
|
|
|
export let addButtonHref = '';
|
|
|
|
|
export let addButtonLabel = '';
|
2021-05-08 22:03:44 +03:00
|
|
|
export let disableSticky = false;
|
2021-08-18 19:47:02 +03:00
|
|
|
export let isTitleEditable = false;
|
|
|
|
|
export let onEditComplete = () => {};
|
2021-08-24 10:45:43 +03:00
|
|
|
export let paddingClass = 'px-2';
|
2023-10-05 08:02:34 +01:00
|
|
|
export let hideOnMobile = false;
|
2021-07-08 09:44:16 +03:00
|
|
|
|
2021-08-18 19:47:02 +03:00
|
|
|
let dynamicRootClass = '';
|
|
|
|
|
let enterEditTitleMode = false;
|
2021-05-07 03:43:37 +03:00
|
|
|
|
2023-08-05 04:44:32 +01:00
|
|
|
$: dynamicRootClass = Array.isArray(navItems) && navItems.length > 4 ? 'bring-down' : '';
|
2021-05-06 08:22:25 +03:00
|
|
|
</script>
|
|
|
|
|
|
2021-06-26 21:32:42 +03:00
|
|
|
<div
|
2023-10-05 08:02:34 +01:00
|
|
|
class="{hideOnMobile
|
|
|
|
|
? 'hidden lg:flex'
|
|
|
|
|
: ''} header dark:bg-black dark:border-neutral-600 bg-white flex items-center justify-between {!disableSticky &&
|
2021-08-24 10:45:43 +03:00
|
|
|
'sticky'} {paddingClass} {dynamicRootClass}"
|
2021-06-26 21:32:42 +03:00
|
|
|
style={overidableStyle}
|
|
|
|
|
>
|
|
|
|
|
{#if !!title}
|
2021-08-18 19:47:02 +03:00
|
|
|
{#if isTitleEditable}
|
|
|
|
|
{#if !enterEditTitleMode}
|
2023-08-05 04:44:32 +01:00
|
|
|
<button class="w-full" on:click={() => (enterEditTitleMode = true)}>
|
|
|
|
|
<h4
|
2023-09-16 22:44:20 +01:00
|
|
|
class="editable-title hover:bg-gray-100 dark:bg-black px-3 rounded-md overflow-ellipsis"
|
2023-08-05 04:44:32 +01:00
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</h4>
|
|
|
|
|
</button>
|
2021-08-18 19:47:02 +03:00
|
|
|
{:else}
|
|
|
|
|
<TextField
|
|
|
|
|
bind:value={title}
|
|
|
|
|
placeholder="Course title"
|
|
|
|
|
onChange={() => {
|
|
|
|
|
enterEditTitleMode = false;
|
|
|
|
|
|
|
|
|
|
if (typeof onEditComplete === 'function') {
|
|
|
|
|
onEditComplete();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
{:else}
|
2023-08-05 04:44:32 +01:00
|
|
|
<div class="flex items-center w-full" {title}>
|
2021-08-26 13:35:56 +03:00
|
|
|
<slot name="image" />
|
2023-08-05 04:44:32 +01:00
|
|
|
<h4
|
|
|
|
|
class="{$$slots.image
|
|
|
|
|
? 'ml-2'
|
|
|
|
|
: ''} dark:text-white whitespace-nowrap truncate text-lg font-semibold"
|
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</h4>
|
2021-08-26 13:35:56 +03:00
|
|
|
</div>
|
2021-08-18 19:47:02 +03:00
|
|
|
{/if}
|
2021-06-26 21:32:42 +03:00
|
|
|
{/if}
|
|
|
|
|
{#if Array.isArray(navItems) && navItems.length}
|
|
|
|
|
<div class="flex justify-evenly items-center">
|
|
|
|
|
{#each navItems as item}
|
2023-08-24 09:12:10 +01:00
|
|
|
<a
|
2023-08-24 18:31:52 +01:00
|
|
|
class="mr-5 pb-2 text-sm font-bold flex items-center relative {item.isActive
|
2023-08-24 09:12:10 +01:00
|
|
|
? 'text-primary-700'
|
2023-10-06 13:40:45 +00:00
|
|
|
: 'dark:text-white text-black'} hover:no-underline"
|
2023-08-24 09:12:10 +01:00
|
|
|
href={item.href}
|
|
|
|
|
>
|
2021-06-26 21:32:42 +03:00
|
|
|
{item.label}
|
2021-08-31 21:59:17 +03:00
|
|
|
|
|
|
|
|
{#if typeof item.badgeValue === 'number'}
|
2023-08-05 04:44:32 +01:00
|
|
|
<Chip value={item.badgeValue} className="ml-1 bg-gray-300 dark:text-black" />
|
2021-08-31 21:59:17 +03:00
|
|
|
{/if}
|
2023-08-24 09:12:10 +01:00
|
|
|
<span
|
|
|
|
|
class="absolute bottom-0 left-0 h-1 bg-primary-700 transition-all ease-in-out duration-500 {item.isActive
|
|
|
|
|
? 'w-full'
|
|
|
|
|
: 'w-0'}"
|
|
|
|
|
/>
|
2021-06-26 21:32:42 +03:00
|
|
|
</a>
|
|
|
|
|
{/each}
|
|
|
|
|
{#if addButtonHref}
|
|
|
|
|
<NewButton href={addButtonHref} label={addButtonLabel} />
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
<slot name="widget" />
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-05-06 08:22:25 +03:00
|
|
|
<style>
|
|
|
|
|
.header {
|
|
|
|
|
border-bottom: 1px solid var(--border-color);
|
2021-05-07 03:43:37 +03:00
|
|
|
min-height: 61px;
|
2021-06-26 21:32:42 +03:00
|
|
|
z-index: 1;
|
2021-05-08 22:03:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header.sticky {
|
2021-05-07 03:43:37 +03:00
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
2021-05-06 08:22:25 +03:00
|
|
|
}
|
|
|
|
|
|
2021-05-07 03:43:37 +03:00
|
|
|
.header.bring-down {
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
}
|
2021-05-22 12:32:32 +03:00
|
|
|
.spacing {
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
}
|
2021-05-07 03:43:37 +03:00
|
|
|
|
2021-08-18 19:47:02 +03:00
|
|
|
.editable-title {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
display: flex;
|
|
|
|
|
/* justify-content: center; */
|
|
|
|
|
align-items: center;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
2021-09-17 06:33:49 +03:00
|
|
|
|
|
|
|
|
@media (max-width: 760px) {
|
|
|
|
|
.title {
|
|
|
|
|
width: fit-content;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-06 08:22:25 +03:00
|
|
|
</style>
|