Skip to content

Commit 8e7e281

Browse files
committed
Add channel and user list stores
1 parent 17e84b0 commit 8e7e281

16 files changed

Lines changed: 415 additions & 22 deletions

File tree

src/App.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
<BApp>
33
<h1>You are {{ irc.isConnected ? 'connected' : 'not connected' }}</h1>
44

5-
<LoginForm @login="irc.signIn" />
5+
<ChatApp v-if="irc.isConnected" />
6+
<LoginForm v-else @login="irc.signIn" />
67
</BApp>
78
</template>
89

910
<script setup lang="ts">
11+
import ChatApp from '#components/ChatApp.vue';
1012
import LoginForm from '#components/LoginForm.vue';
1113
import { useIrcStore } from '#stores';
1214
import { BApp } from 'bootstrap-vue-next';

src/components/ChatApp.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<DraggableWindow>
3+
<template v-slot:main>
4+
<Transition name="fade"> </Transition>
5+
</template>
6+
</DraggableWindow>
7+
</template>
8+
9+
<script setup lang="ts">
10+
import DraggableWindow from './DraggableWindow.vue';
11+
// TODO: Re-implement resizing tracking
12+
</script>
13+
14+
<style scoped>
15+
.fade-enter-active,
16+
.fade-leave-active {
17+
transform-origin: top center;
18+
@media (prefers-reduced-motion: no-preference) {
19+
transition: transform 200ms;
20+
}
21+
}
22+
23+
.fade-enter,
24+
.fade-leave-to {
25+
transform-origin: top center;
26+
/* Moves everything up without interfering with top bar. */
27+
transform: scaleY(0);
28+
}
29+
</style>

src/components/DraggableWindow.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<template>
33
<!-- TODO: Figure out keyboard accessibility... -->
44
<!-- eslint-disable-next-line vuejs-accessibility/click-events-have-key-events -->
5-
<div ref="draggableContainer" id="draggable-container" @click="internalClick">
5+
<div ref="draggableContainer" class="draggable-container" @click="internalClick">
66
<div class="handle handle-l" @mousedown="resizeMouseDown($event, 'l')" />
77
<div class="handle handle-tl" @mousedown="resizeMouseDown($event, 'tl')" />
88
<div class="handle handle-t" @mousedown="resizeMouseDown($event, 't')" />
@@ -11,7 +11,7 @@
1111
<div class="handle handle-br" @mousedown="resizeMouseDown($event, 'br')" />
1212
<div class="handle handle-b" @mousedown="resizeMouseDown($event, 'b')" />
1313
<div class="handle handle-bl" @mousedown="resizeMouseDown($event, 'bl')" />
14-
<div id="draggable-header" @mousedown="dragMouseDown">
14+
<div class="draggable-header" @mousedown="dragMouseDown">
1515
<slot name="header" />
1616
</div>
1717
<slot name="main" />
@@ -21,8 +21,8 @@
2121

2222
<script lang="ts" setup>
2323
import gsap from 'gsap';
24-
import throttle from 'lodash/throttle';
25-
import { computed, onMounted, ref, watch } from 'vue';
24+
import { throttle } from 'lodash';
25+
import { computed, onMounted, reactive, ref, watch } from 'vue';
2626
2727
const props = defineProps({
2828
enabled: {
@@ -40,19 +40,19 @@
4040
(event: 'closeDragElement'): void;
4141
}>();
4242
43-
const positions = {
43+
const positions = reactive({
4444
clientX: 0,
4545
clientY: 0,
4646
movementX: 0,
4747
movementY: 0,
48-
};
49-
const resizePositions = {
48+
});
49+
const resizePositions = reactive({
5050
clientX: 0,
5151
clientY: 0,
5252
movementX: 0,
5353
movementY: 0,
5454
dir: '',
55-
};
55+
});
5656
5757
const draggableContainer = ref<HTMLDivElement>();
5858
/**
@@ -300,12 +300,12 @@
300300
defineExpose({ minimize });
301301
</script>
302302

303-
<style>
304-
#draggable-container {
303+
<style scoped>
304+
.draggable-container {
305305
position: absolute;
306306
z-index: 9;
307307
}
308-
#draggable-header {
308+
.draggable-header {
309309
z-index: 10;
310310
}
311311

src/constants/channels.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const DEFAULT_CHANNELS = ['#general', '#off-topic', '#help', '#labs', '#test'];
2+
3+
export const CHANNEL_DESCRIPTIONS: Record<string, string> = {
4+
'#general': 'General chat',
5+
'#off-topic': 'Off-topic chat',
6+
'#help': 'Help requests',
7+
'#labs': 'Discussion related to labs',
8+
};

src/constants/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
export * from './channels';
12
export * from './colors';
23
export * from './emoticons';
4+
export * from './users';

src/constants/users.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { User } from '#models';
2+
3+
export const ANONYMOUS_USER: User = {
4+
username: 'anonymous',
5+
uid: '0',
6+
nicks: ['anonymous^0'],
7+
away: false,
8+
awayReason: '',
9+
};

src/models/channel.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { BanStatus } from './ban-status';
2+
import type { Message } from './message';
3+
4+
export interface Channel {
5+
name: string;
6+
messages: Message[];
7+
usersTyping: string[];
8+
banStatus: BanStatus;
9+
notificationsEnabled: boolean;
10+
/** User is mentioned. Cleared when channel is read. */
11+
hasMention: boolean;
12+
/** User or keyword mentioned. Cleared when channel is read. */
13+
hasNotification: boolean;
14+
}

src/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './ban';
22
export * from './ban-status';
3+
export * from './channel';
34
export * from './message';
45
export * from './user';

src/models/message.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import type { User } from './user';
22

3+
export type MessageType = 'message' | 'action' | 'system';
4+
35
export interface Message {
46
time: Date;
57
starred: boolean;
68
message: string;
79
target: string;
810
user: User;
9-
isAction: boolean;
11+
type: MessageType;
1012
tags: Record<string, string>;
1113
}

src/models/user.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface User {
22
username: string;
3+
/** User ID */
34
uid: string;
45
nicks: string[];
56
away: boolean;

0 commit comments

Comments
 (0)