diff --git a/.gitignore b/.gitignore index 74f58d58..d64bcbed 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ sandbox/ .DS_Store .env.* *.log +/frontend/*.tsbuildinfo /frontend/.next /frontend/.cache /frontend/cache diff --git a/frontend/src/components/Diff/Diff.tsx b/frontend/src/components/Diff/Diff.tsx index b708fde9..5ca25dbf 100644 --- a/frontend/src/components/Diff/Diff.tsx +++ b/frontend/src/components/Diff/Diff.tsx @@ -21,13 +21,13 @@ const SelectedSourceLineContext = createContext(null) function FormatDiffText({ texts }: { texts: api.DiffText[] }) { return <> { - texts.map(t => { + texts.map((t, i) => { if (t.format == "rotation") { - return {t.text} + return {t.text} } else if (t.format) { - return {t.text} + return {t.text} } else { - return {t.text} + return {t.text} } }) } diff --git a/frontend/src/components/Nav/Search.module.scss b/frontend/src/components/Nav/Search.module.scss index de53dfba..36d96b6b 100644 --- a/frontend/src/components/Nav/Search.module.scss +++ b/frontend/src/components/Nav/Search.module.scss @@ -85,6 +85,18 @@ border-top-left-radius: 0; border-top-right-radius: 0; + + opacity: 0; + transform: scaleY(0.75); + visibility: hidden; + transition-duration: 0.125s; + transition-property: opacity, transform, visibility; +} + +.results.isOpen { + opacity: 0.9999; + transform: none; + visibility: visible; } .item { diff --git a/frontend/src/components/Nav/Search.tsx b/frontend/src/components/Nav/Search.tsx index 9353f1ae..f241050e 100644 --- a/frontend/src/components/Nav/Search.tsx +++ b/frontend/src/components/Nav/Search.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react" +import { useEffect, useRef, useState } from "react" import Image from "next/image" import { useRouter } from "next/router" @@ -6,7 +6,6 @@ import { useRouter } from "next/router" import { SearchIcon } from "@primer/octicons-react" import classNames from "classnames" import { useCombobox } from "downshift" -import { motion, AnimatePresence } from "framer-motion" import { usePlausible } from "next-plausible" import { useLayer } from "react-laag" import useSWR from "swr" @@ -27,7 +26,7 @@ function useRecentScratches(): api.TerseScratch[] { return data?.results || [] } -export default function Search({ className }: { className?: string }) { +function MountedSearch({ className }: { className?: string }) { const [query, setQuery] = useState("") const [isFocused, setIsFocused] = useState(false) const [isLoading, setIsLoading] = useState(false) @@ -102,21 +101,11 @@ export default function Search({ className }: { className?: string }) { }, }) - const [isMounted, setIsMounted] = useState(false) - useEffect(() => setIsMounted(true), []) - const router = useRouter() - if (!isMounted) { - return
- - -
+ const lastWidthRef = useRef(0) + if (triggerBounds) { + lastWidthRef.current = triggerBounds.width } return
setIsFocused(true)} /> {isLoading && isFocused && } - {isMounted && renderLayer( - - {isOpen && - {items.map((scratch, index) => { - const props = getItemProps({ item: scratch, index }) - const oldOnClick = props.onClick - props.onClick = evt => { - evt.preventDefault() // Don't visit the link - return oldOnClick(evt) - } + {renderLayer( + )}
} + +export default function Search({ className }: { className?: string }) { + const [isMounted, setIsMounted] = useState(false) + useEffect(() => setIsMounted(true), []) + + if (!isMounted) { + return
+ + +
+ } + + return +} diff --git a/frontend/src/components/Select.tsx b/frontend/src/components/Select.tsx index 33cbc524..d0b4ea26 100644 --- a/frontend/src/components/Select.tsx +++ b/frontend/src/components/Select.tsx @@ -8,11 +8,12 @@ export type Props = { className?: string onChange: ChangeEventHandler children: ReactNode + value?: string } -export default function Select({ onChange, children, className }: Props) { +export default function Select({ onChange, children, className, value }: Props) { return
- {children} diff --git a/frontend/src/components/compiler/CompilerOpts.tsx b/frontend/src/components/compiler/CompilerOpts.tsx index ecc11118..6beb12e7 100644 --- a/frontend/src/components/compiler/CompilerOpts.tsx +++ b/frontend/src/components/compiler/CompilerOpts.tsx @@ -8,9 +8,10 @@ import Select from "../Select" import styles from "./CompilerOpts.module.css" import { useCompilersForPlatform } from "./compilers" -import Flags, { NO_TRANSLATION } from "./Flags" import PresetSelect from "./PresetSelect" +const NO_TRANSLATION = "NO_TRANSLATION" + interface IOptsContext { checkFlag(flag: string): boolean setFlag(flag: string, value: boolean): void @@ -18,7 +19,7 @@ interface IOptsContext { const OptsContext = createContext(undefined) -export function Checkbox({ flag, description }) { +function Checkbox({ flag, description }) { const { checkFlag, setFlag } = useContext(OptsContext) const isChecked = checkFlag(flag) @@ -30,7 +31,7 @@ export function Checkbox({ flag, description }) {
} -export function FlagSet({ name, children }) { +function FlagSet({ name, children, value }) { const { setFlag } = useContext(OptsContext) return
@@ -43,23 +44,43 @@ export function FlagSet({ name, children }) { setFlag((event.target as HTMLSelectElement).value, true) }} + value={value} > {children}
} -export function FlagOption({ flag, description }: { flag: string, description?: string }) { - const { checkFlag } = useContext(OptsContext) - - return } +interface FlagsProps { + schema: api.Flag[] +} + +function Flags({ schema }: FlagsProps) { + const compilersTranslation = useTranslation("compilers") + const { checkFlag } = useContext(OptsContext) + + return <> + {schema.map(flag => { + if (flag.type === "checkbox") { + return + } else if (flag.type === "flagset") { + const selectedFlag = flag.flags.filter(checkFlag)[0] || flag.flags[0] + return + {flag.flags.map(f => )} + + } + })} + +} + export type CompilerOptsT = { compiler: string compiler_flags: string @@ -188,11 +209,11 @@ export function OptsEditor({ platform, compiler: compilerId, setCompiler, opts,