Discussion page

This commit is contained in:
rotimi_best
2020-12-26 18:35:09 +02:00
parent ba06a0001a
commit 24b2ef48d2
8 changed files with 92 additions and 91 deletions
+11
View File
@@ -1963,6 +1963,11 @@
"sourcemap-codec": "^1.4.4" "sourcemap-codec": "^1.4.4"
} }
}, },
"marked": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/marked/-/marked-1.2.7.tgz",
"integrity": "sha512-No11hFYcXr/zkBvL6qFmAp1z6BKY3zqLMHny/JN/ey+al7qwCM2+CMBL9BOgqMxZU36fz4cCWfn2poWIf7QRXA=="
},
"merge-stream": { "merge-stream": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
@@ -2896,6 +2901,12 @@
"regexparam": "^1.3.0" "regexparam": "^1.3.0"
} }
}, },
"typescript": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz",
"integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==",
"dev": true
},
"uglify-js": { "uglify-js": {
"version": "3.12.3", "version": "3.12.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.3.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.3.tgz",
+5 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "Unidiscuss", "name": "unidiscuss",
"description": "Unidiscuss", "description": "unidiscuss",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"dev": "sapper dev", "dev": "sapper dev",
@@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"compression": "^1.7.1", "compression": "^1.7.1",
"marked": "^1.2.7",
"polka": "next", "polka": "next",
"sirv": "^1.0.0" "sirv": "^1.0.0"
}, },
@@ -32,6 +33,7 @@
"sapper": "^0.28.0", "sapper": "^0.28.0",
"svelte": "^3.17.3", "svelte": "^3.17.3",
"svelte-preprocess": "^4.3.0", "svelte-preprocess": "^4.3.0",
"tailwindcss": "^1.8.10" "tailwindcss": "^1.8.10",
"typescript": "^4.1.3"
} }
} }
+7 -31
View File
@@ -21,49 +21,25 @@
<style> <style>
.sidebar-root { .sidebar-root {
padding: 16px; width: 250px;
border: 1px solid #e1e4e8;
border-radius: 6px;
width: 200px;
height: fit-content; height: fit-content;
} }
h4 {
font-size: 14px;
font-weight: 600;
border-bottom: 1px solid #e1e4e8;
padding-bottom: 10px;
}
.avatar {
border-radius: 50%;
display: inline-block;
overflow: hidden;
line-height: 1;
vertical-align: middle;
border-radius: 6px;
margin-right: 10px;
}
.contributer-link {
display: flex;
padding: 8px 0;
}
</style> </style>
<!-- markup (zero or more items) goes here --> <!-- markup (zero or more items) goes here -->
<div class="sidebar-root"> <div class="sidebar-root p-5 w-100 border border-1 border-gray rounded-md mt-12">
<h4>Most helpful</h4> <h4 class="border-b border-gray text-base font-bold pb-1">Most helpful</h4>
{#each contributors as contributor} {#each contributors as contributor}
<a class="contributer-link" href="/{contributor.name}"> <a class="flex pt-3" href="/{contributor.name}">
<img <img
class="avatar" class="inline-block overflow-hidden rounded-full mr-1 leading-none align-middle"
src="https://avatars0.githubusercontent.com/u/2854919?s=40&amp;v=4" src="https://avatars0.githubusercontent.com/u/2854919?s=40&amp;v=4"
width="20" width="23"
height="20" height="20"
alt="@jamesmosier" alt="@jamesmosier"
> >
<span>{contributor.name}</span> <span class="hover:text-blue-600 hover:underline">{contributor.name}</span>
</a> </a>
{/each} {/each}
</div> </div>
+1 -2
View File
@@ -8,7 +8,6 @@
<style> <style>
main { main {
display: flex;
background-color: white; background-color: white;
padding: 15px 2em; padding: 15px 2em;
margin: 0 auto; margin: 0 auto;
@@ -28,7 +27,7 @@
<Nav {segment}/> <Nav {segment}/>
<main> <main class="flex justify-evenly">
<slot></slot> <slot></slot>
<SideBar /> <SideBar />
</main> </main>
+44 -32
View File
@@ -1,4 +1,7 @@
<script context="module"> <script context="module">
import marked from 'marked'
import Vote from "../../components/Vote.svelte";
export async function preload({ params }) { export async function preload({ params }) {
// the `id` parameter is available because // the `id` parameter is available because
// this file is called [id].svelte // this file is called [id].svelte
@@ -25,42 +28,51 @@
<title>{discussion.title}</title> <title>{discussion.title}</title>
</svelte:head> </svelte:head>
<h1>{discussion.title}</h1> <div class="lg:w-3/5 mx-auto md:mx-10 lg:mb-20">
<div class="flex items-start">
<div class="my-1 px-1 w-full md:w-1/2 lg:my-4 lg:px-4 lg:w-1/3"> <Vote value="{discussion.votes}" />
<!-- Article --> <h1 class="text-4xl mb-8">{discussion.title}</h1>
<article class="overflow-hidden rounded-lg shadow-lg"> </div>
<div class="my-1 px-1 rounded-lg border border-1 border-gray">
<a href="#"> <header class="flex items-center justify-between leading-none p-2">
<img alt="Placeholder" class="block h-auto w-full" src="https://picsum.photos/600/400/?random"> <a class="flex items-center no-underline hover:underline text-black" href="/">
</a>
<header class="flex items-center justify-between leading-tight p-2 md:p-4">
<h1 class="text-lg">
<a class="no-underline hover:underline text-black" href="#">
Article Title
</a>
</h1>
<p class="text-grey-darker text-sm">
14/4/19
</p>
</header>
<footer class="flex items-center justify-between leading-none p-2 md:p-4">
<a class="flex items-center no-underline hover:underline text-black" href="#">
<img alt="Placeholder" class="block rounded-full" src="https://picsum.photos/32/32/?random"> <img alt="Placeholder" class="block rounded-full" src="https://picsum.photos/32/32/?random">
<p class="ml-2 text-sm"> <p class="ml-2 text-sm">
Author Name {discussion.author.name}
</p>
<p class="ml-2 text-sm text-gray-500">
12h ago
</p> </p>
</a> </a>
<a class="no-underline text-grey-darker hover:text-red-dark" href="#"> </header>
<span class="hidden">Like</span> <section class="p-2">
<i class="fa fa-heart"></i> {@html marked(discussion.question)}
</a> </section>
</footer> </div>
</article> <div class="my-8">
<!-- END Article --> <strong>{discussion.comments.length} ответы</strong>
</div>
{#each discussion.comments as comment}
<div class="my-5 px-1 flex items-start">
<Vote value="{comment.votes}" />
<div class="w-full rounded-lg border border-1 border-gray">
<header class="flex items-center justify-between leading-none p-2">
<a class="flex items-center no-underline hover:underline text-black" href="/">
<img alt="Placeholder" class="block rounded-full" width="24" height="20" 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>
</header>
<section class="p-2">
{@html marked(comment.comment)}
</section>
</div>
</div>
{/each}
</div> </div>
<!-- END Column -->
+23 -7
View File
@@ -6,33 +6,37 @@
// This file is called `_discussions.js` rather than `posts.js`, because // This file is called `_discussions.js` rather than `posts.js`, because
// we don't want to create an `/blog/posts` route — the leading // we don't want to create an `/blog/posts` route — the leading
// underscore tells Sapper not to do that. // underscore tells Sapper not to do that.
const question = "\ Hey!\n>\n> I'm working on a dashboard app that's where most things are login only and I like using ### Outlined a draft of the flows\n>\n> ### API Proposals\n> #### Through `getServerSideProps`\n> * Add new return property to `getServerSideProps` called i.e. `fetchPolicy` that can default to `always` being current behaviour and add new option `cache-and-network`/`stale-while-revalidate` as outlined above\n> * Add new router API event, called i.e. `routePropsChanged`, that can be triggered when page props change\n> * Maybe it could also send the `stale-while-revalidate` http header to the browser for instant page reloads?\n> * Problem: needs a way to clear cache when mutating to prevent a flash of unchanged content\n>\n> #### Through router\n> * Add new prop to Link/Router called `fetchPolicy: 'cache-and-network'` which could use a cache of the page's data if it exists and warm it up on load (similar to [`shallow`](https://nextjs.org/docs/routing/shallow-routing).)\n> * If `fetchPolicy: 'cache-and-network` is combined with `prefetch` it could actually preload the data on each page as well and make every route navigation change snappy, even when using getServerSideProps`\n> * This removes the \"flash of unchanged content\" on mutations as you can trigger a route change after a mutation w/o using the cache.\n>\n> Later on, this could be extended to allow for polling as well maybe, which could enable some real-time views without the need of any actual client-side query wiring.\n"
export default [ export default [
{ {
title: "What is Sapper?", title: "What is Sapper?",
id: 1, id: 1,
votes: 100,
author: { author: {
name: "babdraa", name: "babdraa",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4" avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4"
}, },
question: "Hello, I was thinking… Is there a way to get static props for non-page components without passing props from page component? Eg. navigation which is shared across many pages.", question,
createdAt: Date.now(), createdAt: Date.now(),
comments: [ comments: [
{ {
name: "babdraa", name: "babdraa",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4", avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4",
votes: 5,
comment: comment:
"getStaticProps must always be called from a page located in pages/*" "getStaticProps must always be called from a page located in pages/*"
}, },
{ {
name: "crana", name: "crana",
avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4", avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4",
votes: 0,
comment: comment:
"Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though." " Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though. Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though. Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though. Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though. Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though. Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though. Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though."
}, },
{ {
name: "loris", name: "loris",
avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4", avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4",
votes: 100,
comment: comment:
"getStaticProps must always be called from a page located in pages/*" "getStaticProps must always be called from a page located in pages/*"
} }
@@ -42,24 +46,27 @@ export default [
{ {
title: "How to use Sapper", title: "How to use Sapper",
id: 2, id: 2,
votes: 100,
author: { author: {
name: "babdraa", name: "babdraa",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4" avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4"
}, },
question: question:
"Hello, I was thinking… Is there a way to get static props for non-page components without passing props from page component? Eg. navigation which is shared across many pages.", question,
createdAt: Date.now(), createdAt: Date.now(),
comments: [ comments: [
{ {
name: "rawe", name: "rawe",
avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4", avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4",
votes: 10,
comment: comment:
"Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though." "Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though."
}, },
{ {
name: "hlaow", name: "hlaow",
avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4", avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4",
votes: 5,
comment: comment:
"getStaticProps must always be called from a page located in pages/*" "getStaticProps must always be called from a page located in pages/*"
} }
@@ -68,30 +75,34 @@ export default [
{ {
title: "Why the name?", title: "Why the name?",
votes: 100,
id: 3, id: 3,
author: { author: {
name: "babdraa", name: "babdraa",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4" avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4"
}, },
question: question:
"Hello, I was thinking… Is there a way to get static props for non-page components without passing props from page component? Eg. navigation which is shared across many pages.", question,
createdAt: Date.now(), createdAt: Date.now(),
comments: [ comments: [
{ {
name: "babdraa", name: "babdraa",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4", avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4",
votes: 50,
comment: comment:
"getStaticProps must always be called from a page located in pages/*" "getStaticProps must always be called from a page located in pages/*"
}, },
{ {
name: "crana", name: "crana",
avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4", avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4",
votes: 9,
comment: comment:
"Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though." "Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though."
}, },
{ {
name: "loris", name: "loris",
avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4", avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4",
votes: 5,
comment: comment:
"getStaticProps must always be called from a page located in pages/*" "getStaticProps must always be called from a page located in pages/*"
} }
@@ -101,22 +112,25 @@ export default [
{ {
title: "How is Sapper different from Next.js?", title: "How is Sapper different from Next.js?",
id: 4, id: 4,
votes: 10,
author: { author: {
name: "babdraa", name: "babdraa",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4" avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4"
}, },
question: "Hello, I was thinking… Is there a way to get static props for non-page components without passing props from page component? Eg. navigation which is shared across many pages.", question: question,
createdAt: Date.now(), createdAt: Date.now(),
comments: [ comments: [
{ {
name: "babdraa", name: "babdraa",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4", avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4",
votes: 0,
comment: comment:
"getStaticProps must always be called from a page located in pages/*" "getStaticProps must always be called from a page located in pages/*"
}, },
{ {
name: "crana", name: "crana",
avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4", avatar: "https://avatars1.githubusercontent.com/u/31749594?s=60&v=4",
votes: 1,
comment: comment:
"Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though." "Hello, thank you for reply. Of course I know that :-) I was just thinking if there is some way to do same as getStaticProps for other components too. I don't think such feature is completely necessary, though."
}, },
@@ -132,16 +146,18 @@ export default [
{ {
title: "How can I get involved?", title: "How can I get involved?",
id: 5, id: 5,
votes: 7,
author: { author: {
name: "living", name: "living",
avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4" avatar: "https://avatars3.githubusercontent.com/u/24832873?s=60&v=4"
}, },
question: "Hello, I was thinking… Is there a way to get static props for non-page components without passing props from page component? Eg. navigation which is shared across many pages.", question: question,
createdAt: Date.now(), createdAt: Date.now(),
comments: [ comments: [
{ {
name: "gbenga", name: "gbenga",
avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4", avatar: "https://avatars3.githubusercontent.com/u/11896398?s=60&v=4",
votes: 1000,
comment: comment:
"getStaticProps must always be called from a page located in pages/*" "getStaticProps must always be called from a page located in pages/*"
} }
+1 -12
View File
@@ -115,7 +115,7 @@
<svelte:head> <svelte:head>
<title>Unidiscuss - Help students in your university</title> <title>Unidiscuss - Help students in your university</title>
</svelte:head> </svelte:head>
<div class="root"> <div class="w-1/2 mx-auto mb-20">
<div class="flex justify-end mb-5"> <div class="flex justify-end mb-5">
<NewQuestion /> <NewQuestion />
</div> </div>
@@ -136,11 +136,6 @@
</div> </div>
<style> <style>
.root {
margin: 0 auto 20px;
width: 600px;
}
.discussion-box { .discussion-box {
border-top: 1px solid #eaecef; border-top: 1px solid #eaecef;
display: flex; display: flex;
@@ -167,10 +162,4 @@
.discussion-comments { .discussion-comments {
display: flex; display: flex;
} }
@media only screen and (max-width : 768px) {
.root {
width: 100%;
}
}
</style> </style>
-4
View File
@@ -16,10 +16,6 @@ h1 {
font-size: 2em; font-size: 2em;
} }
a {
color: inherit;
}
code { code {
font-family: menlo, inconsolata, monospace; font-family: menlo, inconsolata, monospace;
font-size: calc(1em - 2px); font-size: calc(1em - 2px);