Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/auto-merge-claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Auto-merge Claude branches

on:
push:
branches:
- 'claude/**'

permissions:
contents: write
pull-requests: write

jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Create and merge PR
env:
GH_TOKEN: ${{ github.token }}
run: |
BRANCH="${GITHUB_REF#refs/heads/}"
echo "Auto-merging $BRANCH into main"

# Create PR
PR_URL=$(gh pr create \
--base main \
--head "$BRANCH" \
--title "Auto-merge: $(git log -1 --pretty=%s)" \
--body "Automatically created from \`$BRANCH\`." \
2>/dev/null || true)

# If PR already exists, get its number
PR_NUM=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number')

if [ -n "$PR_NUM" ]; then
gh pr merge "$PR_NUM" --merge --auto --delete-branch
echo "Merged PR #$PR_NUM"
else
echo "No PR to merge"
fi
73 changes: 55 additions & 18 deletions components/app/StoryForge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default function StoryForge({
discussionQuestions: string[];
familyActivity: string;
virtueTag: string;
virtueDetail: string;
} | null>(null);
const [error, setError] = useState<string | null>(null);
const [copied, setCopied] = useState(false);
Expand Down Expand Up @@ -231,6 +232,7 @@ ACTIVITY: [A simple, fun family activity (5-10 minutes) that practices the virtu
setStory({
title, body, discussionQuestions, familyActivity,
virtueTag: resolved.map((r) => r.sv.name).join(" \u00B7 "),
virtueDetail: resolved.map((r) => `${r.sv.name} (${r.pv.name}) \u2014 ${r.sv.desc}`).join(" \u00B7 "),
});
incrementStoryCount();
trackEvent("story_generated");
Expand All @@ -256,37 +258,53 @@ ACTIVITY: [A simple, fun family activity (5-10 minutes) that practices the virtu
const buildStoryHTML = () => {
if (!story) return "";
const displayName = draftName.trim() || "a young reader";
return `<!DOCTYPE html><html><head><title>${story.title}</title>
return `<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${story.title}</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:wght@400;600;700&display=swap');
body { font-family: 'Crimson Text', Georgia, serif; max-width: 650px; margin: 40px auto; padding: 40px; color: #1F2937; line-height: 1.9; }
h1 { text-align: center; font-size: 28px; color: #0A1628; border-bottom: 3px solid #D4A846; padding-bottom: 16px; margin-bottom: 24px; }
.meta { text-align: center; font-size: 14px; color: #9CA3AF; margin-bottom: 32px; }
p { font-size: 17px; margin-bottom: 16px; }
.footer { margin-top: 40px; text-align: center; font-size: 13px; color: #D1D5DB; border-top: 1px solid #E5E7EB; padding-top: 16px; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { width: 100%; }
body { font-family: 'Crimson Text', Georgia, serif; width: 100%; margin: 0; padding: 0.75in 1in; color: #1F2937; line-height: 1.8; font-size: 16px; }
h1 { text-align: center; font-size: 26px; color: #0A1628; border-bottom: 3px solid #D4A846; padding-bottom: 14px; margin-bottom: 8px; }
.virtue-label { text-align: center; margin-bottom: 6px; }
.virtue-label span { display: inline-block; padding: 4px 14px; border-radius: 100px; background: #D4A84618; color: #B8941F; font-size: 13px; font-weight: 600; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.virtue-desc { text-align: center; font-size: 13px; color: #9CA3AF; font-style: italic; margin-bottom: 6px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.meta { text-align: center; font-size: 13px; color: #9CA3AF; margin-bottom: 28px; }
.story-body p { font-size: 16px; margin-bottom: 14px; text-indent: 1.5em; }
.story-body p:first-child { text-indent: 0; }
.footer { margin-top: 36px; text-align: center; font-size: 12px; color: #D1D5DB; border-top: 1px solid #E5E7EB; padding-top: 14px; }
.tip-banner { display: none; }
@media print { .tip-banner { display: none !important; } }
@media screen { .tip-banner { display: block; position: fixed; top: 0; left: 0; right: 0; z-index: 999;
background: #0A1628; color: white; padding: 14px 20px; text-align: center;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.5; } }
@media print {
body { padding: 0; margin: 0; width: 100%; }
.tip-banner { display: none !important; }
@page { size: letter; margin: 0.75in 1in; }
}
@media screen {
body { max-width: 8.5in; margin: 0 auto; }
.tip-banner { display: block; position: fixed; top: 0; left: 0; right: 0; z-index: 999;
background: #0A1628; color: white; padding: 14px 20px; text-align: center;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.5; }
}
</style>
</head><body>
<div class="tip-banner">
\uD83D\uDCC4 <strong>To save as PDF:</strong> Tap the <strong>Share button</strong> (square with arrow) then choose <strong>"Print"</strong> or <strong>"Save to Files"</strong>. On desktop, choose <strong>"Save as PDF"</strong> in the print dialog.
</div>
<h1>${story.title}</h1>
${story.virtueTag ? `<div class="virtue-label"><span>${story.virtueTag}</span></div>` : ""}
${story.virtueDetail ? `<div class="virtue-desc">${story.virtueDetail}</div>` : ""}
<div class="meta">A story for ${displayName} \u00B7 Generated by Bedtime Virtues</div>
${story.body.split("\n\n").map((p: string) => `<p>${p}</p>`).join("")}
<div class="story-body">
${story.body.split("\n\n").map((p: string) => `<p>${p}</p>`).join("")}
</div>
${story.discussionQuestions.length > 0 ? `
<div style="margin-top: 40px; padding: 24px; border: 2px solid #D4A846; border-radius: 12px; background: #FFFBEB;">
<h2 style="font-size: 20px; color: #0A1628; margin-bottom: 16px; font-family: Inter, sans-serif;">Discussion Guide</h2>
${story.virtueTag ? `<div style="display: inline-block; padding: 4px 12px; border-radius: 100px; background: #D4A84620; color: #D4A846; font-size: 13px; font-weight: 600; margin-bottom: 16px; font-family: Inter, sans-serif;">${story.virtueTag}</div>` : ""}
<div style="margin-top: 36px; padding: 20px; border: 2px solid #D4A846; border-radius: 12px; background: #FFFBEB;">
<h2 style="font-size: 18px; color: #0A1628; margin-bottom: 14px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">Discussion Guide</h2>
<ol style="padding-left: 20px;">
${story.discussionQuestions.map((q: string) => `<li style="margin-bottom: 12px; font-size: 16px;">${q}</li>`).join("")}
${story.discussionQuestions.map((q: string) => `<li style="margin-bottom: 10px; font-size: 15px;">${q}</li>`).join("")}
</ol>
${story.familyActivity ? `<div style="margin-top: 16px; padding: 16px; background: #D4A84615; border-radius: 8px;">
<strong style="font-family: Inter, sans-serif; font-size: 14px; color: #0A1628;">Family Activity:</strong>
<p style="font-size: 15px; margin-top: 4px;">${story.familyActivity}</p>
${story.familyActivity ? `<div style="margin-top: 14px; padding: 14px; background: #D4A84615; border-radius: 8px;">
<strong style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; color: #0A1628;">Family Activity:</strong>
<p style="font-size: 14px; margin-top: 4px;">${story.familyActivity}</p>
</div>` : ""}
</div>
` : ""}
Expand Down Expand Up @@ -646,6 +664,25 @@ ACTIVITY: [A simple, fun family activity (5-10 minutes) that practices the virtu
}}>
{story.title}
</h2>
{story.virtueTag && (
<div style={{ textAlign: "center", marginBottom: 6 }}>
<span style={{
display: "inline-block", padding: "4px 14px", borderRadius: 100,
background: `${T.gold}18`, color: T.gold,
fontFamily: T.fontSans, fontSize: 13, fontWeight: 600,
}}>
{story.virtueTag}
</span>
</div>
)}
{story.virtueDetail && (
<div style={{
textAlign: "center", fontFamily: T.fontSans, fontSize: 13,
color: T.gray400, fontStyle: "italic", marginBottom: 6,
}}>
{story.virtueDetail}
</div>
)}
<div style={{
textAlign: "center", fontFamily: T.fontSans, fontSize: 13,
color: T.gray400, marginBottom: 32,
Expand Down
Loading