feat: 내 각 아이콘·상세, 이야기 내 글·무한 스크롤, 공유 이미지 얇은 띠, 행사 주소 수집

- 내 각: 아이콘 고르기(my_gak.icon), 카드는 아이콘·점수·아쉬운 조건만, 눌러서 상세(시간대·조건별 점수), 공유는 공통 공유 창
- 이야기: 오늘 쓴 내 글 묶음, '내 글' 칩·탭, 무한 스크롤, 사진 카메라 버튼, 지우기 확인, ⋯ 메뉴 하트 옆, 글 시간 서버 계산(1일 전)
- 공유 이미지: 1:1·4:5 는 아래 얇은 띠 한 줄로 카드를 크게
- 행사: 수집 때 주소 저장(event.address), 행사 포스트에 장소·주소·기간
- 히어로 말풍선 '오늘 낮은 / 내일 낮은', 내일을 볼 때 배경도 따라감, 달 보름 순간이 낮이면 뜨는 시각으로
- 단풍 지도 피드 맨 위, 행사·계절 띠 포스트 틀 되돌림, 쇼츠 홈 버튼 가림·닫기 버튼, 하단 여백, 회색 글자 대비
- 토스 앱에선 쇼츠 플레이어를 하나만 띄움
This commit is contained in:
minaChoi committed 2026-10-27 18:55:42 +09:00
1 parent 3a249c509d
commit ffe6153148
35 files changed
+566 -185

No files matched your search

