Skip to content

feat: 単語暗記進捗の記録のためのブックマーク機能(★)と、単語カードを見た数を記録する機能(目のアイコン) - #27

Open
amy-mor wants to merge 2 commits into
mainfrom
word-memorization-check
Open

feat: 単語暗記進捗の記録のためのブックマーク機能(★)と、単語カードを見た数を記録する機能(目のアイコン)#27
amy-mor wants to merge 2 commits into
mainfrom
word-memorization-check

Conversation

@amy-mor

@amy-mor amy-mor commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

My単語帳→ブックマーク機能
のタスク(8/14にアサイン)を行いました。追加した機能は以下です。
・ブックマーク機能として、覚えられなかった単語に★をつける
・★の回数が蓄積される
・★の回数によって色が変わる(1回目:青緑、2回目:黄、3回目以降:赤)
・上記の★の色をユーザーが自由に編集できる
・★の表示回数を手動で変更あるいはリセット(個別・一括の両方)する
・★がついた単語のみを復習する
・単語カードが表示された回数がわかる(目のアイコンの右側に数字が表示される)

@amy-mor
amy-mor requested review from Tatsu723 and tknkaa August 16, 2026 08:49

@tknkaa tknkaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

楽観的 UI 使ってるところとかめっちゃいいと思う!
細かいところと Server Actions についてもう一回確認してほしい!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

何の変更か分かるようにマイグレーションに名前を指定してるのはめっちゃいいと思う!
ただ、今回はマイグレーションを2回に分ける意味がないので、特に理由がなければ1回にまとめた方が履歴がスッキリしていいと思う!

Comment thread lib/star-colors.ts
// level2はcoralとlevel1の間を橋渡しする暖色のアンバーにしている
export const DEFAULT_STAR_COLORS: StarColors = {
level1: "#3fb6b8",
level2: "#fbbf24 ",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

末尾スペースがあると input type="color" で黒に矯正されてしまうので消そう!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

useStarColors はコンポーネントではなくカスタムフックなので、ファイル名はキャメルケースにして、lib/hooks/useStarColors.ts に置きたい!

{displayedStar.starred ? "★" : "☆"}
</button>
</form>
<StarCountEditor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

key = {current.id} みたいに key を指定した方がいいかも!
スターの回数を修正するポップアップを開いたまま次のカードに移動すると、ポップアップの中の値が前のカードのまま残っちゃって、そのまま保存すると前のカードの回数が今開いてるカードに適用されてしまうと思う!

Comment thread components/EyeIcon.tsx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maskuseId をやめて、輪郭と瞳孔の穴を fill-rule="evenodd" で1つの <path> にまとめた方が、フックを使わなくなる分 "use client" も不要になってシンプルになると思う!

: { id: current.id, starred: current.starred, starCount: current.starCount };
async function handleToggleStar() {
setOptimisticStar(
current.starred

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CardRow.tsx と同じように displayedStar から次の状態を計算するべきかと!そうすればサーバーのレスポンスを待たずにトグルできると思う!


// 単語の★を付け外しする。付けるときだけ starCount を+1し、外してもstarCountは減らさない
export async function toggleStar(cardId: string, notebookId: string) {
const card = await prisma.card.findUniqueOrThrow({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

find して update するのは atomic にしたい!

});

revalidatePath(`/my-notebooks/${notebookId}`);
revalidatePath(`/my-notebooks/${notebookId}/study`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

setStarCount, resetStar, resetAllStars で /review を revalidate しない理由ってなんだっけ?

data: { viewCount: { increment: 1 } },
});

revalidatePath(`/my-notebooks/${notebookId}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ここは3パス全部 revalidate する意味あるかな?

@na-trium-144

Copy link
Copy Markdown

revalidateする/しない のまえに、このコードだとなにもキャッシュしていないのでは?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants