2021-06-26 21:32:42 +03:00
|
|
|
<script>
|
2021-08-18 19:47:02 +03:00
|
|
|
import TextField from '../Form/TextField.svelte';
|
2023-08-30 14:31:40 +00:00
|
|
|
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
|
|
|
|
|
import IconButton from '$lib/components/IconButton/index.svelte';
|
|
|
|
|
|
2021-06-26 21:32:42 +03:00
|
|
|
export let isTitle = false;
|
2021-08-18 19:47:02 +03:00
|
|
|
export let onClose = () => {};
|
2021-07-03 19:29:41 +00:00
|
|
|
export let scrollToQuestion = false;
|
2021-08-18 19:47:02 +03:00
|
|
|
export let points = undefined;
|
|
|
|
|
export let hasError = false;
|
|
|
|
|
export let onPointsChange = () => {};
|
2021-07-03 19:29:41 +00:00
|
|
|
|
2023-08-30 14:31:40 +00:00
|
|
|
let ref;
|
2021-07-03 19:29:41 +00:00
|
|
|
|
|
|
|
|
$: {
|
|
|
|
|
if (ref && scrollToQuestion) {
|
2021-08-18 19:47:02 +03:00
|
|
|
ref.scrollIntoView({
|
|
|
|
|
block: 'start',
|
|
|
|
|
behavior: 'smooth',
|
2023-08-20 19:08:48 +00:00
|
|
|
inline: 'nearest'
|
2021-08-18 19:47:02 +03:00
|
|
|
});
|
2021-07-03 19:29:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-26 21:32:42 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div
|
2021-07-03 19:29:41 +00:00
|
|
|
bind:this={ref}
|
2023-09-01 15:28:47 +01:00
|
|
|
class="bg-white dark:bg-gray-800 border-2 {hasError
|
2021-08-18 19:47:02 +03:00
|
|
|
? 'border-red-700'
|
2023-08-20 19:08:48 +00:00
|
|
|
: 'border-gray hover:border-primary-700'} rounded-md mb-6 relative root"
|
2021-06-26 21:32:42 +03:00
|
|
|
>
|
|
|
|
|
{#if isTitle}
|
2023-08-20 19:08:48 +00:00
|
|
|
<div class="title absolute bg-primary-700" />
|
2021-06-26 21:32:42 +03:00
|
|
|
{/if}
|
|
|
|
|
<div class="px-4 {isTitle ? 'pt-4' : 'pt-2'} pb-3">
|
|
|
|
|
<slot />
|
|
|
|
|
</div>
|
2021-08-18 19:47:02 +03:00
|
|
|
|
|
|
|
|
{#if typeof points !== 'undefined'}
|
2023-08-30 14:31:40 +00:00
|
|
|
<div
|
|
|
|
|
class="flex justify-between items-center border-gray border-t-2 border-r-0 border-b-0 border-l-0 p-2"
|
|
|
|
|
>
|
2021-08-18 19:47:02 +03:00
|
|
|
<div class="flex items-center w-40">
|
2023-05-05 20:19:45 +00:00
|
|
|
<p class="dark:text-white text-sm mr-2">Points:</p>
|
2021-08-18 19:47:02 +03:00
|
|
|
<TextField
|
|
|
|
|
placeholder="Points"
|
|
|
|
|
bind:value={points}
|
|
|
|
|
type="number"
|
|
|
|
|
onChange={onPointsChange}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2023-08-30 14:31:40 +00:00
|
|
|
|
|
|
|
|
{#if onClose && !isTitle}
|
|
|
|
|
<IconButton onClick={onClose}>
|
|
|
|
|
<TrashCanIcon size={24} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
{/if}
|
2021-08-18 19:47:02 +03:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
2021-06-26 21:32:42 +03:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.title {
|
|
|
|
|
color: rgba(255, 255, 255, 1);
|
|
|
|
|
border-top-left-radius: 8px;
|
|
|
|
|
border-top-right-radius: 8px;
|
|
|
|
|
height: 10px;
|
|
|
|
|
left: -1px;
|
|
|
|
|
top: -1px;
|
|
|
|
|
width: calc(100% + 2px);
|
|
|
|
|
}
|
|
|
|
|
</style>
|