+44 -15
View File
@@ -2,7 +2,9 @@ import { domToCanvas } from 'modern-screenshot'
import { API_BASE_URL } from '../api/setup'
const W = 1080
const SIDE = 60
const SIDE = 24
// 1:1·4:5 아래 띠 높이: 날씨각 · 동네·날짜 · 주소 한 줄
const FOOT = 84
// 시간대별 배경 (화면 하늘 배경과 같은 색)
const SKY: Record<string, [string, string, string]> = {
@@ -12,11 +14,14 @@ const SKY: Record<string, [string, string, string]> = {
night: ['#0e1433', '#1b2356', '#2a2e6e'],
}
/** 공유 이미지 크기. 위: 로고·지역 날짜, 가운데: 카드, 아래: 주소 */
/**
* 공유 이미지 크기. 9:16 은 위 로고·지역 날짜, 가운데 카드, 아래 주소 알약.
* 1:1·4:5(strip)는 카드를 크게 두고 아래 얇은 띠 한 줄(날씨각 · 지역 날짜 · 주소)만
*/
export const SHARE_SIZES = {
story: { ratio: '9:16', w: 9, hr: 16, h: 1920, logoY: 250, logoPx: 96, subY: 325, subPx: 40, pillY: 1760, pillH: 100, labelPx: 34, hostPx: 46 },
feed: { ratio: '4:5', w: 4, hr: 5, h: 1350, logoY: 140, logoPx: 76, subY: 200, subPx: 34, pillY: 1250, pillH: 84, labelPx: 30, hostPx: 40 },
square: { ratio: '1:1', w: 1, hr: 1, h: 1080, logoY: 115, logoPx: 64, subY: 168, subPx: 30, pillY: 990, pillH: 80, labelPx: 28, hostPx: 38 },
story: { ratio: '9:16', w: 9, hr: 16, h: 1920, strip: false, logoY: 250, logoPx: 96, subY: 325, subPx: 40, pillY: 1760, pillH: 100, labelPx: 34, hostPx: 46 },
feed: { ratio: '4:5', w: 4, hr: 5, h: 1350, strip: true, logoY: 0, logoPx: 40, subY: 0, subPx: 26, pillY: 0, pillH: 0, labelPx: 0, hostPx: 32 },
square: { ratio: '1:1', w: 1, hr: 1, h: 1080, strip: true, logoY: 0, logoPx: 40, subY: 0, subPx: 26, pillY: 0, pillH: 0, labelPx: 0, hostPx: 32 },
} as const
export type ShareSize = keyof typeof SHARE_SIZES
@@ -113,7 +118,7 @@ type Box = { x: number; y: number; w: number; h: number }
function place(n: number, aspect: number, top: number, bottom: number): Box[] {
const room = bottom - top
if (n === 1) {
const w = Math.min(W - SIDE * 3, room / aspect)
const w = Math.min(W - SIDE * 2, room / aspect)
const h = w * aspect
return [{ x: (W - w) / 2, y: top + (room - h) / 2, w, h }]
}
@@ -152,11 +157,11 @@ export async function shareImage(slides: HTMLElement[], opts: { size: ShareSize;
document.fonts.load(LOGO(z.hostPx), opts.host),
document.fonts.load(LOGO(36), '12'),
document.fonts.load(SANS(z.subPx), opts.sub),
document.fonts.load(SANS(z.labelPx), PILL_LABEL),
...(z.strip ? [] : [document.fonts.load(SANS(z.labelPx), PILL_LABEL)]),
])
const css = await fontCss(cards.map((c) => c.textContent ?? '').join(''))
const aspect = cards[0].offsetHeight / cards[0].offsetWidth
const boxes = place(cards.length, aspect, z.subY + 60, z.pillY - z.pillH / 2 - 50)
const boxes = z.strip ? place(cards.length, aspect, SIDE, z.h - FOOT) : place(cards.length, aspect, z.subY + 60, z.pillY - z.pillH / 2 - 50)
const shots = await Promise.all(cards.map((c, i) => domToCanvas(c, { scale: boxes[i].w / c.offsetWidth, filter: keep, font: css ? { cssText: css } : false, fetchFn: viaProxy })))
const canvas = document.createElement('canvas')
@@ -173,13 +178,15 @@ export async function shareImage(slides: HTMLElement[], opts: { size: ShareSize;
ctx.fillStyle = bg
ctx.fillRect(0, 0, W, z.h)
ctx.textAlign = 'center'
ctx.fillStyle = '#ff7a45'
ctx.font = LOGO(z.logoPx)
ctx.fillText('날씨각', W / 2, z.logoY)
ctx.fillStyle = dark ? '#bcc3ea' : '#5a6380'
ctx.font = SANS(z.subPx)
ctx.fillText(opts.sub, W / 2, z.subY, W - SIDE * 2)
if (!z.strip) {
ctx.textAlign = 'center'
ctx.fillStyle = '#ff7a45'
ctx.font = LOGO(z.logoPx)
ctx.fillText('날씨각', W / 2, z.logoY)
ctx.fillStyle = dark ? '#bcc3ea' : '#5a6380'
ctx.font = SANS(z.subPx)
ctx.fillText(opts.sub, W / 2, z.subY, W - SIDE * 2)
}
const r = 40 * (boxes[0].w / 900)
shots.forEach((shot, i) => {
@@ -200,6 +207,28 @@ export async function shareImage(slides: HTMLElement[], opts: { size: ShareSize;
})
if (shots.length > 1) boxes.forEach((b, i) => badge(ctx, b.x + 6, b.y + 6, i + 1))
if (z.strip) {
// 아래 띠: 왼쪽 [날씨각 지역 · 날짜], 오른쪽 주소. 카드 양 끝에 맞춘다
const left = Math.min(...boxes.map((b) => b.x))
const right = Math.max(...boxes.map((b) => b.x + b.w))
const y = z.h - FOOT / 2 + 2
ctx.textBaseline = 'middle'
ctx.textAlign = 'left'
ctx.fillStyle = '#ff7a45'
ctx.font = LOGO(z.logoPx)
ctx.fillText('날씨각', left, y)
const logoW = ctx.measureText('날씨각').width
ctx.font = LOGO(z.hostPx)
const hostW = ctx.measureText(opts.host).width
ctx.textAlign = 'right'
ctx.fillText(opts.host, right, y)
ctx.textAlign = 'left'
ctx.fillStyle = dark ? '#bcc3ea' : '#5a6380'
ctx.font = SANS(z.subPx)
ctx.fillText(opts.sub, left + logoW + 16, y, Math.max(0, right - hostW - 24 - (left + logoW + 16)))
return new Promise((resolve, reject) => canvas.toBlob((b) => (b ? resolve(b) : reject(new Error('toBlob failed'))), 'image/png'))
}
// 주소 알약: [오늘 내 동네 각 보기 host]
ctx.font = SANS(z.labelPx)
const lw = ctx.measureText(PILL_LABEL).width