Refine landing pet scale and login forgot-password link.
Size the homepage pet from LCD height instead of width alone, and soften the forgot-password link so it reads secondary to the password label.
This commit is contained in:
@@ -126,7 +126,12 @@
|
|||||||
/* Landing hero preview: cap LCD height on narrow viewports */
|
/* Landing hero preview: cap LCD height on narrow viewports */
|
||||||
.tamagotchi-lcd-landing {
|
.tamagotchi-lcd-landing {
|
||||||
@apply aspect-[4/3] w-full shrink-0;
|
@apply aspect-[4/3] w-full shrink-0;
|
||||||
max-height: clamp(140px, 42vw, 280px);
|
max-height: clamp(120px, 36vw, 240px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tamagotchi-lcd-landing > div.absolute svg {
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pet-viewport-stage {
|
.pet-viewport-stage {
|
||||||
|
|||||||
@@ -29,15 +29,33 @@ function LandingPetPreviewSkeleton() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeLandingPetScale(lcdWidth: number): number {
|
const SPRITE_HEIGHT = 32;
|
||||||
return Math.min(7, Math.max(4, Math.round(lcdWidth / 36)));
|
const SPRITE_WIDTH = 16;
|
||||||
|
/** Target rendered pet height as a fraction of LCD height */
|
||||||
|
const TARGET_HEIGHT_RATIO = 0.42;
|
||||||
|
/** Keep pet from spanning too much of the LCD width */
|
||||||
|
const TARGET_WIDTH_RATIO = 0.2;
|
||||||
|
|
||||||
|
function computeLandingPetScale(lcdWidth: number, lcdHeight: number): number {
|
||||||
|
if (lcdWidth <= 0 || lcdHeight <= 0) {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scaleFromHeight = Math.round(
|
||||||
|
(lcdHeight * TARGET_HEIGHT_RATIO) / SPRITE_HEIGHT,
|
||||||
|
);
|
||||||
|
const scaleFromWidth = Math.round(
|
||||||
|
(lcdWidth * TARGET_WIDTH_RATIO) / SPRITE_WIDTH,
|
||||||
|
);
|
||||||
|
|
||||||
|
return Math.min(5, Math.max(2, Math.min(scaleFromHeight, scaleFromWidth)));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LandingPetPreview() {
|
export function LandingPetPreview() {
|
||||||
const resizeObserverRef = useRef<ResizeObserver | null>(null);
|
const resizeObserverRef = useRef<ResizeObserver | null>(null);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isSignedIn, setIsSignedIn] = useState(false);
|
const [isSignedIn, setIsSignedIn] = useState(false);
|
||||||
const [petScale, setPetScale] = useState(7);
|
const [petScale, setPetScale] = useState(4);
|
||||||
const [customization, setCustomization] = useState<AvatarCustomization>(
|
const [customization, setCustomization] = useState<AvatarCustomization>(
|
||||||
defaultAvatarCustomization,
|
defaultAvatarCustomization,
|
||||||
);
|
);
|
||||||
@@ -50,16 +68,17 @@ export function LandingPetPreview() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateScale = (width: number) => {
|
const updateScale = (width: number, height: number) => {
|
||||||
setPetScale(computeLandingPetScale(width));
|
setPetScale(computeLandingPetScale(width, height));
|
||||||
};
|
};
|
||||||
|
|
||||||
updateScale(node.getBoundingClientRect().width);
|
const rect = node.getBoundingClientRect();
|
||||||
|
updateScale(rect.width, rect.height);
|
||||||
|
|
||||||
const observer = new ResizeObserver((entries) => {
|
const observer = new ResizeObserver((entries) => {
|
||||||
const entry = entries[0];
|
const entry = entries[0];
|
||||||
if (entry) {
|
if (entry) {
|
||||||
updateScale(entry.contentRect.width);
|
updateScale(entry.contentRect.width, entry.contentRect.height);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export function LoginForm({
|
|||||||
<Label htmlFor="password">Password</Label>
|
<Label htmlFor="password">Password</Label>
|
||||||
<Link
|
<Link
|
||||||
href="/auth/forgot-password"
|
href="/auth/forgot-password"
|
||||||
className="ml-auto inline-block text-sm underline-offset-4 hover:underline"
|
className="ml-auto shrink-0 text-xs text-muted-foreground/70 underline-offset-4 hover:text-muted-foreground hover:underline"
|
||||||
>
|
>
|
||||||
Forgot your password?
|
Forgot your password?
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
Reference in New Issue
Block a user