-
Notifications
You must be signed in to change notification settings - Fork 126
feat(twitch/chat): mod icons with reasons #1192
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
Open
pimothyxd
wants to merge
9
commits into
SevenTV:master
Choose a base branch
from
pimothyxd:feat/twitch-chat-mod-reasons
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
09e9277
feat(twitch/chat): add mod action reasons
pimothyxd 222c766
chore: update changelog
pimothyxd 6e0ca91
feat(twitch/chat): add option to hide pin confirmation prompt
pimothyxd cb90bde
chore: fix lint issues
pimothyxd f8abc27
chore: fix lint issues
pimothyxd cb1ee37
refactor: add max-width to action reasons float
pimothyxd acbdcc0
Merge branch 'master' into feat/twitch-chat-mod-reasons
zxr173 ca71c26
Merge branch 'master' into feat/twitch-chat-mod-reasons
zxr173 76a9326
fix: vue event handlers
pimothyxd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| <template> | ||
| <main class="seventv-settings-action-reasons"> | ||
| <div class="create-new"> | ||
| <FormInput label="New Reason..." :onkeydown="onNewReason" /> | ||
| </div> | ||
|
|
||
| <UiScrollable> | ||
| <div v-for="(reason, index) in reasons" :key="index" class="seventv-settings-action-reason-item"> | ||
| <div class="controls"> | ||
| <div class="control" @click="onReasonMove(index, 'up')"> | ||
| <ArrowIcon for="exit-icon" direction="up" /> | ||
| </div> | ||
| <div class="control" @click="onReasonMove(index, 'down')"> | ||
| <ArrowIcon for="exit-icon" direction="down" /> | ||
| </div> | ||
| </div> | ||
| <div class="content"> | ||
| <div class="use-virtual-input" tabindex="0" @click="onInputFocus(index)"> | ||
| <span>{{ reason }}</span> | ||
| <FormInput | ||
| :ref="(n) => virtualInputs.set(index, n as InstanceType<typeof FormInput>)" | ||
| :model-value="reason" | ||
| @blur="onInputBlur(index)" | ||
| /> | ||
| </div> | ||
| <div v-tooltip="'Remove'" class="control" @click="onReasonRemove(index)"> | ||
| <CloseIcon tabindex="0" /> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </UiScrollable> | ||
| </main> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { clamp } from "@vueuse/core"; | ||
| import { useConfig } from "@/composable/useSettings"; | ||
| import FormInput from "@/site/global/components/FormInput.vue"; | ||
| import ArrowIcon from "@/assets/svg/icons/ArrowIcon.vue"; | ||
| import CloseIcon from "@/assets/svg/icons/CloseIcon.vue"; | ||
| import UiScrollable from "@/ui/UiScrollable.vue"; | ||
|
|
||
| const reasons = useConfig<string[]>("chat.mod_action_reasons.list"); | ||
|
|
||
| const virtualInputs = new Map<number, InstanceType<typeof FormInput>>(); | ||
|
|
||
| function onNewReason(event: KeyboardEvent) { | ||
| if (event.target instanceof HTMLInputElement === false) return; | ||
| if (event.target.value.length === 0) return; | ||
|
|
||
| if (event.key !== "Enter") return; | ||
|
|
||
| reasons.value = [...reasons.value, event.target.value]; | ||
| event.target.value = ""; | ||
| } | ||
|
|
||
| function onReasonRemove(index: number) { | ||
| reasons.value.splice(index, 1); | ||
| reasons.value = [...reasons.value]; | ||
| } | ||
|
|
||
| function onReasonMove(index: number, direction: "up" | "down") { | ||
| const newIndex = clamp(direction === "up" ? index - 1 : index + 1, 0, reasons.value.length); | ||
|
|
||
| const [reason] = reasons.value.splice(index, 1); | ||
| reasons.value.splice(newIndex, 0, reason); | ||
| reasons.value = [...reasons.value]; | ||
| } | ||
|
|
||
| function onInputFocus(index: number) { | ||
| const input = virtualInputs.get(index); | ||
|
|
||
| input?.focus(); | ||
| } | ||
|
|
||
| function onInputBlur(index: number) { | ||
| const input = virtualInputs.get(index); | ||
|
|
||
| if (!input) return; | ||
|
|
||
| const value = input.value(); | ||
|
|
||
| // if the input is now empty, we shall delete the reason | ||
| if (!value || value.length === 0) { | ||
| reasons.value.splice(index, 1); | ||
| } else { | ||
| reasons.value.splice(index, 1, value); | ||
| } | ||
|
|
||
| reasons.value = [...reasons.value]; | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped lang="scss"> | ||
| .seventv-settings-action-reasons { | ||
| display: grid; | ||
| grid-template-rows: min-content 1fr; | ||
| max-height: 35vh; | ||
| gap: 1rem; | ||
|
|
||
| .create-new { | ||
| display: flex; | ||
| flex-direction: row; | ||
|
|
||
| input { | ||
| width: 100%; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| .control { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| width: 3rem; | ||
| height: 3rem; | ||
|
|
||
| &:hover { | ||
| background: hsla(0deg, 0%, 30%, 32%); | ||
| border-radius: 0.25rem; | ||
| cursor: pointer; | ||
| } | ||
| } | ||
|
|
||
| .seventv-settings-action-reason-item { | ||
| display: flex; | ||
| flex-direction: row; | ||
| padding: 0.5rem; | ||
| width: 100%; | ||
| align-items: center; | ||
| gap: 1rem; | ||
|
|
||
| &:hover, | ||
| &:focus-within { | ||
| background-color: #3333; | ||
| } | ||
|
|
||
| &:nth-child(odd) { | ||
| background-color: var(--seventv-background-shade-2); | ||
| } | ||
|
|
||
| .controls { | ||
| display: flex; | ||
| justify-content: center; | ||
| color: var(--seventv-input-border); | ||
| } | ||
|
|
||
| .content { | ||
| display: grid; | ||
| grid-template-columns: 1fr min-content; | ||
| align-items: center; | ||
| width: 100%; | ||
| gap: 1rem; | ||
| height: 3.5rem; | ||
| } | ||
|
|
||
| .use-virtual-input { | ||
| cursor: text; | ||
| padding: 0.5rem; | ||
| display: block; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| white-space: nowrap; | ||
|
|
||
| input { | ||
| width: 0; | ||
| height: 0; | ||
| opacity: 0; | ||
| } | ||
|
|
||
| &:focus-within { | ||
| padding: 0; | ||
|
|
||
| span { | ||
| display: none; | ||
| } | ||
|
|
||
| input { | ||
| opacity: 1; | ||
| width: 100%; | ||
| height: initial; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.