From 9f3351292b60832649380816fb30e418a18e175a Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Fri, 27 Sep 2024 14:38:43 +0000 Subject: [PATCH] Ok fine no contentEditable, not even a little as a treat --- .../0/ministry_of_truth/components/Input.css.ts | 4 +++- .../0/ministry_of_truth/components/Input.tsx | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/airstrip_one/0/ministry_of_truth/components/Input.css.ts b/src/app/airstrip_one/0/ministry_of_truth/components/Input.css.ts index 6fd02f8..8f0fde6 100644 --- a/src/app/airstrip_one/0/ministry_of_truth/components/Input.css.ts +++ b/src/app/airstrip_one/0/ministry_of_truth/components/Input.css.ts @@ -1,4 +1,4 @@ -import { style } from "@vanilla-extract/css"; +import { style } from '@vanilla-extract/css'; export const message_style = style({ boxSizing: 'border-box', @@ -8,10 +8,12 @@ export const message_style = style({ border: 'none', padding: '0.5em', fontSize: '1em', + fontFamily: 'inherit', color: 'magenta', backgroundColor: 'black', overflowWrap: 'break-word', textAlign: 'center', + resize: 'none', ':focus': { outline: 'none', }, diff --git a/src/app/airstrip_one/0/ministry_of_truth/components/Input.tsx b/src/app/airstrip_one/0/ministry_of_truth/components/Input.tsx index 9dc3e08..c36f302 100644 --- a/src/app/airstrip_one/0/ministry_of_truth/components/Input.tsx +++ b/src/app/airstrip_one/0/ministry_of_truth/components/Input.tsx @@ -1,8 +1,9 @@ 'use client' -import { useEffect, useRef } from 'react'; +import { useLayoutEffect, useRef } from 'react'; import { useSearchParams } from 'next/navigation'; +import comic_sans from '../../../../comic.ts'; import { message_style } from '../components/Input.css'; export default function Input() { @@ -13,6 +14,8 @@ export default function Input() { const encoded = btoa(message); const new_url = `${window.location.protocol}//${window.location.host}${window.location.pathname}?e=${encoded}`; window.history.replaceState(null, '', new_url); + input_ref.current!.style.height = ""; + input_ref.current!.style.height = `${input_ref.current!.scrollHeight}px`; } const message = search_params.get('e') ? @@ -22,18 +25,18 @@ export default function Input() { ?? 'At the apex of the pyramid comes Big Brother. Big Brother is infallible and all-powerful. Every success, every achievement, every victory, every scientific discovery, all knowledge, all wisdom, all happiness, all virtue, are held to issue directly from his leadership and inspiration.' ); - useEffect(() => { + useLayoutEffect(() => { set_message(message); }); return ( -

set_message(input_ref.current!.textContent ?? '')} - contentEditable - > - {message} -

+ defaultValue={message} + /> ); }