-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
78 additions
and
4,698 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { createSignal, onMount, Show } from 'solid-js' | ||
import type { NoteLoadType } from '../note/note-load-types' | ||
import { loadNoteFromType } from '../shared/storage' | ||
import { load } from '../note/utils/file-format' | ||
import type { MargedNoteData } from '../note/components/notes-utils' | ||
import { Spinner } from '../note/components/utils/Spinner' | ||
|
||
export const Navbar = () => { | ||
|
||
} | ||
|
||
export const InitialScreen = () => { | ||
return <div> | ||
aaa | ||
</div> | ||
} | ||
|
||
const LoadingNoteScreen = () => { | ||
return <div class="h-full grid place-items-center"> | ||
<div class="flex justify-center items-center"> | ||
<Spinner class="border-on-background"/> | ||
ノートを読み込み中... | ||
</div> | ||
</div> | ||
} | ||
export default (props: { | ||
noteLoadType: NoteLoadType | ||
}) => { | ||
const [getNote, setNote] = createSignal<MargedNoteData[]>() | ||
const [getNoteLoadState, setNoteLoadState] = createSignal<'pending' | 'loaded' | 'error'>('pending') | ||
|
||
onMount(async () => { | ||
setNoteLoadState('pending') | ||
const loadedNoteFile = await loadNoteFromType(props.noteLoadType) | ||
if (!loadedNoteFile) { | ||
setNoteLoadState('error') | ||
return | ||
} | ||
|
||
const loadedNote = await load(new Blob([loadedNoteFile.nnote])) | ||
if (!loadedNote.success) { | ||
setNoteLoadState('error') | ||
return | ||
} | ||
|
||
setNote(loadedNote.notes) | ||
setNoteLoadState('loaded') | ||
}) | ||
return <div class="h-full"> | ||
<Show when={getNoteLoadState() === 'pending'}> | ||
<LoadingNoteScreen /> | ||
</Show> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,4 @@ | ||
import { type NoSerialize, createContextId } from '@builder.io/qwik' | ||
import type { TextNoteData } from '../note/components/notes/TextNote/types' | ||
import type { NoteLoadType } from '../note/note-load-types' | ||
import type { QuizContent } from './constants' | ||
|
||
/** | ||
* クイズ | ||
*/ | ||
export interface Quiz { | ||
content: QuizContent | ||
|
||
source: TextNoteData | ||
|
||
id: number | ||
} | ||
|
||
export interface ScreenState { | ||
note: | ||
| NoSerialize<{ | ||
name: string | ||
notes: TextNoteData[] | ||
}> | ||
| 'pending' | ||
| 'notfound' | ||
| 'invalid' | ||
|
||
started: boolean | ||
|
||
availableAI: boolean | null | ||
|
||
noteLoadType: NoteLoadType | ||
|
||
/** | ||
* 出題範囲 | ||
*/ | ||
rangeNotes: Set<string> | ||
|
||
lastMissedQuizIds: number[] | ||
} | ||
|
||
export type QuizFrom = 'generated' | 'missed' | 'lowRate' | ||
export type QuizState = { | ||
correctQuizzes: Quiz[] | ||
incorrectQuizzes: Quiz[] | ||
|
||
generatedQuizzes: number | ||
|
||
quizzes: { | ||
quiz: Quiz | ||
from: QuizFrom | ||
}[] | ||
|
||
current: { | ||
index: number | ||
quiz: Quiz | ||
choices: string[] | ||
from: QuizFrom | ||
} | null | ||
|
||
isFinished: boolean | ||
|
||
finishedQuizIndexes: Set<number> | ||
|
||
lastMissedQuizzes: number | ||
} | ||
|
||
export interface Settings { | ||
quizzesByRound: number | ||
lowRateQuizzesInRound: number | ||
} | ||
|
||
export const SCREEN_STATE_CTX = createContextId<ScreenState>('screenState') | ||
export const QUIZ_STATE_CTX = createContextId<QuizState>('quizState') | ||
export const SETTINGS_CTX = createContextId<Settings>('settings') | ||
note: Note | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
export const Spinner = () => { | ||
export const Spinner = (props: { | ||
class?: string | ||
}) => { | ||
return ( | ||
<div class="animate-spin h-[1.2rem] w-[1.2rem] border-2 border-surface rounded-full border-t-transparent inline-block" /> | ||
<div | ||
classList={{ [props.class ?? '']: true }} | ||
class="animate-spin h-[1.2rem] w-[1.2rem] border-2 rounded-full border-t-transparent inline-block" | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters