2021-07-27 22:53:51 +03:00
< script >
2021-07-28 22:57:40 +03:00
import { stores } from '@sapper/app' ;
import AddComment20 from 'carbon-icons-svelte/lib/AddComment20' ;
import Vote from '../components/Vote/index.svelte' ;
import Space from '../components/Space/index.svelte' ;
import HashTags from '../components/HashTags/index.svelte' ;
import PageNav from '../components/PageNav/index.svelte' ;
2021-07-27 22:53:51 +03:00
function getDiscussion ( filterBy , allDiscussions ) {
switch ( filterBy ) {
2021-07-28 22:57:40 +03:00
// case 'popular':
// return allDiscussions.filter((a, i) => i >= 0 && i < 2);
case 'recent' :
2021-07-27 22:53:51 +03:00
return allDiscussions . filter (( a , i ) => i >= 2 && i < 5 );
2021-07-28 22:57:40 +03:00
case 'upvoted' :
2021-07-27 22:53:51 +03:00
return allDiscussions . filter (( a , i ) => i > 4 && i < 8 );
default :
return allDiscussions ;
}
}
const { page } = stores ();
2021-07-28 22:57:40 +03:00
let filterBy = '' ;
2021-07-27 22:53:51 +03:00
let discussions = [];
2021-07-28 22:57:40 +03:00
$ : filterBy = $page . query . filter || 'popular' ;
2021-07-27 22:53:51 +03:00
const _allDiscussions = [
{
id : 1 ,
2021-07-28 22:57:40 +03:00
title : 'How do I pass Anicimov?' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'rotimibest' ,
2021-07-27 22:53:51 +03:00
},
2021-07-28 22:57:40 +03:00
tags : [ 'ибэит' , 'икс' ],
2021-07-27 22:53:51 +03:00
answered : false ,
comments : 10 ,
votes : 10 ,
},
{
id : 2 ,
title :
2021-07-28 22:57:40 +03:00
'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?' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'attronaldo' ,
2021-07-27 22:53:51 +03:00
},
2021-07-28 22:57:40 +03:00
tags : [ 'иибрт' , 'иее' ],
2021-07-27 22:53:51 +03:00
answered : false ,
comments : 2 ,
votes : 2 ,
},
{
id : 3 ,
2021-07-28 22:57:40 +03:00
title : 'Who is Nikolenko?' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'donald' ,
2021-07-27 22:53:51 +03:00
},
2021-07-28 22:57:40 +03:00
tags : [ 'ибэит' , 'иее' , 'иибрт' , 'ИПИГ' ],
2021-07-27 22:53:51 +03:00
answered : false ,
comments : 10 ,
votes : 10 ,
},
{
id : 4 ,
2021-07-28 22:57:40 +03:00
title : 'Archive discussion button' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'acharlesvv' ,
2021-07-27 22:53:51 +03:00
},
tags : [
2021-07-28 22:57:40 +03:00
'ИЭКСУ' ,
'ИМБТ' ,
'ИМИ' ,
'ИПТДМ' ,
'ИИИР' ,
'ГФ' ,
'ХТФ' ,
'ИДЗО' ,
'УИИ' ,
'УНИ' ,
2021-07-27 22:53:51 +03:00
],
answered : false ,
comments : 15 ,
votes : 15 ,
},
{
id : 1 ,
2021-07-28 22:57:40 +03:00
title : 'How do I pass Anicimov?' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'rotimibest' ,
2021-07-27 22:53:51 +03:00
},
2021-07-28 22:57:40 +03:00
tags : [ 'ибэит' , 'икс' ],
2021-07-27 22:53:51 +03:00
answered : false ,
comments : 7 ,
votes : 7 ,
},
{
id : 2 ,
2021-07-28 22:57:40 +03:00
title : 'Where do I find the nearest restaurant?' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'attronaldo' ,
2021-07-27 22:53:51 +03:00
},
2021-07-28 22:57:40 +03:00
tags : [ 'иибрт' , 'иее' ],
2021-07-27 22:53:51 +03:00
answered : false ,
comments : 4 ,
votes : 4 ,
},
{
id : 3 ,
2021-07-28 22:57:40 +03:00
title : 'Who is Nikolenko?' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'donald' ,
2021-07-27 22:53:51 +03:00
},
2021-07-28 22:57:40 +03:00
tags : [ 'ибэит' , 'иее' , 'иибрт' , 'ИПИГ' ],
2021-07-27 22:53:51 +03:00
answered : false ,
comments : 100 ,
votes : 100 ,
},
{
id : 4 ,
2021-07-28 22:57:40 +03:00
title : 'Archive discussion button' ,
2021-07-27 22:53:51 +03:00
author : {
2021-07-28 22:57:40 +03:00
name : 'acharlesvv' ,
2021-07-27 22:53:51 +03:00
},
tags : [
2021-07-28 22:57:40 +03:00
'ИЭКСУ' ,
'ИМБТ' ,
'ИМИ' ,
'ИПТДМ' ,
'ИИИР' ,
'ГФ' ,
'ХТФ' ,
'ИДЗО' ,
'УИИ' ,
'УНИ' ,
2021-07-27 22:53:51 +03:00
],
answered : false ,
comments : 5 ,
votes : 5 ,
},
];
const allDiscussions = [];
_allDiscussions . forEach (( d , i ) => {
allDiscussions . push ( d , _allDiscussions [ _allDiscussions . length - ( i + 1 )]);
});
$ : discussions = getDiscussion ( filterBy , allDiscussions );
</ script >
< svelte:head >
< title > ClassroomIO - Help students in your university</ title >
</ svelte:head >
< div class = "root md:w-3/4 mx-auto md:mb-20" >
< PageNav
title = "Talks"
addButtonHref = "/ask"
addButtonLabel = "Ask"
navItems = {[
{
2021-07-28 22:57:40 +03:00
label : 'Popular' ,
isActive : filterBy === 'popular' ,
href : '/discussions?filter=popular' ,
2021-07-27 22:53:51 +03:00
},
{
2021-07-28 22:57:40 +03:00
label : 'Recent' ,
isActive : filterBy === 'recent' ,
href : '/discussions?filter=recent' ,
2021-07-27 22:53:51 +03:00
},
{
2021-07-28 22:57:40 +03:00
label : 'Upvoted' ,
isActive : filterBy === 'upvoted' ,
href : '/discussions?filter=upvoted' ,
2021-07-27 22:53:51 +03:00
},
]}
/ >
{ #each discussions as discussion }
< div class = "discussion-box" >
< Vote value = { discussion . votes } / >
< div class = "discussion-topic-author" >
< h4 >
2021-07-28 22:57:40 +03:00
< a rel = "prefetch" href = "discussions/ { discussion . id } "
2021-07-27 22:53:51 +03:00
>{ 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 : 600 px ;
margin : 0 auto ;
border-left : 1 px solid var ( -- border - color );
border-right : 1 px solid var ( -- border - color );
}
. discussion-box {
/* border: 1px solid var(--border-color); */
display : flex ;
align-items : flex-start ;
padding : 10 px 15 px ;
/* border-radius: 10px; */
margin : 0 px auto ;
border-bottom : 1 px solid #e2e8f0 ;
}
h4 {
font-size : 16 px ;
font-weight : 900 ;
word-break : break-word ;
overflow-wrap : break-word ;
margin : 0 ;
}
. discussion-topic-author {
margin-right : 20 px ;
}
. discussion-topic-author span {
color : #586069 ;
font-size : 12 px ;
}
</ style >