Skip to content

Commit a4271a9

Browse files
committed
fix: mobile color input, file input, code editor jank + toast error for canShow false
1 parent ce0fe02 commit a4271a9

File tree

4 files changed

+55
-48
lines changed

4 files changed

+55
-48
lines changed

src/components/ColorInput.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ export default function ColorInput(props: Props) {
2222
<div class="w-full">
2323
<input
2424
class="text-white pl-9 font-mono w-full bg-back-subtle leading-none px-3 py-2 rounded-md border focus:(outline-none ring-2 ring-fore-base ring-offset-2 ring-offset-back-base)"
25-
type="text"
26-
// @ts-expect-error i'm right
25+
type="button"
2726
on:input={(e) => {
2827
props.setValue(e.target.value);
2928
}}
@@ -33,6 +32,7 @@ export default function ColorInput(props: Props) {
3332
el: ref,
3433
alpha: true,
3534
formatToggle: true,
35+
focusInput: false,
3636
theme: "large",
3737
themeMode: "auto",
3838
});

src/components/ImageInput.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function FileInput(props: Props) {
1313
return (
1414
<div class="inline-flex items-center gap-1">
1515
<input
16-
class="border rounded-md text-sm px-1 py-2 file:(bg-transparent border-none text-fore-base) bg-back-base hover:bg-fore-base/5 focus-visible:(outline-none ring-2 ring-fore-base ring-offset-2 ring-offset-back-base)"
16+
class="w-full border rounded-md text-sm px-1 py-2 file:(bg-transparent border-none text-fore-base) bg-back-base hover:bg-fore-base/5 focus-visible:(outline-none ring-2 ring-fore-base ring-offset-2 ring-offset-back-base)"
1717
ref={input!}
1818
type="file"
1919
accept={props.accept}

src/components/editor/CodeEditor.tsx

+48-44
Original file line numberDiff line numberDiff line change
@@ -144,50 +144,54 @@ export function CodeEditor(props: Props) {
144144
const [showDialog, setShowDialog] = createSignal(false);
145145

146146
return (
147-
<div>
148-
<AllowPasteDialog
149-
open={showDialog()}
150-
setClosed={() => {
151-
setShowDialog(false);
152-
}}
153-
onAllow={() => {
154-
allowPaste = true;
155-
localStorage.setItem(ALLOW_PASTE_KEY, "true");
156-
}}
157-
/>
158-
<div class="flex justify-between pb-2 h-11">
159-
<Switch label="Show code" value={showCode()} setValue={setShowCode} />
160-
<Show when={showCode()}>
161-
<label class="flex items-center gap-1 text-sm">
162-
Vim mode
163-
<input
164-
class="h-4 w-4"
165-
type="checkbox"
166-
checked={vimMode()}
167-
onChange={(e) => setVimMode(e.target.checked)}
168-
/>
169-
</label>
170-
<label class="flex items-center gap-1 text-sm">
171-
Update thumbnail
172-
<input
173-
class="h-4 w-4"
174-
type="checkbox"
175-
checked={updateThumbnail()}
176-
onChange={(e) => setUpdateThumbnail(e.target.checked)}
177-
/>
178-
</label>
179-
<Button
180-
disabled={!dirty()}
181-
onMouseDown={() =>
182-
props.onSave(view.state.doc.toString(), updateThumbnail())
183-
}
184-
class="bg-green-700 border rounded-md hover:bg-green-700/90 focus-visible:(outline-none ring-2 ring-fore-base ring-offset-2 ring-offset-back-base) disabled:(bg-transparent text-fore-base pointer-events-none opacity-50) transition-colors px-3 min-w-150px"
185-
>
186-
{dirty() ? "Save" : "No changes"}
187-
</Button>
188-
</Show>
147+
<>
148+
<div class="py-2">
149+
<Switch label="Code editor" value={showCode()} setValue={setShowCode} />
189150
</div>
190-
<div ref={parent!} classList={{ hidden: !showCode() }}></div>
191-
</div>
151+
<div>
152+
<AllowPasteDialog
153+
open={showDialog()}
154+
setClosed={() => {
155+
setShowDialog(false);
156+
}}
157+
onAllow={() => {
158+
allowPaste = true;
159+
localStorage.setItem(ALLOW_PASTE_KEY, "true");
160+
}}
161+
/>
162+
<div class="flex justify-end gap-4 pb-2 h-11">
163+
<Show when={showCode()}>
164+
<label class="flex items-center gap-1 text-sm">
165+
Vim mode
166+
<input
167+
class="h-4 w-4"
168+
type="checkbox"
169+
checked={vimMode()}
170+
onChange={(e) => setVimMode(e.target.checked)}
171+
/>
172+
</label>
173+
<label class="flex items-center gap-1 text-sm">
174+
Update thumbnail
175+
<input
176+
class="h-4 w-4"
177+
type="checkbox"
178+
checked={updateThumbnail()}
179+
onChange={(e) => setUpdateThumbnail(e.target.checked)}
180+
/>
181+
</label>
182+
<Button
183+
disabled={!dirty()}
184+
onMouseDown={() =>
185+
props.onSave(view.state.doc.toString(), updateThumbnail())
186+
}
187+
class="bg-green-700 border rounded-md hover:bg-green-700/90 focus-visible:(outline-none ring-2 ring-fore-base ring-offset-2 ring-offset-back-base) disabled:(bg-transparent text-fore-base pointer-events-none opacity-50) transition-colors px-3 min-w-150px"
188+
>
189+
{dirty() ? "Save" : "No changes"}
190+
</Button>
191+
</Show>
192+
</div>
193+
<div ref={parent!} classList={{ hidden: !showCode() }}></div>
194+
</div>
195+
</>
192196
);
193197
}

src/components/preview/QrPreview.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,15 @@ function DownloadButtons(props: DownloadProps) {
240240
}),
241241
],
242242
};
243+
if (!navigator.canShare(shareData)) {
244+
throw new Error();
245+
}
243246
navigator.share(shareData);
244247
} catch (e) {
245248
console.log(e);
246249
toastError(
247250
"Native sharing failed",
248-
"Unsupported in this browser"
251+
"File sharing not supported by browser"
249252
);
250253
}
251254
}}

0 commit comments

Comments
 (0)