From bd67f2fcf2da67be1e2b178c00be707248c869bf Mon Sep 17 00:00:00 2001 From: lordlogo2002 Date: Sat, 19 Jul 2025 23:38:19 +0200 Subject: [PATCH] refactor: rename RickLabel to RickPanel and enhance click handling with stay focused option --- source/src/index.tsx | 66 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/source/src/index.tsx b/source/src/index.tsx index 7db028d..c84b4fe 100644 --- a/source/src/index.tsx +++ b/source/src/index.tsx @@ -1,32 +1,84 @@ import { h, render, Component } from 'nano-jsx' -class RickLabel extends Component { +class RickPanel extends Component { count = 0 + stayFocused = true handleClick = () => { this.count++ - window.open('https://www.youtube.com/watch?v=dQw4w9WgXcQ', '_blank') + + const win = window.open('https://www.youtube.com/watch?v=dQw4w9WgXcQ', '_blank') + + if (!this.stayFocused && win) { + win.focus() + } + this.update?.() } + handleCheckbox = (e: Event) => { + const input = e.target as HTMLInputElement + this.stayFocused = input.checked + } + + handleSansClick = () => { + window.open('https://www.youtube.com/watch?v=ZcoqR9Bwx1Y', '_blank') // Megalovania 🎶 + } + render() { return (
- Rickroll Me ({this.count}) +
+ 🔥 Rickroll Panel +
+ + + +
+ +
+ +
+ sans. +
) } } -export function insertRickLabel(target: HTMLElement | string = document.body): void { +export function insertRickPanel(target: HTMLElement | string = document.body): void { const container = typeof target === 'string' ? document.querySelector(target) : target if (container instanceof HTMLElement) { - render(, container) + render(, container) } }