From dcd213102f08ab1141ff83122771c92c69422172 Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Wed, 28 May 2025 11:24:37 +0200 Subject: [PATCH] cleanup CSS a bit --- src/component/app/App.css | 5 ++++ src/component/app/App.tsx | 24 +++++++++++++++++ src/component/expr/ExprBlock.css | 9 +------ src/component/expr/ExprBlock.tsx | 9 ++++--- src/component/expr/InputBlock.css | 27 +------------------ src/component/expr/InputBlock.tsx | 43 +++++++++++++++++++------------ src/component/other/Input.css | 19 ++++++++++++++ src/component/other/Input.tsx | 12 +++++---- src/component/other/Type.css | 18 ++----------- src/component/other/Type.tsx | 5 ++-- src/index.css | 21 +++++++++++++++ 11 files changed, 113 insertions(+), 79 deletions(-) create mode 100644 src/component/other/Input.css diff --git a/src/component/app/App.css b/src/component/app/App.css index 05564f1..21fbcf0 100644 --- a/src/component/app/App.css +++ b/src/component/app/App.css @@ -40,6 +40,11 @@ footer { color: white; } +footer ::selection { + color: dodgerblue; + background: lightblue; +} + footer a { color: white; } diff --git a/src/component/app/App.tsx b/src/component/app/App.tsx index 2509f1f..e2f557f 100644 --- a/src/component/app/App.tsx +++ b/src/component/app/App.tsx @@ -142,11 +142,35 @@ export function App() { // dynamic evalutions const evalResult = evalExpr(currentState, extendedEnv); + const onCopy = () => { + const serialized = JSON.stringify(currentState); + navigator.clipboard.write([new ClipboardItem({"text/plain": serialized})]); + } + const onPaste = () => { + navigator.clipboard.read().then(items => { + if (items.length === 1) { + items[0].getType("text/plain") + .then(value => value.text()) + .then(text => { + try { + const parsed = JSON.parse(text); + pushHistory(_ => parsed); + } + catch (e) { + console.error(e); + } + }) + } + }); + } + return ( <>
+ + { actionShortcuts.map(([_, keys, descr], i) => diff --git a/src/component/expr/ExprBlock.css b/src/component/expr/ExprBlock.css index 4cae95a..30d2bb1 100644 --- a/src/component/expr/ExprBlock.css +++ b/src/component/expr/ExprBlock.css @@ -3,13 +3,11 @@ position: relative; } .editor.error { - border: 1px solid red; + border: 1px solid red !important; display: inline-block; } .errorMessage { - display: none; - position: absolute; color: darkred; background-color: pink; margin-top: 4px; @@ -20,11 +18,6 @@ width: max-content; } -.editor:hover > .errorMessage { - display: block; - /* z-index: 9999; */ -} - .editor.unknown { border: 1px dashed dodgerblue; display: inline-block; diff --git a/src/component/expr/ExprBlock.tsx b/src/component/expr/ExprBlock.tsx index 32d7d80..747b18d 100644 --- a/src/component/expr/ExprBlock.tsx +++ b/src/component/expr/ExprBlock.tsx @@ -51,13 +51,14 @@ export function ExprBlock(props: ExprBlockProps) { const actions = getActions(globalContext, props.setState); const extraHandlers = Object.fromEntries(Object.entries(actions).map(([shortcut, action]) => [shortcut, (e) => { e.preventDefault(); action(); }])); - const err = props.typeInfo.err || evalExpr(props.state, env).err; - return + const evalResult = evalExpr(props.state, env); + const err = props.typeInfo.err || evalResult.err; + return {renderBlock[props.state.kind]()} - {(err !== undefined) && + {/* {(err !== undefined) && (
{err.message.trim()} -
)} + )} */} computeSuggestions(text, env, score), [text, score, env]); - useEffect(() => { if (focus) { inputRef.current?.focus(); @@ -145,29 +145,38 @@ export function InputBlock({ state, setState, score, onCancel, typeInfo }: Input }, }; - return <> - - + const err = typeInfo.err || evalExpr(state, env).err; + + return <> + + + + {(err !== undefined) && + (
+ {err.message.trim()} +
)} + +
:: - + ; } function Suggestions({ suggestions, onSelect, i, setI }) { return <>{(suggestions.length > 0) && -
+
{suggestions.map((suggestion, j) => - {(focus === "yes") && children} - {text}{focus && suggestion} + return + {text}{focus && suggestion} // @ts-ignore @@ -143,5 +144,6 @@ export function Input({placeholder, text, suggestion, onTextChange, onEnter, onC onBlur={() => setFocus("no")} spellCheck={false} /> - ; + {(focus === "yes") && children} + ; } diff --git a/src/component/other/Type.css b/src/component/other/Type.css index 2bd3da4..925d06f 100644 --- a/src/component/other/Type.css +++ b/src/component/other/Type.css @@ -6,13 +6,11 @@ .type { margin:1px; display: inline-block; - font-family: "Roboto", sans-serif; font-optical-sizing: auto; font-weight: 400; font-style: normal; font-variation-settings: "wdth" 100; - color: darkgrey; } @@ -60,7 +58,7 @@ .iteratorType { border-style: dashed; - /* animation: flickerAnimation 500ms steps(1) normal infinite; */ + animation: flickerAnimation 500ms steps(1) normal infinite; } /* Animations */ @@ -74,25 +72,13 @@ .typeSignature { display: inline-block; - position: relative; } - .typeDebug { - display: none; -} - -.typeSignature:hover > .typeDebug { - display: inline-block; - position: absolute; white-space-collapse: preserve; width: max-content; background-color: #d2ebf1e0; color: black; font-family: var(--my-monospace-font); padding: 4px; - z-index: 100; -} - -.editor:hover > .typeSignature { - display: inline-block; + font-size: 10pt; } diff --git a/src/component/other/Type.tsx b/src/component/other/Type.tsx index 9c4d01d..e908aca 100644 --- a/src/component/other/Type.tsx +++ b/src/component/other/Type.tsx @@ -5,10 +5,9 @@ import { ValueUnknown } from "./Value"; import type { TypeInfo } from "../../eval/infer_type"; export function TypeInfoBlock({typeInfo}: {typeInfo: TypeInfo}) { - return + return -
- {prettySS(typeInfo.subs)} + {prettySS(typeInfo.subs)}
; } diff --git a/src/index.css b/src/index.css index 5d7afd2..530c2f5 100644 --- a/src/index.css +++ b/src/index.css @@ -17,3 +17,24 @@ kbd { border-radius: 3px; margin: 0 2px 0 2px; } + + +.dropdownContainer { + position: relative; +} +.dropdown { + position: absolute; + display: block; + z-index: 100; +} +.hideIfMouseAway { + display: none; +} +.mouseOver:hover .dropdown { + display: block; +} + +::selection { + color: white; + background: dodgerblue; +} \ No newline at end of file