Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tailwindify #1394

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
1d9a08c
Backend updates
ethteck Dec 1, 2024
95435ff
frontend updates
ethteck Dec 1, 2024
fd69fe2
Undo 15
ethteck Dec 1, 2024
31403e0
Undo 15
ethteck Dec 1, 2024
bcd5fc0
oops
ethteck Dec 1, 2024
11e41ff
oops
ethteck Dec 1, 2024
baa17aa
oops
ethteck Dec 1, 2024
621c753
make thing not hook
ethteck Dec 1, 2024
ffefc25
regen yarn.lock
ethteck Dec 1, 2024
a2e3f40
oops
ethteck Dec 1, 2024
9e8abed
The resize observer
ethteck Dec 1, 2024
b246608
oops
ethteck Dec 1, 2024
2b9bf75
hamster help
ethteck Dec 7, 2024
625738b
more updates
ethteck Dec 7, 2024
0ab258c
more
ethteck Dec 7, 2024
0570292
fixules
ethteck Dec 7, 2024
515f25a
more migration
ethteck Dec 7, 2024
d1b147e
meowp
ethteck Dec 7, 2024
bf777dc
one
ethteck Dec 7, 2024
711cb03
un-frug
ethteck Dec 7, 2024
199845d
useImportType
ethteck Dec 7, 2024
5bef576
useTemplate
ethteck Dec 7, 2024
c31cef6
useNumberNamespace
ethteck Dec 7, 2024
7b8a98a
noUselessFragments
ethteck Dec 7, 2024
17dd28e
useLiteralKeys
ethteck Dec 7, 2024
4713bcf
useOptionalChain
ethteck Dec 7, 2024
4367854
noUnnecessaryContinue
ethteck Dec 7, 2024
cbb45ef
noUnreachable
ethteck Dec 7, 2024
6b2423a
noDoubleEquals
ethteck Dec 7, 2024
f1c24f8
useSortedClasses
ethteck Dec 7, 2024
7f48c8b
removed unneded file
ethteck Dec 8, 2024
4203075
delete later
ethteck Dec 8, 2024
5f47460
Promment
ethteck Dec 8, 2024
aeb0529
Merge branch 'updates' into lint
ethteck Dec 8, 2024
43cc316
useSingleVarDeclarator
ethteck Dec 8, 2024
2f6d9df
useSelfClosingElements
ethteck Dec 8, 2024
ff37469
noConfusingVoidType
ethteck Dec 8, 2024
bfbf38e
wut
ethteck Dec 8, 2024
926efae
noAccumulatingSpread
ethteck Dec 8, 2024
a06e8d8
noForEach
ethteck Dec 8, 2024
0d5c6f3
noAssignInExpressions
ethteck Dec 8, 2024
963a5b9
cleanups
ethteck Dec 8, 2024
aa7660c
useDefaultParameterLast
ethteck Dec 8, 2024
97ebb18
useEnumInitializers
ethteck Dec 8, 2024
9f4e474
useNodejsImportProtocol
ethteck Dec 8, 2024
e02505b
Run formatter
ethteck Dec 8, 2024
3506080
Select
ethteck Dec 7, 2024
dd5311d
NewScratchForm
ethteck Dec 8, 2024
4585670
ExampleCodeMirror
ethteck Dec 8, 2024
1b6b868
Merge branch 'main' into lint
ethteck Dec 8, 2024
8adcfb4
Merge branch 'lint' into formatter
ethteck Dec 8, 2024
3d55b72
Merge branch 'formatter' into tailwind
ethteck Dec 8, 2024
bbced5c
Merge branch 'main' into tailwind
ethteck Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 57 additions & 32 deletions frontend/src/app/(navfooter)/new/NewScratchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,28 @@ import basicSetup from "@/lib/codemirror/basic-setup";
import { cpp } from "@/lib/codemirror/cpp";
import getTranslation from "@/lib/i18n/translate";

import styles from "./new.module.scss";
interface FormLabelProps {
children: React.ReactNode;
htmlFor?: string;
small?: string;
}

function FormLabel({ children, htmlFor, small }: FormLabelProps) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this htmlEl (i.e. element) rather than htmlFor because that has a very specific other meaning: https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/htmlFor

