Add mock AI provider and AI integration tests; fix sign-in transition and card flip
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
74a98ac1f1
commit
75158c4449
8 changed files with 720 additions and 33 deletions
|
|
@ -304,8 +304,8 @@ function useLogout() {
|
|||
try {
|
||||
await api.post('/api/auth/logout');
|
||||
} finally {
|
||||
qc.clear();
|
||||
await qc.invalidateQueries({ queryKey: qk.auth });
|
||||
qc.setQueryData(qk.auth, { configured: true, authenticated: false });
|
||||
qc.removeQueries({ predicate: (q) => q.queryKey[0] !== 'auth' });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,21 @@ export function FlipCard({
|
|||
footer?: ReactNode;
|
||||
}) {
|
||||
const [showHint, setShowHint] = useState(false);
|
||||
useEffect(() => setShowHint(false), [cardKey]);
|
||||
// Only animate the front when it comes back from the answer, not when a new card arrives.
|
||||
const [turned, setTurned] = useState(false);
|
||||
useEffect(() => {
|
||||
setShowHint(false);
|
||||
setTurned(false);
|
||||
}, [cardKey]);
|
||||
useEffect(() => {
|
||||
if (flipped) setTurned(true);
|
||||
}, [flipped]);
|
||||
const face = 'flip-face flex min-h-[320px] flex-col rounded-[22px] border border-line bg-surface shadow-2 sm:min-h-[380px]';
|
||||
// Short answers read best large and centred; long ones as normal text.
|
||||
const size = (text: string) => (text.length < 60 ? 'text-[28px] sm:text-[34px] leading-tight text-center' : text.length < 220 ? 'text-[21px] sm:text-[24px] leading-snug text-center' : 'text-[17px] sm:text-[18px]');
|
||||
return (
|
||||
<div key={cardKey} className="flip w-full animate-in">
|
||||
<div className="flip-inner" data-flipped={flipped}>
|
||||
<div key={cardKey} className="w-full animate-in">
|
||||
<div className="flip-inner" data-flipped={flipped} data-turned={turned}>
|
||||
<div className={cx(face, 'flip-front')}>
|
||||
<button type="button" onClick={onFlip} aria-label="Show answer" className="flex flex-1 cursor-pointer flex-col rounded-[22px] text-left">
|
||||
<div className="flex items-center justify-between px-5 pt-4">
|
||||
|
|
|
|||
|
|
@ -46,8 +46,9 @@ export function LoginPage() {
|
|||
setError('');
|
||||
try {
|
||||
await api.post('/api/auth/login', { password });
|
||||
qc.clear();
|
||||
await qc.invalidateQueries({ queryKey: qk.auth });
|
||||
// Drop anything cached from a previous session, then let the gate through.
|
||||
qc.removeQueries({ predicate: (q) => q.queryKey[0] !== 'auth' });
|
||||
qc.setQueryData(qk.auth, { configured: true, authenticated: true });
|
||||
} catch (err) {
|
||||
setError(errorMessage(err));
|
||||
setPassword('');
|
||||
|
|
@ -88,7 +89,7 @@ export function SetupPage() {
|
|||
setError('');
|
||||
try {
|
||||
await api.post('/api/auth/setup', { code, password });
|
||||
await qc.invalidateQueries({ queryKey: qk.auth });
|
||||
qc.setQueryData(qk.auth, { configured: true, authenticated: true });
|
||||
} catch (err) {
|
||||
setError(errorMessage(err));
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -420,44 +420,47 @@
|
|||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* Flashcard flip */
|
||||
.flip {
|
||||
perspective: 1600px;
|
||||
}
|
||||
/* Flashcard flip. Both faces are stacked in one grid cell so the card keeps the height of
|
||||
the taller side; only the active face is visible, and it swings in when it appears.
|
||||
(Deliberately not a preserve-3d/backface construction: that breaks in several
|
||||
compositing situations, and this keeps the hidden side out of the accessibility tree.) */
|
||||
.flip-inner {
|
||||
display: grid;
|
||||
transform-style: preserve-3d;
|
||||
transition: transform 420ms cubic-bezier(0.3, 0.8, 0.3, 1);
|
||||
}
|
||||
.flip-inner[data-flipped='true'] {
|
||||
transform: rotateY(180deg);
|
||||
perspective: 1600px;
|
||||
}
|
||||
.flip-face {
|
||||
grid-area: 1 / 1;
|
||||
backface-visibility: hidden;
|
||||
-webkit-backface-visibility: hidden;
|
||||
transform-origin: center;
|
||||
will-change: transform;
|
||||
}
|
||||
.flip-back {
|
||||
transform: rotateY(180deg);
|
||||
}
|
||||
/* Hidden face must not be reachable by keyboard or screen reader. */
|
||||
.flip-inner[data-flipped='true'] .flip-front,
|
||||
.flip-inner[data-flipped='false'] .flip-back {
|
||||
visibility: hidden;
|
||||
transition: visibility 0s linear 210ms;
|
||||
}
|
||||
.flip-inner[data-flipped='false'] .flip-front,
|
||||
.flip-inner[data-flipped='true'] .flip-back {
|
||||
visibility: visible;
|
||||
transition: visibility 0s linear 210ms;
|
||||
animation: sd-flip 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
.flip-inner[data-flipped='false'][data-turned='true'] .flip-front {
|
||||
animation: sd-flip-back 340ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.flip-inner {
|
||||
transition: none;
|
||||
.flip-face {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes sd-flip {
|
||||
from {
|
||||
transform: rotateY(-88deg);
|
||||
}
|
||||
}
|
||||
@keyframes sd-flip-back {
|
||||
from {
|
||||
transform: rotateY(88deg);
|
||||
}
|
||||
}
|
||||
|
||||
@utility tab-cobalt {
|
||||
--tab: var(--c-cobalt);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue