From 5f0ca2c209ac90d18de68863558f73852d56ab04 Mon Sep 17 00:00:00 2001 From: Janis Date: Sun, 12 Nov 2023 18:03:20 +0100 Subject: [PATCH] clean up --- src/Generator.tsx | 58 ++++++++++++++++++--------------------- src/styles/Generator.scss | 42 ++++++++++++++-------------- src/styles/Viewer.scss | 13 +++++---- src/styles/index.scss | 28 ++++++++++++++++--- 4 files changed, 80 insertions(+), 61 deletions(-) diff --git a/src/Generator.tsx b/src/Generator.tsx index 1460fa8..d83a3a1 100644 --- a/src/Generator.tsx +++ b/src/Generator.tsx @@ -1,9 +1,10 @@ -import React, { ChangeEvent, useRef, useState } from "react"; +import React, { ChangeEvent, useRef, useState, useEffect } from "react"; import "@styles/Generator.scss"; import Viewer from "./Viewer"; export default function Generator() { - const [outputUrl, setOutputUrl] = useState(new URL(window.location.href).toString()); + // State variables + const [outputUrl, setOutputUrl] = useState(() => new URL(window.location.href).toString()); const copiedTooltipRef = useRef(null); const [remoteAppPort, setRemoteAppPort] = useState(5899); @@ -11,10 +12,12 @@ export default function Generator() { const [hideNonTalking, setHideNonTalking] = useState(false); const [clientLimit, setClientLimit] = useState(0); - React.useEffect(() => { + // Effect to generate URL when dependencies change + useEffect(() => { generateUrl(); }, [remoteAppPort, showChannelName, hideNonTalking, clientLimit]); + // Function to generate the output URL function generateUrl() { const url = new URL(window.location.href.replace("/generate", "")); url.searchParams.set("remoteAppPort", remoteAppPort.toString()); @@ -25,6 +28,7 @@ export default function Generator() { setOutputUrl(url.toString()); } + // Function to copy URL to clipboard function copy() { navigator.clipboard.writeText(outputUrl); @@ -43,16 +47,21 @@ export default function Generator() { return (
+ {/* Header */}

TS5-OBS-Overlay Generator

by DerTyp7

+ + {/* Instructions */}

1. Customize your settings

2. Copy the generated URL

3. Paste the URL into the BrowserSource URL field in OBS

Click here for detailed instructions
+ + {/* Output Section */}

{outputUrl} @@ -64,61 +73,46 @@ export default function Generator() { Copied!

+ + {/* Generator Content */}
+ {/* Configurations */}

Configurations

+ {/* Option Sections */}
-
{ - setShowChannelName(!showChannelName); - }} - > + {/* Show Channel Name Option */} +
setShowChannelName(!showChannelName)}> - +
-
{ - setHideNonTalking(!hideNonTalking); - }} - > + {/* Hide Non-Talking Clients Option */} +
setHideNonTalking(!hideNonTalking)}>
+ {/* Client Limit Option */}
- ) => { - setClientLimit(parseInt(e.target.value)); - }} - /> + ) => setClientLimit(parseInt(e.target.value))} />
+ {/* RemoteApp-Port Option */}
- ) => { - setRemoteAppPort(parseInt(e.target.value)); - }} - /> + ) => setRemoteAppPort(parseInt(e.target.value))} />
+ {/* Preview */}
diff --git a/src/styles/Generator.scss b/src/styles/Generator.scss index f704ad0..cde0957 100644 --- a/src/styles/Generator.scss +++ b/src/styles/Generator.scss @@ -3,6 +3,7 @@ $breakpoint-1: 1200px; $breakpoint-2: 790px; $breakpoint-3: 600px; +// Tooltip animation keyframes @keyframes tooltipAnimation { 0% { opacity: 0; @@ -16,7 +17,7 @@ $breakpoint-3: 600px; .generator { background-color: #232528; - color: white; + color: #fff; width: 100%; display: flex; height: 100%; @@ -39,25 +40,17 @@ $breakpoint-3: 600px; gap: 10px 50px; flex-wrap: wrap; padding-bottom: 10px; + p, a { font-size: 0.8rem; } + p { color: #b4b4b4; } - - a { - color: #3abe78; - font-weight: bold; - text-decoration: none; - transition: all 100ms ease-in-out; - - &:hover { - color: #31f399; - } - } } + .output { display: flex; flex-direction: row; @@ -142,6 +135,7 @@ $breakpoint-3: 600px; justify-content: left; column-gap: 10px; width: 100%; + input { -webkit-appearance: none; -moz-appearance: none; @@ -154,7 +148,7 @@ $breakpoint-3: 600px; outline: none; transition: all 200ms ease-in-out; position: relative; - color: white; + color: #fff; text-align: center; &::-webkit-outer-spin-button, @@ -163,7 +157,7 @@ $breakpoint-3: 600px; margin: 0; } - // make it a cross when checked + // Cross when checked styles &:checked { &:after { content: ""; @@ -193,7 +187,10 @@ $breakpoint-3: 600px; input[type="number"] { width: 50px; + height: 25px; cursor: text; + -moz-appearance: textfield; + appearance: textfield; } label { @@ -202,9 +199,13 @@ $breakpoint-3: 600px; } } } + + // Preview styles .preview { flex: 1; border: 2px solid #31f39973; + + // Viewer styles (see src/styles/Viewer.scss) .viewer { background-image: url("/images/viewer_example_background.png"); background-repeat: no-repeat; @@ -214,6 +215,7 @@ $breakpoint-3: 600px; } } + // Responsive styles @media screen and (max-width: $breakpoint-1) { .generatorContent { flex-direction: column; @@ -243,13 +245,13 @@ $breakpoint-3: 600px; .url { width: 200px; } - } - .generatorContent { - .configurations { - .options { - flex-direction: column; - gap: 30px; + .generatorContent { + .configurations { + .options { + flex-direction: column; + gap: 30px; + } } } } diff --git a/src/styles/Viewer.scss b/src/styles/Viewer.scss index 890d605..0b3a269 100644 --- a/src/styles/Viewer.scss +++ b/src/styles/Viewer.scss @@ -1,14 +1,14 @@ +//* Viewer styles +// this file contains styles for the viewer component +// styles for the viewer component should not be modified somewhere else + .viewer { display: flex; flex-direction: column; - gap: 0 0; - font-size: 3rem; - color: white; - padding: 10px; + padding: 0.5rem; h1, p { - margin: 0; background-color: #2f313680; padding: 0.25rem 0.5rem; border-radius: 0.25rem; @@ -18,6 +18,7 @@ max-width: 20ch; user-select: none; } + .channelNameContainer { display: flex; align-items: center; @@ -31,12 +32,14 @@ align-items: center; margin: 0.5rem 0; + // icon styles svg { width: 2.1rem; aspect-ratio: 1/1; margin-right: 0.5rem; } + // client name styles p { font-size: 1.4rem; } diff --git a/src/styles/index.scss b/src/styles/index.scss index c4ada0f..8406e2b 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -1,3 +1,4 @@ +// Reset styles for all elements * { font-family: Arial, Helvetica, sans-serif; font-weight: bold; @@ -7,19 +8,23 @@ box-sizing: border-box; } +// Set up basic styles for the entire page body, html { min-height: 100vh; min-width: 100%; display: flex; overflow-x: hidden; + color: #fff; } +// Ensure the root element takes up the full viewport #root { height: 100%; min-width: 100%; } +// Headline styles h1 { font-size: 1.8rem; } @@ -36,6 +41,7 @@ h4 { font-size: 1.1rem; } +// Common styles for heading elements h1, h2, h3, @@ -45,6 +51,19 @@ h6 { font-weight: bold; } +// Text styles +a { + color: #3abe78; + font-weight: bold; + text-decoration: none; + transition: all 100ms ease-in-out; + + &:hover { + color: #31f399; + } +} + +// Button styles button { background-color: #202024; color: #fff; @@ -54,13 +73,14 @@ button { padding: 10px 20px; cursor: pointer; transition: all 300ms ease-in-out; + &:hover { background-color: #42d486; color: #202024; } } -// custom dark themed scrollbar +// Custom dark-themed scrollbar ::-webkit-scrollbar { width: 5px; height: 5px; @@ -74,8 +94,8 @@ button { ::-webkit-scrollbar-thumb { background: #31f39973; border-radius: 10px; -} -::-webkit-scrollbar-thumb:hover { - background: #48ee95; + &:hover { + background: #48ee95; + } }