Suggested change
function FormLabel({ children, htmlFor, small }: FormLabelProps) {
function FormLabel({ children, htmlEl, small }: FormLabelProps) {

const Tag = htmlFor ? "label" : "p";
return (
<Tag
className="m-0 block p-2.5 font-semibold text-[0.9em] text-[color:var(--g1700)]"
{...(htmlFor && { htmlFor })}
Copy link
Member

@bates64 bates64 Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer ?? probably. doesnt matter because typescript but its more precise

>
{children}
{small && (
<small className="pl-2 font-normal text-[0.8em] text-[color:var(--g800)]">
{small}
</small>
)}
</Tag>
);
}

function getLabels(asm: string): string[] {
const lines = asm.split("\n");
Expand Down Expand Up @@ -260,7 +281,7 @@ export default function NewScratchForm({
return (
<div>
<div>
<p className={styles.label}>Platform</p>
<FormLabel>Platform</FormLabel>
<PlatformSelect
platforms={serverCompilers.platforms}
value={platform}
Expand All @@ -272,26 +293,28 @@ export default function NewScratchForm({
</div>

<div>
<p className={styles.label}>Compiler</p>
<div className={styles.compilerContainer}>
<div>
<span className={styles.compilerChoiceHeading}>
<FormLabel>Compiler</FormLabel>
<div className="flex cursor-default select-none items-center justify-between max-[400px]:flex-col">
<div className="flex w-full flex-1 flex-col">
<span className="px-2.5 py-0.5 text-[0.8rem] text-[color:var(--g800)]">
Select a compiler
</span>
<Select
className={styles.compilerChoiceSelect}
className="w-full"
options={compilerChoiceOptions}
value={compilerId}
onChange={setCompiler}
/>
</div>
<div className={styles.compilerChoiceOr}>or</div>
<div>
<span className={styles.compilerChoiceHeading}>
<div className="flex-0 px-2 py-2 text-center text-[0.8rem] text-[color:var(--g500)] min-[400px]:px-4">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprised we don't have a tailwind config value for this: text-[color:var(--g500)] , like text-grey-500 or something. If not we should raise an issue about doing that

or
</div>
<div className="flex w-full flex-1 flex-col">
<span className="px-2.5 py-0.5 text-[0.8rem] text-[color:var(--g800)]">
Select a preset
</span>
<PresetSelect
className={styles.compilerChoiceSelect}
className="w-full"
platform={platform}
presetId={presetId}
setPreset={setPreset}
Expand All @@ -305,10 +328,12 @@ export default function NewScratchForm({
</div>

<div>
<label className={styles.label} htmlFor="label">
Diff label{" "}
<small>(asm label from which the diff will begin)</small>
</label>
<FormLabel
htmlFor="label"
small="(asm label from which the diff will begin)"
>
Diff label
</FormLabel>
<input
name="label"
type="text"
Expand All @@ -317,34 +342,28 @@ export default function NewScratchForm({
onChange={(e) =>
setLabel((e.target as HTMLInputElement).value)
}
className={styles.textInput}
className="w-full rounded border border-[color:var(--g500)] bg-[color:var(--g200)] px-2.5 py-2 font-mono text-[0.8rem] text-[color:var(--g1200)] placeholder-[color:var(--g700)] outline-none"
autoCorrect="off"
autoCapitalize="off"
spellCheck={false}
/>
</div>
<div className={styles.editorContainer}>
<p className={styles.label}>
Target assembly <small>(required)</small>
</p>
<div className="flex h-[200px] flex-col">
<FormLabel small="(required)">Target assembly</FormLabel>
<CodeMirror
className={styles.editor}
className="w-full flex-1 overflow-hidden rounded border border-[color:var(--g500)] bg-[color:var(--g200)] [&_.cm-editor]:h-full"
value={asm}
valueVersion={valueVersion}
onChange={setAsm}
extensions={basicSetup}
/>
</div>
<div className={styles.editorContainer}>
<p className={styles.label}>
Context{" "}
<small>
(any typedefs, structs, and declarations you would like
to include go here; typically generated with m2ctx.py)
</small>
</p>
<div className="flex h-[200px] flex-col">
<FormLabel small="(any typedefs, structs, and declarations you would like to include go here; typically generated with m2ctx.py)">
Context
</FormLabel>
<CodeMirror
className={styles.editor}
className="w-full flex-1 overflow-hidden rounded border border-[color:var(--g500)] bg-[color:var(--g200)] [&_.cm-editor]:h-full"
value={context}
valueVersion={valueVersion}
onChange={setContext}
Expand All @@ -362,12 +381,18 @@ export default function NewScratchForm({
>
Create scratch
</AsyncButton>
<p className={styles.privacyNotice}>
<p className="pt-4 text-[0.9rem] text-[color:var(--g1200)]">
decomp.me will store any data you submit and link it to your
session.
<br />
For more information, see our{" "}
<Link href="/privacy">privacy policy</Link>.
<Link
href="/privacy"
className="text-[color:var(--link)] hover:underline"
>
privacy policy
</Link>
.
</p>
</div>
</div>
Expand Down
115 changes: 0 additions & 115 deletions frontend/src/app/(navfooter)/new/new.module.scss

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import CodeMirror from "@/components/Editor/CodeMirror";
import basicSetup from "@/lib/codemirror/basic-setup";
import { cpp } from "@/lib/codemirror/cpp";

import styles from "./ExampleCodeMirror.module.scss";

const EXAMPLE_C_CODE = `#include "common.h"

typedef struct Vec2b {
Expand Down Expand Up @@ -114,7 +112,7 @@ void step_game_loop(void) {

export default function ExampleCodeMirror() {
return (
<div className={styles.container}>
<div className="overflow-hidden [&_.cm-editor]:h-[200px]">
<CodeMirror
value={EXAMPLE_C_CODE}
valueVersion={0}
Expand Down
39 changes: 0 additions & 39 deletions frontend/src/components/Select.module.scss

This file was deleted.

14 changes: 9 additions & 5 deletions frontend/src/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import type { ReactNode, ChangeEventHandler } from "react";

import { ChevronDownIcon } from "@primer/octicons-react";

import styles from "./Select.module.scss";

export type Props = {
className?: string;
onChange: ChangeEventHandler<HTMLSelectElement>;
Expand All @@ -18,12 +16,18 @@ export default function Select({
value,
}: Props) {
return (
<div className={`${styles.group} ${className}`}>
<select onChange={onChange} value={value}>
<div
className={`relative inline-flex select-none rounded border border-[var(--g400)] bg-[var(--g200)] px-[10px] py-2 text-[0.8rem] text-[var(--g1600)] ${className}`}
>
<select
onChange={onChange}
value={value}
className="!outline-0 flex-1 appearance-none border-0 bg-transparent pr-8 outline-none [&_option]:bg-[var(--g200)] [&_option]:text-[var(--g1600)]"
>
{children}
</select>

<div className={styles.icon}>
<div className="-translate-y-1/2 pointer-events-none absolute top-1/2 right-[0.6em]">
<ChevronDownIcon size={16} />
</div>
</div>
Expand Down
Loading
Loading