Skip to content

Commit

Permalink
fix: 不自然にコンポーネントが消えるため、制御条件でレンダリングするのをやめる
Browse files Browse the repository at this point in the history
  • Loading branch information
weweweok committed Apr 18, 2024
1 parent 1c1e8c1 commit b97d323
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions islands/ImageForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const createAsciiArt = async (image: File) => {
export default function ImageForm() {
const isActiveFileUpLoderDisable = useSignal(false);
const buttonDisable = useSignal(false);
const previewUploadImage = useSignal(false);
const isAnnounsing = useSignal(false);

const uploadImage = (event: Event) => {
Expand Down Expand Up @@ -47,7 +46,6 @@ export default function ImageForm() {
const image = imageElement.files[0];

buttonDisable.value = true;
previewUploadImage.value = true;
isAnnounsing.value = true;

const asciiArtBlob = await createAsciiArt(image);
Expand All @@ -58,12 +56,13 @@ export default function ImageForm() {
"ascii-art"
) as HTMLImageElement;
asciiArtPreview.src = blobUrl;
const preview = document.getElementById("preview") as HTMLImageElement;
preview.src = "";
};
fileData.readAsDataURL(asciiArtBlob);

isActiveFileUpLoderDisable.value = false;
buttonDisable.value = false;
previewUploadImage.value = false;
isAnnounsing.value = false;
};
return (
Expand All @@ -86,9 +85,7 @@ export default function ImageForm() {
ファイルをアップロードする
</button>
</form>
{!previewUploadImage.value ? (
<img id="preview" class="max-w-xs max-h-56 " />
) : undefined}
<img id="preview" class="max-w-xs max-h-56 " />
{isAnnounsing.value ? (
<div id="announce-generating">
<h1>アスキーアートを生成中...</h1>
Expand Down

0 comments on commit b97d323

Please sign in to comment.