fix(mobile): story paw ring clipped at the top

The middle toe beans reach y = -9 in the 0–100 viewBox. Web draws the SVG
with overflow: visible; react-native-svg clips at the viewBox, cutting the
paw off. Extend the viewBox upward and grow the box to match; the "add
story" tile uses the same box so it lines up with the rings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-09-26 12:41:43 +02:00
1 parent de237f19a1
commit 2ef439c752
2 files changed
+42 -10

No files matched your search

+27 -6
View File
@@ -13,9 +13,22 @@ type Props = {
};
const RING_PAD = 8;
// The two middle toe beans (cy 1, r 10) reach up to y = -9 in the 0–100
// viewBox. Web renders the SVG with `overflow: visible`; react-native-svg
// clips at the viewBox instead, which cut the paw off at the top (found.md
// "Story Ring ist abgeschnitten"). So the viewBox starts BEAN_OVERHANG units
// higher and the box grows by the same proportion.
const BEAN_OVERHANG = 10;
const UNSEEN_COLOR = "#f97316";
const SEEN_COLOR = "#9ca3af";
/** Outer box of a PawRing for a given avatar size — lets siblings (StoryTray's "add" tile) line up with it. */
export function getPawRingBox(size: number) {
const width = size + RING_PAD * 2;
const overhang = (width * BEAN_OVERHANG) / 100;
return { width, height: width + overhang, paddingTop: overhang };
}
/**
* Port of web's src/components/stories/PawRing.tsx — a paw-print outline
* (one big circle + four "toe bean" circles) drawn with react-native-svg
@@ -32,7 +45,7 @@ export function PawRing({ petId, children, size = 32, onPress }: Props) {
const { hasStory, allSeen } = data;
const ringColor = allSeen ? SEEN_COLOR : UNSEEN_COLOR;
const outerSize = size + RING_PAD * 2;
const box = getPawRingBox(size);
const strokeWidth = Math.max(4, size / 8);
const beans = [
{ cx: 13, cy: 10, r: 8 },
@@ -42,13 +55,21 @@ export function PawRing({ petId, children, size = 32, onPress }: Props) {
];
const content = (
<View style={{ width: outerSize, height: outerSize, alignItems: "center", justifyContent: "center" }}>
<View
style={{
width: box.width,
height: box.height,
paddingTop: box.paddingTop,
alignItems: "center",
justifyContent: "center",
}}
>
{hasStory && (
<Svg
width={outerSize}
height={outerSize}
viewBox="0 0 100 100"
style={{ position: "absolute" }}
width={box.width}
height={box.height}
viewBox={`0 ${-BEAN_OVERHANG} 100 ${100 + BEAN_OVERHANG}`}
style={{ position: "absolute", top: 0, left: 0 }}
>
<Circle cx={50} cy={50} r={44} fill="none" stroke={ringColor} strokeWidth={strokeWidth} />
{beans.map((b, i) => (
+15 -4
View File
@@ -7,11 +7,12 @@ import { PlusCircle } from "lucide-react-native";
import { useTRPC } from "../api/trpc";
import { useActivePet } from "../context/ActivePetContext";
import { useTheme } from "../context/ThemeContext";
import { PawRing } from "./PawRing";
import { PawRing, getPawRingBox } from "./PawRing";
import { PetAvatar } from "./PetAvatar";
import { fontFamily, type ColorTokens } from "../theme/tokens";
const AVATAR_SIZE = 56;
const RING_BOX = getPawRingBox(AVATAR_SIZE);
/**
* Port of web's src/components/stories/StoryTray.tsx: an "add story" tile
@@ -37,8 +38,10 @@ export function StoryTray() {
return (
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.row}>
<Pressable style={styles.item} onPress={() => router.push("/story-new")}>
<View style={styles.addButton}>
<PlusCircle color={colors.pureWhite} size={26} />
<View style={styles.addButtonBox}>
<View style={styles.addButton}>
<PlusCircle color={colors.pureWhite} size={26} />
</View>
</View>
<Text style={styles.label} numberOfLines={1}>
{t("feed.storyLabel")}
@@ -71,7 +74,15 @@ export function StoryTray() {
function makeStyles(colors: ColorTokens) {
return StyleSheet.create({
row: { gap: 16, paddingHorizontal: 16, paddingVertical: 12 },
item: { alignItems: "center", gap: 4, width: 72 },
item: { alignItems: "center", gap: 4, width: RING_BOX.width },
// Same box as a PawRing so the "add" tile lines up with the story rings.
addButtonBox: {
width: RING_BOX.width,
height: RING_BOX.height,
paddingTop: RING_BOX.paddingTop,
alignItems: "center",
justifyContent: "center",
},
addButton: {
width: AVATAR_SIZE,
height: AVATAR_SIZE,