Restructure ui of app

This commit is contained in:
Ibitoye Rotimi Best
2021-04-05 07:12:51 +03:00
parent cb0909c4fc
commit 59b8722ccd
9 changed files with 496 additions and 299 deletions
+14 -20
View File
@@ -1,12 +1,25 @@
<script>
import Tailwindcss from "../components/Tailwindcss.svelte";
import Nav from "../components/Nav.svelte";
// import Nav from "../components/Nav.svelte";
import LeftNav from "../components/LeftNav.svelte";
import SideBar from "../components/SideBar.svelte";
import Footer from "../components/Footer.svelte";
export let segment;
</script>
<Tailwindcss />
<!-- <Nav {segment} /> -->
<main class="flex max-w-screen-xl">
<LeftNav {segment} />
<slot />
<SideBar />
</main>
<Footer />
<style>
main {
background-color: white;
@@ -19,23 +32,4 @@
:global(a:hover) {
text-decoration: underline;
}
@media only screen and (max-width: 768px) {
main {
flex-direction: column;
align-items: center;
/* padding: 10px; */
}
}
</style>
<Tailwindcss />
<Nav {segment} />
<main class="flex max-w-screen-xl">
<slot />
<SideBar />
</main>
<Footer />
+40 -15
View File
@@ -1,19 +1,28 @@
<script>
import ChevronDown24 from "carbon-icons-svelte/lib/ChevronDown24";
import TextEditor from "../components/TextEditor.svelte";
import TextEditor from "../components/TextEditor.svelte";
let questionTitle = '';
let questionTags = [];
let questionDescription = '';
let questionTitle = "";
let questionDescription = "";
let facultyFilterOpened = false;
const faculties = [
'ИЭКСУ', 'ИМБТ', 'ИМИ', 'ИПТДМ', 'ИИИР', 'ГФ', 'ХТФ', 'ИДЗО', 'УИИ', 'УНИ'
"ИЭКСУ",
"ИМБТ",
"ИМИ",
"ИПТДМ",
"ИИИР",
"ГФ",
"ХТФ",
"ИДЗО",
"УИИ",
"УНИ",
];
let checkbox = faculties.reduce((acc, cur) => {
acc[cur] = false;
return acc;
}, {});
$: clickedTotal = Object.values(checkbox).filter((box) => !!box).length;
function handleFacultyFilters() {
facultyFilterOpened = facultyFilterOpened ? false : true;
@@ -21,29 +30,34 @@
</script>
<svelte:head>
<title>Спросить собшество вопрос</title>
<title>Спросить собшество вопрос</title>
</svelte:head>
<div class="lg:w-3/5 mx-auto md:mx-10 lg:mb-20">
<h2 class="pb-2">Спросить собшество вопрос</h2>
<div class="my-1 flex">
<div class="mr-1">
<div class="main-title my-1 flex">
<div class="faculty-filter mr-1">
<button
class="flex border rounded-lg border-grey py-2 px-3 focus:outline-none focus:border-gray-400 focus:bg-gray-200 relative"
on:click={handleFacultyFilters}
>
<span>Факултеты</span> <ChevronDown24 class="ml-2" />
<span class="flex flex-row"
>Факултеты <span>&nbsp;({clickedTotal})</span></span
>
<ChevronDown24 class="ml-2" />
</button>
{#if facultyFilterOpened}
<div class="w-48 bg-white border border-grey rounded-lg mt-2 py-2 absolute">
<div
class="w-48 bg-white border border-grey rounded-lg mt-2 py-2 absolute"
>
{#each faculties as faculty}
<div class="block px-4 py-2 border-b">
<input
type="checkbox"
class="border border-gray checked:bg-blue-600 checked:border-transparent mr-1 cursor-pointer"
bind:checked={checkbox[faculty]}
>
/>
<span>{faculty}</span>
</div>
{/each}
@@ -60,12 +74,23 @@
type="text"
name="discussion[title]"
id="discussion_title"
value="{questionTitle}"
>
value={questionTitle}
/>
</div>
<TextEditor
value="{questionDescription}"
value={questionDescription}
placeholder="Задайте вопрос или начните разговор"
/>
</div>
</div>
<style>
@media only screen and (max-width: 1002px) {
.faculty-filter {
margin-bottom: 10px;
}
.main-title {
flex-direction: column;
}
}
</style>
+14 -10
View File
@@ -25,12 +25,6 @@
export let discussion;
</script>
<style>
.root {
margin-top: 15px;
}
</style>
<svelte:head>
<title>{discussion.title}</title>
</svelte:head>
@@ -44,11 +38,13 @@
<header class="flex items-center justify-between leading-none p-2">
<a
class="flex items-center no-underline hover:underline text-black"
href="/">
href="/"
>
<img
alt="Placeholder"
class="block rounded-full"
src="https://picsum.photos/32/32/?random" />
src="https://picsum.photos/32/32/?random"
/>
<p class="ml-2 text-sm">{discussion.author.name}</p>
<p class="ml-2 text-sm text-gray-500">12h ago</p>
</a>
@@ -70,13 +66,15 @@
<header class="flex items-center justify-between leading-none p-2">
<a
class="flex items-center no-underline hover:underline text-black"
href="/">
href="/"
>
<img
alt="Placeholder"
class="block rounded-full"
width="24"
height="20"
src={comment.avatar} />
src={comment.avatar}
/>
<p class="ml-2 text-sm">{comment.name}</p>
<p class="ml-2 text-sm text-gray-500">12h ago</p>
</a>
@@ -93,3 +91,9 @@
<hr />
<TextEditor value={userComment} placeholder="Предлогайте ваш ответ" />
</div>
<style>
.root {
margin: 15px 5px;
}
</style>
+238 -223
View File
@@ -1,244 +1,259 @@
<script>
import { stores } from "@sapper/app";
import AddComment20 from "carbon-icons-svelte/lib/AddComment20";
import Vote from "../components/Vote.svelte";
import Space from "../components/Space.svelte";
import HashTags from "../components/HashTags.svelte";
import { stores } from "@sapper/app";
import AddComment20 from "carbon-icons-svelte/lib/AddComment20";
import Vote from "../components/Vote.svelte";
import Space from "../components/Space.svelte";
import HashTags from "../components/HashTags.svelte";
function getDiscussion(filterBy, allDiscussions) {
switch (filterBy) {
case "popular":
return allDiscussions.filter((a, i) => i >= 0 && i < 2);
case "recent":
return allDiscussions.filter((a, i) => i >= 2 && i < 5);
case "upvoted":
return allDiscussions.filter((a, i) => i > 4 && i < 8);
default:
return allDiscussions;
}
}
function getDiscussion(filterBy, allDiscussions) {
switch (filterBy) {
case "popular":
return allDiscussions.filter((a, i) => i >= 0 && i < 2);
case "recent":
return allDiscussions.filter((a, i) => i >= 2 && i < 5);
case "upvoted":
return allDiscussions.filter((a, i) => i > 4 && i < 8);
default:
return allDiscussions;
}
}
const { page } = stores();
let filterBy = "";
let discussions = [];
const { page } = stores();
let filterBy = "";
let discussions = [];
$: filterBy = $page.query.filter || "popular";
$: filterBy = $page.query.filter || "popular";
const allDiscussions = [
{
id: 1,
title: "How do I pass Anicimov?",
author: {
name: "rotimibest",
},
tags: ["ибэит", "икс"],
answered: false,
comments: 10,
votes: 10,
},
{
id: 2,
title:
"Where do I find the nearest restaurant. Where do I find the nearest restaurant?. Where do I find the nearest restaurant? Where do I find the nearest restaurant?",
author: {
name: "attronaldo",
},
tags: ["иибрт", "иее"],
answered: false,
comments: 2,
votes: 2,
},
{
id: 3,
title: "Who is Nikolenko?",
author: {
name: "donald",
},
tags: ["ибэит", "иее", "иибрт", "ИПИГ"],
answered: false,
comments: 10,
votes: 10,
},
{
id: 4,
title: "Archive discussion button",
author: {
name: "acharlesvv",
},
tags: [
"ИЭКСУ",
"ИМБТ",
"ИМИ",
"ИПТДМ",
"ИИИР",
"ГФ",
"ХТФ",
"ИДЗО",
"УИИ",
"УНИ",
],
answered: false,
comments: 15,
votes: 15,
},
{
id: 1,
title: "How do I pass Anicimov?",
author: {
name: "rotimibest",
},
tags: ["ибэит", "икс"],
answered: false,
comments: 7,
votes: 7,
},
{
id: 2,
title: "Where do I find the nearest restaurant?",
author: {
name: "attronaldo",
},
tags: ["иибрт", "иее"],
answered: false,
comments: 4,
votes: 4,
},
{
id: 3,
title: "Who is Nikolenko?",
author: {
name: "donald",
},
tags: ["ибэит", "иее", "иибрт", "ИПИГ"],
answered: false,
comments: 100,
votes: 100,
},
{
id: 4,
title: "Archive discussion button",
author: {
name: "acharlesvv",
},
tags: [
"ИЭКСУ",
"ИМБТ",
"ИМИ",
"ИПТДМ",
"ИИИР",
"ГФ",
"ХТФ",
"ИДЗО",
"УИИ",
"УНИ",
],
answered: false,
comments: 5,
votes: 5,
},
];
const _allDiscussions = [
{
id: 1,
title: "How do I pass Anicimov?",
author: {
name: "rotimibest",
},
tags: ["ибэит", "икс"],
answered: false,
comments: 10,
votes: 10,
},
{
id: 2,
title:
"Where do I find the nearest restaurant. Where do I find the nearest restaurant?. Where do I find the nearest restaurant? Where do I find the nearest restaurant?",
author: {
name: "attronaldo",
},
tags: ["иибрт", "иее"],
answered: false,
comments: 2,
votes: 2,
},
{
id: 3,
title: "Who is Nikolenko?",
author: {
name: "donald",
},
tags: ["ибэит", "иее", "иибрт", "ИПИГ"],
answered: false,
comments: 10,
votes: 10,
},
{
id: 4,
title: "Archive discussion button",
author: {
name: "acharlesvv",
},
tags: [
"ИЭКСУ",
"ИМБТ",
"ИМИ",
"ИПТДМ",
"ИИИР",
"ГФ",
"ХТФ",
"ИДЗО",
"УИИ",
"УНИ",
],
answered: false,
comments: 15,
votes: 15,
},
{
id: 1,
title: "How do I pass Anicimov?",
author: {
name: "rotimibest",
},
tags: ["ибэит", "икс"],
answered: false,
comments: 7,
votes: 7,
},
{
id: 2,
title: "Where do I find the nearest restaurant?",
author: {
name: "attronaldo",
},
tags: ["иибрт", "иее"],
answered: false,
comments: 4,
votes: 4,
},
{
id: 3,
title: "Who is Nikolenko?",
author: {
name: "donald",
},
tags: ["ибэит", "иее", "иибрт", "ИПИГ"],
answered: false,
comments: 100,
votes: 100,
},
{
id: 4,
title: "Archive discussion button",
author: {
name: "acharlesvv",
},
tags: [
"ИЭКСУ",
"ИМБТ",
"ИМИ",
"ИПТДМ",
"ИИИР",
"ГФ",
"ХТФ",
"ИДЗО",
"УИИ",
"УНИ",
],
answered: false,
comments: 5,
votes: 5,
},
];
const allDiscussions = [];
$: discussions = getDiscussion(filterBy, allDiscussions);
_allDiscussions.forEach((d, i) => {
allDiscussions.push(d, _allDiscussions[_allDiscussions.length - (i + 1)]);
});
$: discussions = getDiscussion(filterBy, allDiscussions);
</script>
<svelte:head>
<title>Unidiscuss - Help students in your university</title>
</svelte:head>
<div class="root md:w-3/4 mx-auto md:mb-20">
<div class="header flex justify-between mb-2">
<h4 class="title">Разговоры 😉😁</h4>
<div class="flex justify-evenly items-center">
<a
class="mr-5 text-sm {filterBy === 'popular' && 'active'}"
href="?filter=popular"
>
Popular
</a>
<a
class="mr-5 text-sm {filterBy === 'recent' && 'active'}"
href="?filter=recent"
>
Recent
</a>
<a
class="mr-5 text-sm {filterBy === 'upvoted' && 'active'}"
href="?filter=upvoted"
>
Upvoted
</a>
</div>
</div>
{#each discussions as discussion}
<div class="discussion-box">
<Vote value={discussion.votes} />
<div class="discussion-topic-author">
<h4>
<a rel="prefetch" href="discussion/{discussion.id}"
>{discussion.title}</a
>
</h4>
<span>{discussion.author.name} asked 1 day ago</span>
<HashTags tags={discussion.tags} />
</div>
<Space />
<div class="flex items-center">
<AddComment20 />
<span>{discussion.comments}</span>
</div>
</div>
{/each}
</div>
<style>
.root {
max-width: 600px;
margin: 0 auto;
border-left: 1px solid #eaecef;
border-right: 1px solid #eaecef;
}
.root {
max-width: 600px;
margin: 0 auto;
border-left: 1px solid #eaecef;
border-right: 1px solid #eaecef;
}
.root .header {
border-bottom: 1px solid #eaecef;
padding: 15px;
}
.root .header {
border-bottom: 1px solid #eaecef;
padding: 15px;
}
.root .title {
font-size: 20px;
}
.discussion-box {
/* border: 1px solid #eaecef; */
display: flex;
.root .title {
font-size: 20px;
}
.discussion-box {
/* border: 1px solid #eaecef; */
display: flex;
align-items: flex-start;
padding: 10px 15px;
/* border-radius: 10px; */
margin: 0px auto;
border-bottom: 1px solid #e2e8f0;
}
}
h4 {
font-size: 16px;
font-weight: 900;
word-break: break-word;
overflow-wrap: break-word;
margin: 0;
}
h4 {
font-size: 16px;
font-weight: 900;
word-break: break-word;
overflow-wrap: break-word;
margin: 0;
}
.discussion-topic-author {
margin-right: 20px;
}
.discussion-topic-author span {
color: #586069;
font-size: 12px;
}
.discussion-topic-author {
margin-right: 20px;
}
.discussion-topic-author span {
color: #586069;
font-size: 12px;
}
.active {
position: relative;
display: inline-block;
}
.active {
position: relative;
display: inline-block;
}
.active::after {
position: absolute;
content: "";
width: 100%;
height: 3px;
background-color: #3182ce;
display: block;
}
.active::after {
position: absolute;
content: "";
width: 100%;
height: 3px;
background-color: #3182ce;
display: block;
}
@media only screen and (max-width: 1002px) {
.header {
flex-direction: column;
align-items: flex-start;
}
}
</style>
<svelte:head>
<title>Unidiscuss - Help students in your university</title>
</svelte:head>
<div class="root md:w-3/4 mx-auto md:mb-20">
<div class="header flex justify-between mb-2">
<h4 class="title">Разговоры 😉😁</h4>
<div class="flex justify-evenly items-center">
<a
class="mr-5 text-sm {filterBy === 'popular' && 'active'}"
href="?filter=popular">
Popular
</a>
<a
class="mr-5 text-sm {filterBy === 'recent' && 'active'}"
href="?filter=recent">
Recent
</a>
<a
class="mr-5 text-sm {filterBy === 'upvoted' && 'active'}"
href="?filter=upvoted">
Upvoted
</a>
</div>
</div>
{#each discussions as discussion}
<div class="discussion-box">
<Vote value={discussion.votes} />
<div class="discussion-topic-author">
<h4>
<a
rel="prefetch"
href="discussion/{discussion.id}">{discussion.title}</a>
</h4>
<span>{discussion.author.name} asked 1 day ago</span>
<HashTags tags={discussion.tags} />
</div>
<Space />
<div class="flex items-center">
<AddComment20 />
<span>{discussion.comments}</span>
</div>
</div>
{/each}
</div>
+12 -4
View File
@@ -1,8 +1,16 @@
<script>
function onTelegramAuth(user) {
alert('Logged in as ' + user.first_name + ' ' + user.last_name + ' (' + user.id + (user.username ? ', @' + user.username : '') + ')');
}
</script>
<svelte:head>
<title>Login</title>
<title>Join Unidiscuss</title>
</svelte:head>
<div class="">
<h2>Login page here</h2>
</div>
<div class="lg:w-3/5 mx-auto md:mx-10 lg:mb-20">
<p>Login/Sign up into Unidiscuss</p>
<script async src="https://telegram.org/js/telegram-widget.js?14" data-telegram-login="unidiscuss_bot" data-size="large" data-auth-url="login-redirect" data-request-access="write"></script>
</div>