2025-11-01 15:49:29 +01:00
|
|
|
<script lang="ts">
|
2024-04-19 05:45:48 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
2025-01-04 05:55:14 +01:00
|
|
|
import Chip from '../Chip/index.svelte';
|
|
|
|
|
import TextField from '../Form/TextField.svelte';
|
2023-08-05 04:44:32 +01:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
interface Props {
|
|
|
|
|
title?: string;
|
|
|
|
|
overidableStyle?: string;
|
|
|
|
|
navItems?: any;
|
|
|
|
|
disableSticky?: boolean;
|
|
|
|
|
isTitleEditable?: boolean;
|
|
|
|
|
onEditComplete?: any;
|
|
|
|
|
paddingClass?: string;
|
|
|
|
|
hideOnMobile?: boolean;
|
|
|
|
|
image?: import('svelte').Snippet;
|
|
|
|
|
widget?: import('svelte').Snippet;
|
|
|
|
|
}
|
2021-07-08 09:44:16 +03:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
let {
|
|
|
|
|
title = $bindable(''),
|
|
|
|
|
overidableStyle = '',
|
|
|
|
|
navItems = [],
|
|
|
|
|
disableSticky = false,
|
|
|
|
|
isTitleEditable = false,
|
|
|
|
|
onEditComplete = () => {},
|
|
|
|
|
paddingClass = 'px-2',
|
|
|
|
|
hideOnMobile = false,
|
|
|
|
|
image,
|
|
|
|
|
widget
|
|
|
|
|
}: Props = $props();
|
2021-05-07 03:43:37 +03:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
let enterEditTitleMode = $state(false);
|
|
|
|
|
|
|
|
|
|
const dynamicRootClass = $derived(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
|
2024-05-13 19:35:06 +01:00
|
|
|
class="{hideOnMobile &&
|
2025-01-04 05:55:14 +01:00
|
|
|
'hideOnMobile'} header border-b border-gray-200 bg-white dark:border-neutral-600 dark:bg-black {!disableSticky &&
|
2024-02-21 20:10:36 +01:00
|
|
|
'sticky'} {dynamicRootClass}"
|
2021-06-26 21:32:42 +03:00
|
|
|
style={overidableStyle}
|
|
|
|
|
>
|
2024-02-21 18:59:10 +01:00
|
|
|
<div
|
|
|
|
|
class="{hideOnMobile
|
|
|
|
|
? 'hidden lg:flex'
|
2025-01-04 05:55:14 +01:00
|
|
|
: ''} {paddingClass} m-auto flex min-h-[61px] max-w-4xl items-center justify-between"
|
2024-02-21 18:59:10 +01:00
|
|
|
>
|
|
|
|
|
{#if !!title}
|
|
|
|
|
{#if isTitleEditable}
|
|
|
|
|
{#if !enterEditTitleMode}
|
2025-11-01 15:49:29 +01:00
|
|
|
<button class="w-full" onclick={() => (enterEditTitleMode = true)}>
|
|
|
|
|
<h4 class="editable-title overflow-ellipsis rounded-md px-3 hover:bg-gray-100 dark:bg-black">
|
2024-02-21 18:59:10 +01:00
|
|
|
{title}
|
|
|
|
|
</h4>
|
|
|
|
|
</button>
|
|
|
|
|
{:else}
|
|
|
|
|
<TextField
|
|
|
|
|
bind:value={title}
|
2024-04-19 05:45:48 +01:00
|
|
|
placeholder={$t('course.navItem.settings.course_title')}
|
2024-02-21 18:59:10 +01:00
|
|
|
onChange={() => {
|
|
|
|
|
enterEditTitleMode = false;
|
|
|
|
|
|
|
|
|
|
if (typeof onEditComplete === 'function') {
|
|
|
|
|
onEditComplete();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
|
|
|
|
{:else}
|
2025-01-04 05:55:14 +01:00
|
|
|
<div class="flex w-full items-center" {title}>
|
2025-11-01 15:49:29 +01:00
|
|
|
{@render image?.()}
|
|
|
|
|
<h4 class="{image ? 'ml-2' : ''} truncate whitespace-nowrap text-lg font-semibold dark:text-white">
|
2023-08-05 04:44:32 +01:00
|
|
|
{title}
|
|
|
|
|
</h4>
|
2024-02-21 18:59:10 +01:00
|
|
|
</div>
|
2021-08-18 19:47:02 +03:00
|
|
|
{/if}
|
2024-02-21 18:59:10 +01:00
|
|
|
{/if}
|
|
|
|
|
{#if Array.isArray(navItems) && navItems.length}
|
2025-01-04 05:55:14 +01:00
|
|
|
<div class="flex items-center justify-evenly">
|
2024-02-21 18:59:10 +01:00
|
|
|
{#each navItems as item}
|
|
|
|
|
<a
|
2025-11-21 12:18:04 +01:00
|
|
|
class="relative mr-5 flex items-center pb-2 text-sm {item.isActive
|
2024-02-21 18:59:10 +01:00
|
|
|
? 'text-primary-700'
|
2025-01-04 05:55:14 +01:00
|
|
|
: 'text-black dark:text-white'} hover:no-underline"
|
2024-02-21 18:59:10 +01:00
|
|
|
href={item.href}
|
|
|
|
|
>
|
|
|
|
|
{item.label}
|
|
|
|
|
|
|
|
|
|
{#if typeof item.badgeValue === 'number'}
|
|
|
|
|
<Chip value={item.badgeValue} className="ml-1 bg-gray-300 dark:text-black" />
|
|
|
|
|
{/if}
|
|
|
|
|
<span
|
2025-01-04 05:55:14 +01:00
|
|
|
class="bg-primary-700 absolute bottom-0 left-0 h-1 transition-all duration-500 ease-in-out {item.isActive
|
2024-02-21 18:59:10 +01:00
|
|
|
? 'w-full'
|
|
|
|
|
: 'w-0'}"
|
2025-11-01 15:49:29 +01:00
|
|
|
></span>
|
2024-02-21 18:59:10 +01:00
|
|
|
</a>
|
|
|
|
|
{/each}
|
2021-08-26 13:35:56 +03:00
|
|
|
</div>
|
2021-08-18 19:47:02 +03:00
|
|
|
{/if}
|
2025-11-01 15:49:29 +01:00
|
|
|
{@render widget?.()}
|
2024-02-21 18:59:10 +01:00
|
|
|
</div>
|
2021-06-26 21:32:42 +03:00
|
|
|
</div>
|
|
|
|
|
|
2021-05-06 08:22:25 +03:00
|
|
|
<style>
|
|
|
|
|
.header {
|
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-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
|
|
|
|
2024-05-13 19:35:06 +01:00
|
|
|
@media (max-width: 1024px) {
|
2021-09-17 06:33:49 +03:00
|
|
|
.title {
|
|
|
|
|
width: fit-content;
|
|
|
|
|
}
|
2024-05-13 19:35:06 +01:00
|
|
|
|
|
|
|
|
.hideOnMobile {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
2021-09-17 06:33:49 +03:00
|
|
|
}
|
2021-05-06 08:22:25 +03:00
|
|
|
</style>
|