Files
classroomio/src/routes/ask.svelte
T

101 lines
2.6 KiB
Svelte
Raw Normal View History

2021-01-21 22:23:23 +02:00
<script>
import ChevronDown24 from 'carbon-icons-svelte/lib/ChevronDown24';
import TextEditor from '../components/TextEditor/index.svelte';
2020-12-30 22:29:01 +02:00
let questionTitle = '';
let questionDescription = '';
2021-01-21 22:23:23 +02:00
let facultyFilterOpened = false;
2020-12-30 22:29:01 +02:00
const faculties = [
'ИЭКСУ',
'ИМБТ',
'ИМИ',
'ИПТДМ',
'ИИИР',
'ГФ',
'ХТФ',
'ИДЗО',
'УИИ',
'УНИ',
2020-12-30 22:29:01 +02:00
];
2021-01-21 22:23:23 +02:00
let checkbox = faculties.reduce((acc, cur) => {
acc[cur] = false;
return acc;
}, {});
2021-04-05 07:12:51 +03:00
$: clickedTotal = Object.values(checkbox).filter((box) => !!box).length;
2021-01-21 22:23:23 +02:00
function handleFacultyFilters() {
facultyFilterOpened = facultyFilterOpened ? false : true;
}
2020-12-30 22:29:01 +02:00
</script>
2020-12-24 20:32:05 +02:00
<svelte:head>
2021-04-05 07:12:51 +03:00
<title>Спросить собшество вопрос</title>
2020-12-24 20:32:05 +02:00
</svelte:head>
2021-05-08 11:47:18 +03:00
<div class="root lg:w-3/5 mx-auto md:mx-10 lg:mb-20">
2020-12-30 22:29:01 +02:00
<h2 class="pb-2">Спросить собшество вопрос</h2>
2021-04-05 07:12:51 +03:00
<div class="main-title my-1 flex">
<div class="faculty-filter mr-1">
2021-01-21 22:23:23 +02:00
<button
class="flex border rounded-lg border-grey py-3 px-3 focus:outline-none focus:border-gray-400 focus:bg-gray-200 relative"
2021-01-21 22:23:23 +02:00
on:click={handleFacultyFilters}
>
2021-04-05 07:12:51 +03:00
<span class="flex flex-row"
>Факултеты <span>&nbsp;({clickedTotal})</span></span
>
<ChevronDown24 class="ml-2" />
2021-01-21 22:23:23 +02:00
</button>
{#if facultyFilterOpened}
2021-04-05 07:12:51 +03:00
<div
class="w-48 bg-white border border-grey rounded-lg mt-2 py-3 absolute"
2021-04-05 07:12:51 +03:00
>
2021-01-21 22:23:23 +02:00
{#each faculties as faculty}
<div class="block px-4 py-3 border-b">
2021-01-21 22:23:23 +02:00
<input
type="checkbox"
class="border border-gray checked:bg-blue-600 checked:border-transparent mr-1 cursor-pointer"
bind:checked={checkbox[faculty]}
2021-04-05 07:12:51 +03:00
/>
2021-01-21 22:23:23 +02:00
<span>{faculty}</span>
</div>
{/each}
2020-12-30 22:29:01 +02:00
</div>
2021-01-21 22:23:23 +02:00
{/if}
2020-12-30 22:29:01 +02:00
</div>
<input
2021-01-02 01:23:32 +02:00
class="title rounded-lg border border-1 border-gray p-2 w-full focus:outline-none"
2020-12-30 22:29:01 +02:00
error="false"
autocomplete="off"
placeholder="Title"
aria-label="Title"
aria-describedby="title-input-validation"
type="text"
name="discussion[title]"
id="discussion_title"
2021-04-05 07:12:51 +03:00
value={questionTitle}
/>
2020-12-30 22:29:01 +02:00
</div>
2020-12-24 20:32:05 +02:00
2020-12-30 22:29:01 +02:00
<TextEditor
2021-04-05 07:12:51 +03:00
value={questionDescription}
2020-12-30 22:29:01 +02:00
placeholder="Задайте вопрос или начните разговор"
/>
2021-04-05 07:12:51 +03:00
</div>
<style>
2021-05-08 11:47:18 +03:00
.root {
max-width: 600px;
margin: 10px auto 0;
}
2021-04-05 07:12:51 +03:00
@media only screen and (max-width: 1002px) {
.faculty-filter {
margin-bottom: 10px;
}
.main-title {
flex-direction: column;
}
}
</style>