Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DES-201: add a YouTube-like event bar #432

Merged
merged 24 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c712b76
feat: add additional data to paid events
vyneer Mar 11, 2024
83d5eca
feat: add a function to completely hide the pinned message
vyneer Mar 11, 2024
bf100a8
feat: add a youtube-like paid event bar
vyneer Mar 12, 2024
2aca025
fix: sort events on `PAIDEVENTS` received
vyneer Mar 28, 2024
acf1a47
chore: fix formatting in ChatEventBar
vyneer Mar 28, 2024
9f36223
chore: rename `expiry` to `expirationTimestamp`
vyneer Jul 26, 2024
e937126
refactor: break up `calculateExpiryPercentage` func
vyneer Jul 26, 2024
008ce3a
chore: rename event-bar stuff
vyneer Jul 26, 2024
70f815f
fix: forgot to rename a thing
vyneer Jul 26, 2024
9d0f41a
refactor: use animations for appearing and disappearing
vyneer Jul 26, 2024
f93b639
fix: transition not working properly on the event bar button
vyneer Aug 5, 2024
6184d29
fix: ignore focus mode on event bar buttons
vyneer Aug 5, 2024
de2a728
chore: minor css tweaks
vyneer Oct 17, 2024
2e6989d
chore: another small css tweak
vyneer Oct 17, 2024
fd21d10
chore: simplify some code
vyneer Oct 17, 2024
5da35ce
chore: add a comment
vyneer Oct 17, 2024
773a2b6
Merge branch 'master' into feat/event-bar
vyneer Oct 25, 2024
758d7ff
refactor: split event bar event into its own class
vyneer Oct 29, 2024
e76f797
chore: cleanup event handlers
vyneer Oct 29, 2024
bf3984d
refactor: switch to custom events for selected event toggling
vyneer Oct 30, 2024
7a95cfb
fix: remove unnecessary padding
vyneer Oct 30, 2024
e7096f2
chore: rename wrapper
vyneer Oct 30, 2024
61b755e
fix: update chat window position when eventbar shows up
vyneer Oct 30, 2024
46d9ffa
refactor: switch to EventEmitter
vyneer Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 119 additions & 4 deletions assets/chat/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -765,13 +765,121 @@ hr {
background-color: $color-chat-highlight;
}

/* Pinned Messages */
#chat-pinned-frame {
display: none;
/* Event bar */
#chat-event-bar {
&:empty {
display: none !important;
}

display: inline-flex;
overflow-x: scroll !important;
background: #151515;
z-index: 6;

// width = height (lmao firefox)
scrollbar-width: none;
--ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}

.msg-event-bar-wrapper {
cursor: pointer;
transition:
transform 500ms,
opacity 500ms;
opacity: 0;
transform: scale(0.1);

&.active {
transform: unset;
opacity: 1;
}

&:hover {
transition: transform 100ms;
transform: scale(1.05) !important;
}

&.removed {
transform: scale(0.1) !important;
}
}

.msg-chat {
margin: $gutter-sm $gutter-sm $gutter-sm $gutter-sm;
border-width: 2px;
}

.user {
&.scrolling {
display: inline-block;
animation: scrolling-event-username 12s linear 3s infinite;
word-wrap: normal;
}

&::before {
content: unset;
}

&:hover {
text-decoration: none;
}
}

.event-top {
padding: 0 $gutter-xs 0 0.4em;
}

.event-info {
padding-right: $gutter-xs;

&.scrolling {
overflow: hidden;
width: 74px;
}
}

.event-icon {
width: 2em;
height: 2em;
}

.rainbow-border::before {
margin: -2px;
}
}

@keyframes scrolling-event-username {
25%,
50% {
transform: translateX(calc(-100% + 74px));
}

75%,
100% {
transform: translateX(0%);
}
}

/* Hovering frame containing highlighted event from event bar and pinned message */
#chat-hover-frame {
padding: 4px;
position: absolute;
width: 100%;
z-index: 210;
}

/* Event highlight frame */
#chat-event-highlight-frame {
.msg-event-bar {
margin: $gutter-sm $gutter-sm $gutter-sm $gutter-sm;
}
}

/* Pinned Messages */
#chat-pinned-frame {
display: none;

&.active {
display: block;
Expand Down Expand Up @@ -878,6 +986,10 @@ hr {
&.msg-pinned {
opacity: 1;
}

&.msg-event-bar {
opacity: 1;
}
}

/* Emotes and combo */
Expand Down Expand Up @@ -1890,7 +2002,10 @@ button.btn {
#chat-output-frame {
margin: 0;
}
#chat-pinned-frame {
#chat-event-bar {
display: none !important;
}
#chat-hover-frame {
display: none !important;
}

Expand Down
46 changes: 42 additions & 4 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
ChatEmoteTooltip,
ChatSettingsMenu,
ChatUserInfoMenu,
ChatEventBar,
} from './menus';
import ChatAutoComplete from './autocomplete';
import ChatInputHistory from './history';
Expand Down Expand Up @@ -145,6 +146,7 @@ class Chat {
this.source.on('DONATION', (data) => this.onDONATION(data));
this.source.on('UPDATEUSER', (data) => this.onUPDATEUSER(data));
this.source.on('DEATH', (data) => this.onDEATH(data));
this.source.on('PAIDEVENTS', (data) => this.onPAIDEVENTS(data));

this.control.on('SEND', (data) => this.cmdSEND(data));
this.control.on('HINT', (data) => this.cmdHINT(data));
Expand Down Expand Up @@ -294,6 +296,7 @@ class Chat {
this.mainwindow = new ChatWindow('main').into(this);
this.mutedtimer = new MutedTimer(this);
this.chatpoll = new ChatPoll(this);
this.eventBar = new ChatEventBar(this);
this.pinnedMessage = null;

this.windowToFront('main');
Expand Down Expand Up @@ -1284,19 +1287,54 @@ class Chat {
}

onSUBSCRIPTION(data) {
MessageBuilder.subscription(data).into(this);
const event = MessageBuilder.subscription(data);
event.into(this);
this.eventBar.add(event);
}

onGIFTSUB(data) {
MessageBuilder.gift(data).into(this);
const event = MessageBuilder.gift(data);
event.into(this);
this.eventBar.add(event);
}

onMASSGIFT(data) {
MessageBuilder.massgift(data).into(this);
const event = MessageBuilder.massgift(data);
event.into(this);
this.eventBar.add(event);
}

onDONATION(data) {
MessageBuilder.donation(data).into(this);
const event = MessageBuilder.donation(data);
event.into(this);
this.eventBar.add(event);
}

onPAIDEVENTS(lines) {
lines.forEach((line) => {
const { eventname, data } = this.source.parse({ data: line });
switch (eventname) {
case 'SUBSCRIPTION': {
this.eventBar.add(MessageBuilder.subscription(data));
break;
}
case 'GIFTSUB': {
this.eventBar.add(MessageBuilder.gift(data));
break;
}
case 'MASSGIFT': {
this.eventBar.add(MessageBuilder.massgift(data));
break;
}
case 'DONATION': {
this.eventBar.add(MessageBuilder.donation(data));
break;
}
default:
break;
}
});
this.eventBar.sort();
}

onPRIVMSGSENT() {
Expand Down
5 changes: 4 additions & 1 deletion assets/chat/js/focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class ChatUserFocus {
this.chat = chat;
this.css = css;
this.focused = [];
this.chat.output.on('click', (e) => this.toggleElement(e.target));
this.chat.output.on('click', (e) => {
this.toggleElement(e.target);
this.chat.eventBar.unhighlight();
});
}

toggleElement(target) {
Expand Down
Loading