Files
classroomio/apps/dashboard/src/lib/components/QuestionContainer/index.svelte
T

74 lines
1.9 KiB
Svelte
Raw Normal View History

2021-06-26 21:32:42 +03:00
<script>
2021-08-18 19:47:02 +03:00
import TextField from '../Form/TextField.svelte';
import TrashCanIcon from 'carbon-icons-svelte/lib/TrashCan.svelte';
import IconButton from '$lib/components/IconButton/index.svelte';
2024-04-19 05:45:48 +01:00
import { t } from '$lib/utils/functions/translations';
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
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-16 22:44:20 +01:00
class="bg-white dark:bg-black 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'}
<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">
2024-04-19 05:45:48 +01:00
<p class="dark:text-white text-sm mr-2">{$t('course.navItem.lessons.exercises.new_exercise_modal.points')}:</p>
2021-08-18 19:47:02 +03:00
<TextField
2024-04-19 05:45:48 +01:00
placeholder={$t('course.navItem.lessons.exercises.new_exercise_modal.points')}
2021-08-18 19:47:02 +03:00
bind:value={points}
type="number"
onChange={onPointsChange}
/>
</div>
{#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>