From 7ddf1ddeacd4dd282d11f6656db47bd8687fd597 Mon Sep 17 00:00:00 2001 From: Riku Rouvila Date: Tue, 29 Sep 2020 20:00:53 +0300 Subject: [PATCH] tune styles and add secondary channel listing --- components/ChannelReferenceRenderer.tsx | 17 ++++ pages/index.tsx | 103 +++++++++++------------- styles/style.styl | 27 ++++--- 3 files changed, 78 insertions(+), 69 deletions(-) create mode 100644 components/ChannelReferenceRenderer.tsx diff --git a/components/ChannelReferenceRenderer.tsx b/components/ChannelReferenceRenderer.tsx new file mode 100644 index 0000000..372029f --- /dev/null +++ b/components/ChannelReferenceRenderer.tsx @@ -0,0 +1,17 @@ +export const ChannelReferenceRenderer = (props: { value: string }) => { + return ( + <> + {props.value.split(/(<#[A-Z0-9]+\|[A-Za-z0-9]+>)/).map((str) => { + const matches = str.match(/<#([A-Z0-9]+)\|([A-Za-z0-9]+)>/); + if (matches) { + return ( + + #{matches[2]} + + ); + } + return str; + })} + + ); +}; diff --git a/pages/index.tsx b/pages/index.tsx index 60efe37..7b6ed07 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -7,38 +7,14 @@ import InviteForm from "../components/InviteForm"; import Members from "../components/Members"; import Feed from "../components/Feed"; import { getChannels } from "../data/channels"; -import emoji from "emoji-dictionary"; import ReactMarkdown from "react-markdown"; - -const slackMarkdownRenderer = (text: { value: string }) => { - const emojiText = text.value.replace(/:\w+:/gi, (name) => - emoji.getUnicode(name) - ); - - return ( - - {emojiText.split(/(<#[A-Z0-9]+\|[A-Za-z0-9]+>)/).map((str) => { - const matches = str.match(/<#([A-Z0-9]+)\|([A-Za-z0-9]+)>/); - if (matches) { - return ( - - #{matches[2]} - - ); - } - return str; - })} - - ); -}; +import { ChannelReferenceRenderer } from "../components/ChannelReferenceRenderer"; export async function getStaticProps() { const allChannels = await getChannels(); const channels = allChannels .sort((a, b) => b.num_members - a.num_members) - .sort((a, b) => b.unique_members_today - a.unique_members_today) - .slice(0, 10); - + .sort((a, b) => b.unique_members_today - a.unique_members_today); return { props: { channels: channels, @@ -141,38 +117,51 @@ const IndexContent = (props: IndexProps) => (

Suosituimmat keskustelunaiheet tänään

+ + + + {props.channels.slice(0, 10).map((channel) => ( + + + + + ))} + +
+ + + {channel.num_members} jäsentä + + + + + +

- - - {props.channels.map((channel) => ( - - - - - ))} - -
- - - {channel.num_members} jäsentä - - - - - -
+ Ja paljon muuta:{" "} + {props.channels.slice(10, 30).map((channel, i) => ( + <> + + #{channel.name} + + {i !== 19 ? ", " : "..."} + + ))}

diff --git a/styles/style.styl b/styles/style.styl index 4bd7ec5..87881a8 100644 --- a/styles/style.styl +++ b/styles/style.styl @@ -392,9 +392,9 @@ footer list-style none padding 0 td - padding 0.2rem 0 + padding 0.4rem 0 td:first-child - text-align center + text-align right .channel @@ -443,13 +443,16 @@ footer .channel-members font-size 12px -.channel-topic p - font-size 0.8rem - display -webkit-box - -webkit-box-orient vertical - -webkit-line-clamp 2 - overflow hidden - border-left 1px solid #e6e6e6 - padding-left 1rem - margin 0 - margin-left 0.5rem \ No newline at end of file +.channel-topic + p + font-size 0.8rem + display -webkit-box + -webkit-box-orient vertical + -webkit-line-clamp 2 + overflow hidden + border-left 1px solid #e6e6e6 + padding-left 0.75rem + margin 0 + margin-left 0.5rem + img + width 20px \ No newline at end of file