Skip to content

Commit

Permalink
feat(Pinning): Added message pinning
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroPronghorn committed Oct 1, 2021
1 parent 303c75b commit accad2c
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/tailored/core/sidebar/live/Live.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="live">
<div>
<font-awesome-icon :icon="['far', 'signal-stream']" />
<TypographySubtitle :size="6" text="Now Live" />
<TypographySubtitle :size="6" text="Apex Legends" />
</div>
<InteractablesButton
type="danger"
Expand Down
12 changes: 12 additions & 0 deletions components/tailored/core/statusbar/Statusbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@
>
<font-awesome-icon class="control-icon" :icon="['far', 'video']" />
</div>
<div
class="has-tooltip has-tooltip-bottom has-tooltip-primary"
data-tooltip="Pinned Messages"
@click="() => {
$store.commit('togglePinned', !ui.showPinned)
}"
>
<font-awesome-icon class="control-icon" :icon="['far', 'thumbtack']" />
</div>
<div class="vertical-divider" v-if="$device.isDesktop"></div>
<div
class="market-place has-tooltip has-tooltip-primary has-tooltip-bottom"
Expand All @@ -51,5 +60,8 @@
:show="showSearchResult"
@toggle="toggleSearchResult"
/>
<TailoredMessagingPinned
v-if="ui.showPinned"
/>
</div>
</div>
18 changes: 14 additions & 4 deletions components/tailored/messaging/message/Message.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<div class="is-message" @contextmenu="contextMenu">
<div @mouseenter="mouseOver"
:class="`message-container ${messageHover ? 'message-hover' : '' }`">
<TailoredMessagingMessageActions v-if="messageHover" :setReplyChatbarContent="setReplyChatbarContent"
:class="`message-container ${messageHover ? 'message-hover' : '' } ${message.pinned ? 'pinned-message' : ''}`">
<div v-if="message.pinned" class="pinned-badge">
<font-awesome-icon :icon="['far', 'thumbtack']" />
Pinned
</div>
<div v-if="hideActions" class="inline-meta">
<UiUsername :username="from"
:badge="$mock.users.filter(u => u.name === from)[0].badge" />
<TypographyText :text="$dayjs(message.at).from()" />
</div>
<TailoredMessagingMessageActions v-if="messageHover && !hideActions" :setReplyChatbarContent="setReplyChatbarContent"
:emojiReaction="emojiReaction" />
<VueMarkdown v-if="message.type === 'text'" :source="message.payload" class="markdown" />
<UiImage v-else-if="message.type === 'image'" :source="message.payload.url" alt="" />
<UiEmbedsVideoPlayer v-else-if="message.type === 'video'" :data="message.payload" />
<UiEmbedsAudioPlayer v-else-if="message.type === 'audio'" :data="message.payload" />
<UiEmbedsFile v-else-if="message.type === 'file'" :data="message.payload" />
<TailoredMessagingMessageReactions
v-if="!hideActions && hasReactions"
:message="this.$props.message"
:group="this.$props.group"
:key="`${this.$props.message.id}-${this.$props.message.reactions ? this.$props.message.reactions.length : 0}`" />
:key="`${this.$props.message.id}-${hasReactions ? this.$props.message.reactions.length : 0}`" />
</div>
<TailoredMessagingMessageReply :message="message" :group="group" />
<TailoredMessagingMessageReply :message="message" :group="group" v-if="!hideActions"/>
</div>
26 changes: 26 additions & 0 deletions components/tailored/messaging/message/Message.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
.is-message {
color: @text;
margin-bottom: 0.1rem;
.pinned-message {
border: 1px solid @primary-color;
border-radius: @corner-rounding;
padding: @normal-spacing;
margin-top: @normal-spacing;
margin-bottom: @light-spacing;

.pinned-badge {
top: -(@light-spacing);
left: @light-spacing;
padding: 0 @light-spacing;
background-color: @primary-color;
border-radius: @corner-rounding-smaller;
font-size: @mini-text-size;
position: absolute;
}
}
.inline-meta {
margin-bottom: @light-spacing;
display: inline-flex;
.is-text {
opacity: 0.8;
margin-top: 0.3rem;
margin-left: @light-spacing;
}
}
.markdown {
strong {
color: @bright-text;
Expand Down
9 changes: 9 additions & 0 deletions components/tailored/messaging/message/Message.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,20 @@ export default Vue.extend({
type: Number,
default: -1,
},
hideActions: {
type: Boolean,
default: false,
},
setMessageHover: {
type: Function,
default: () => {},
},
},
computed: {
hasReactions() {
return this.$props.message.reactions && this.$props.message.reactions.length
},
},
data() {
return {
messageHover: false,
Expand Down
6 changes: 6 additions & 0 deletions components/tailored/messaging/message/actions/Actions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
>
<font-awesome-icon :icon="['fas', 'reply']" :class="'control-icon'" />
</div>
<div
class="reply-command has-tooltip has-tooltip-primary"
:data-tooltip="$t('global.pin')"
>
<font-awesome-icon :icon="['far', 'thumbtack']" :class="'control-icon'" />
</div>
<div
class="reply-command has-tooltip has-tooltip-primary"
:data-tooltip="$t('global.more')"
Expand Down
30 changes: 30 additions & 0 deletions components/tailored/messaging/pinned/Pinned.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<div id="pinned-messages" v-click-outside="() => {
$store.commit('togglePinned', false)
}">
<div class="pinned-wrap">
<UiScroll
verticalScroll
scrollbarVisibility="scroll"
enableWrap>
<div class="header">
<font-awesome-icon :icon="['far', 'thumbtack']" />
<TypographySubtitle :size="6" text="Pinned Messages" />
</div>
<div class="filters">
<span class="filter active-filter">New</span>
<span class="filter">Old</span>
<span class="filter">Files</span>
</div>
<UiHorizontalRule />
<div v-for="message in $mock.pinnedMessages" class="wrap">
<TailoredMessagingMessage
hide-actions
:message="message"
:from="$mock.users.filter(u => u.address === message.from)[0].name"
:key="message.id" />
<InteractablesButton size="small" type="dark" text="Jump" />
<font-awesome-icon :icon="['far', 'times']" />
</div>
</UiScroll>
</div>
</div>
94 changes: 94 additions & 0 deletions components/tailored/messaging/pinned/Pinned.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#pinned-messages {
position: absolute;
display: inline-flex;
top: calc(@statusbar-height - @light-spacing);
width: 22rem;
background: @semitransparent-light-gradient;
border-radius: @corner-rounding;
border: @light-border;
backdrop-filter: @blur;
max-height: 50vh;
overflow: hidden;

.pinned-wrap {
overflow: hidden;
}
img {
max-width: 100%;
}

.header {
.subtitle {
font-size: @micro-text-size !important;
font-family: @primary-font;
}
font-size: @micro-text-size !important;
font-family: @primary-font;
}

hr {
margin-top: 0;
}

.filters {
text-align: right;
}
.filter {
font-size: @text-size;
display: inline-block;
justify-self: flex-end;
opacity: 0.75;
cursor: pointer;
}

.active-filter {
opacity: 1;
}

.scroll-area {
max-height: 100%;
padding: @light-spacing @light-spacing;
padding-right: @normal-spacing;

.is-message {
margin-bottom: 0;
}
.wrap {
position: relative;
padding: 0 @light-spacing;
padding-bottom: @light-spacing;
margin-bottom: @light-spacing;
background: @semitransparent-lighter-gradient;
border-radius: @corner-rounding;
border: @light-border;

.button {
padding: 0 @light-spacing;
height: unset;
float: right;
position: absolute;
top: @light-spacing;
right: @light-spacing;
}
.button.is-dark {
right: 2rem;
}
.fa-times {
position: absolute;
right: @light-spacing;
top: @light-spacing;
font-size: @text-size;
cursor: pointer;
}
}
}
}

@media only screen and (max-width: @mobile-breakpoint) {
#pinned-messages {
width: unset;
left: @light-spacing;
right: @light-spacing;
max-height: 75vh;
}
}
7 changes: 7 additions & 0 deletions components/tailored/messaging/pinned/Pinned.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template src="./Pinned.html"></template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({})
</script>
<style lang="less" src="./Pinned.less"></style>
52 changes: 52 additions & 0 deletions mock/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,44 @@ export type Message = {
at: number
type: string
payload: any
pinned: boolean
}

export const PinnedMessages = [
{
id: '00-d0-10',
at: 1620515545000,
type: 'text',
from: '0xdf9eb223bafbe5c5271415c75aecd68c21fe3d7f',
payload:
'Radiant shooting star wavelength helium local arm penumbra total eclipse Lagrange points nova Doppler shift full moon spectroscope universe sky ionosphere NASA orbital eccentricity superior planets visual magnitude heliocentric',
replies: [
{
id: '01-432-138',
from: '0x07ee55aa48bb72dcc6e9d78256648910de513eca',
to: '00-d0-10',
type: 'text',
at: 1620515583000,
payload: 'This is a late message reply',
reactions: [],
},
],
reactions: [],
},
{
from: '0xdf9eb223bafbe5c5271415c75aecd68c21fe3d7f',
id: '00-c0-11',
at: 1620515543400,
type: 'image',
payload: {
type: 'img/png',
url: 'https://i.redd.it/buk8te6ried61.png',
},
replies: [],
reactions: [],
},
]

export const Messages = [
{
id: '00-00-01',
Expand All @@ -33,6 +69,19 @@ export const Messages = [
replies: [],
reactions: [],
},
{
id: '00-123193-10',
at: 1620515543000,
type: 'file',
payload: {
filename: 'satellite.tar.gz',
type: 'application/tar',
size: 19203,
src: 'https://gateway.pinata.cloud/ipfs/QmTm39rhwcPYMFc788KVBxtM7UNaxoucovFyY21gsmFqz9',
},
replies: [],
reactions: [],
},
],
},
{
Expand Down Expand Up @@ -84,6 +133,7 @@ export const Messages = [
id: '00-123193-10',
at: 1620515543000,
type: 'file',
pinned: true,
payload: {
filename: 'satellite.tar.gz',
type: 'application/tar',
Expand Down Expand Up @@ -141,6 +191,7 @@ export const Messages = [
id: '00-d0-10',
at: 1620515545000,
type: 'text',
pinned: true,
payload:
'Radiant shooting star wavelength helium local arm penumbra total eclipse Lagrange points nova Doppler shift full moon spectroscope universe sky ionosphere NASA orbital eccentricity superior planets visual magnitude heliocentric',
replies: [
Expand All @@ -160,6 +211,7 @@ export const Messages = [
id: '00-c0-11',
at: 1620515543400,
type: 'image',
pinned: true,
payload: {
type: 'img/png',
url: 'https://i.redd.it/buk8te6ried61.png',
Expand Down
3 changes: 2 additions & 1 deletion plugins/local/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
marketFilters,
marketProducts,
} from '~/mock/marketplace'
import { Messages } from '~/mock/messages'
import { Messages, PinnedMessages } from '~/mock/messages'
import { Servers, Unreads, ServerInfo } from '~/mock/servers'
import { CallUsers, Users } from '~/mock/users'

Expand All @@ -24,6 +24,7 @@ const mock = {
},
unreads: Unreads,
messages: Messages,
pinnedMessages: PinnedMessages,
marketplace: {
marketCategories,
marketFilters,
Expand Down
6 changes: 6 additions & 0 deletions store/ui/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { MessageGroup } from '~/types/messaging'
import { Channel } from '~/types/ui/server'

export default {
togglePinned(state: NuxtState, visible: Boolean) {
state.ui = {
...state.ui,
showPinned: visible,
}
},
toggleContextMenu(state: NuxtState, enabled: Boolean) {
state.ui = {
...state.ui,
Expand Down
Loading

0 comments on commit accad2c

Please sign in to comment.