This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add route for extension auth + Modq improvements (#1013)
- Loading branch information
Showing
10 changed files
with
752 additions
and
121 deletions.
There are no files selected for viewing
This file contains 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 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 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,92 @@ | ||
<template> | ||
<div class="seventv-toggle-outer"> | ||
<span v-if="left" class="seventv-toggle-option"> | ||
{{ left }} | ||
</span> | ||
<label class="seventv-toggle-switch" :for="id"> | ||
<input :id="id" v-model="value" tabindex="0" type="checkbox" @change="$emit('update:modelValue', value)" /> | ||
<div class="seventv-toggle round"></div> | ||
</label> | ||
<span v-if="right" class="seventv-toggle-option"> | ||
{{ right }} | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from "vue"; | ||
const props = defineProps<{ | ||
id: string; | ||
left?: string; | ||
right?: string; | ||
modelValue: boolean; | ||
}>(); | ||
const value = ref(props.modelValue); | ||
defineEmits<{ | ||
(e: "update:modelValue", value: boolean): void; | ||
}>(); | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.seventv-toggle-outer { | ||
display: flex; | ||
flex-wrap: nowrap; | ||
align-items: center; | ||
gap: 0.8rem; | ||
} | ||
.seventv-toggle-option { | ||
font-size: 1rem; | ||
font-weight: 600; | ||
vertical-align: center; | ||
} | ||
.seventv-toggle-switch { | ||
display: inline-block; | ||
height: 1rem; | ||
position: relative; | ||
width: 2rem; | ||
} | ||
.seventv-toggle { | ||
inset: 0; | ||
cursor: pointer; | ||
position: absolute; | ||
transition: 0.25s; | ||
outline: 0.01rem solid currentcolor; | ||
} | ||
.seventv-toggle::before { | ||
bottom: 0.15rem; | ||
content: ""; | ||
height: 0.7rem; | ||
left: 0.15rem; | ||
position: absolute; | ||
transition: 0.25s; | ||
width: 0.7rem; | ||
background-color: currentcolor; | ||
} | ||
input { | ||
opacity: 0; | ||
&:focus + .seventv-toggle { | ||
outline: 0.1rem solid black; | ||
} | ||
&:checked + .seventv-toggle::before { | ||
transform: translateX(1rem); | ||
} | ||
} | ||
.seventv-toggle.round { | ||
border-radius: 0.25rem; | ||
} | ||
.seventv-toggle.round::before { | ||
border-radius: 0.25rem; | ||
} | ||
</style> |
This file contains 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 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,7 @@ | ||
import { RouteRecordRaw } from "vue-router"; | ||
|
||
export const ExtensionAuthRoute = { | ||
path: "/extension/auth", | ||
name: "ExtensionAuth", | ||
component: () => import("@/views/ExtensionAuth.vue"), | ||
} as RouteRecordRaw; |
This file contains 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 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,39 @@ | ||
<template> | ||
<div class="extension-auth-content"> | ||
<LoginButton v-if="!actor.user" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { watch } from "vue"; | ||
import { useActor } from "@/store/actor"; | ||
import { useStore } from "@/store/main"; | ||
import LoginButton from "@/components/utility/LoginButton.vue"; | ||
const store = useStore(); | ||
const actor = useActor(); | ||
window.addEventListener("message", function listener(e) { | ||
if (e.origin !== "https://www.twitch.tv") return; | ||
if (e.data !== "7tv-token-request") return; | ||
window.removeEventListener("message", listener); | ||
watch( | ||
() => store.authToken, | ||
(t) => { | ||
if (!t) return; | ||
e.source?.postMessage({ type: "7tv-token", token: t }, { targetOrigin: "https://www.twitch.tv/*" }); | ||
}, | ||
{ immediate: true }, | ||
); | ||
}); | ||
</script> | ||
|
||
<style lang="scss"> | ||
nav { | ||
display: none; | ||
} | ||
.extension-auth-content { | ||
display: flex; | ||
margin: auto; | ||
justify-content: center; | ||
} | ||
</style> |
Oops, something went wrong.