Skip to content

feat: 랜딩 페이지에 MathLive 기반 수학 점역 데모 추가 및 한글·수학 탭 통합 - #177

Open
jessieyeon wants to merge 14 commits into
dev-five-git:mainfrom
jessieyeon:demo-math-landing
Open

feat: 랜딩 페이지에 MathLive 기반 수학 점역 데모 추가 및 한글·수학 탭 통합#177
jessieyeon wants to merge 14 commits into
dev-five-git:mainfrom
jessieyeon:demo-math-landing

Conversation

@jessieyeon

Copy link
Copy Markdown

개요

랜딩 페이지에 수학 점역 체험 데모를 추가하고, 기존 한글 점역 데모와 함께 '한글' / '수학' 탭 토글 하나로 통합했습니다. 사용자는 MathLive 화면 수식 키보드로 수식을 WYSIWYG 편집하고, 자동 생성된 LaTeX가 실시간으로 한국 수학 점자로 변환되는 것을 체험할 수 있습니다.

주요 변경

수학 점역 데모

  • mathlive@^0.110.0 도입, MathLive 폰트를 public/mathlive/fonts/self-host (braillify의 "외부 연결 없이 실행" 원칙 유지 — CDN 미사용)
  • MathTransInput — MathLive <math-field> 웹 컴포넌트 래퍼. SSR 회피(동적 import), 데스크톱에서도 가상 수식 키보드 노출(manual 정책), 언마운트 시 키보드 자동 닫힘
  • MathLive가 생성한 LaTeX를 $...$로 감싸 기존 braillify WASM translateToUnicode에 전달 — 코어 엔진(libs/braillify) 무수정

한글·수학 탭 통합

  • DemoTabs — '한글'/'수학' 탭 토글(기본 '한글'). WAI-ARIA tablist/tab/tabpanel, 좌우 화살표 키 이동 지원
  • 수학 안내문을 입력창 placeholder로 이동(한글 데모와 동일한 방식), 출력창은 예시만 표시
  • 입력·출력 박스를 동일 flex-basis 2단 구조로 맞춰 전 브레이크포인트에서 크기 통일(모바일 343×203 / 태블릿 693×256 / 데스크톱 498×500, 모두 좌우 동일)
  • DemoChrome — 한글·수학 데모가 공유하는 헤딩/화살표 컴포넌트 추출

세부 보정

  • \frac 정규화: MathLive의 중괄호 생략 직렬화(\frac34)를 braillify가 인식하는 \frac{3}{4} 정규형으로 변환. 미종료 중괄호·제어기호 인자도 안전하게 처리
  • 입력 박스 전체 클릭 시 수식 필드 포커스(기존 한글 데모와 동일 동작)

검증

  • bun run build 통과, 기존 테스트 스위트 14,165개 전부 통과(회귀 없음)
  • 브라우저 확인: 한글 변환(학교⠚⠁⠈⠬), 수학 변환(x²+1⠭⠘⠼⠃⠢⠼⠁, ¾⠼⠙⠌⠼⠉), 탭 전환/화살표 키 이동, 가상 키보드 열림·닫힘, 다크 테마 가독성, 폰트 로컬 서빙(404 없음)
  • 반응형 3개 브레이크포인트에서 좌우 박스 크기 일치 실측

알려진 후속 작업 (이 PR 범위 밖)

  • braillify 엔진의 LaTeX 파서가 중괄호 없는 \frac34을 직접 분수로 인식하도록 일반화 — 현재는 랜딩측 normalizeFracBraces로 경계에서 처리. 엔진 수정은 별도 서브시스템(Rust + PDF 근거 테스트)이라 분리함.

jessieyeon and others added 11 commits July 22, 2026 15:31
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- MathTransInput: 박스 전체 클릭 시 math-field 포커스(TransInput과 동일 동작)
- readArg: 미종료 중괄호 내용 보존, 제어기호 인자 균형 유지
- DemoChrome: 한글·수학 데모 공통 헤딩/화살표 컴포넌트 추출
- DemoTabs: type=button, aria-controls, role=tabpanel, 좌우 화살표 키 이동
- MathTransInput: latex 상태를 부모에서 단일 관리(controlled), placeholder 흐름 배치로 매직 넘버 제거
- 입출력 박스를 동일 flex-basis 2단 구조로 맞춰 크기(498×500) 통일

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@owjs3901 owjs3901 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superpowers 를 gitignore에 추가요망

Comment thread apps/landing/src/app/DemoChrome.tsx Outdated
Comment thread apps/landing/src/app/MathTrans.tsx Outdated
Comment thread apps/landing/src/app/MathTransInput.tsx Outdated
Comment thread apps/landing/src/app/MathTransInput.tsx Outdated
Comment thread apps/landing/src/app/MathTransInput.tsx Outdated
Comment thread apps/landing/src/app/Trans.tsx Outdated
Comment thread docs/superpowers/plans/2026-07-22-demo-tabs-unify.md Outdated
jessieyeon and others added 3 commits July 28, 2026 13:15
- Trans/MathTrans/MathTransInput의 세로 컨테이너를 Flex→VStack으로 변경
- VStack 기본값과 중복되는 flexDirection="column" 및 불필요한 w="100%" 제거
- DemoArrow의 transform 기본값 rotate(0deg)→null (항등 변환이라 불필요)
- 미사용 Flex import 정리

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- MathTransInput: math-field의 인라인 style을 css()로 전환
- Trans/MathTrans: VStack 기본값과 중복되는 flexDirection 맨 앞 column을 null로
- docs/superpowers 플랜 문서 2개 제거
바깥 컨테이너가 row 방향 flex라 align-items stretch가 가로를 늘리지
않아 w=100%가 제거되면 입력·출력 박스 너비가 어긋난다. w=100% 대신
flex=1로 가로를 채워 박스 크기 동일을 유지하면서 명시적 w=100%를 제거한다.

@owjs3901 owjs3901 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

폰트에 라이센스 문제가 없는지 확인합시다, 만약 걱정되면 link 태그를 통해서 해결하면 좋을 것 같아요

maskPosition="center"
maskRepeat="no-repeat"
maskSize="contain"
w={['17px', null, null, '28px']}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

17px같은 홀수는 피해야 합니다

return (
<Flex aria-hidden="true">
<Image
alt=""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alt를 넣는게 이롭습니다

}

return (
<VStack flex="1" gap={['16px', null, null, '30px']} w="100%">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flex 1은 맨 처음 return에서 바로 쓰는 것 보다 이 컴포넌트를 호출하는 곳에서 flex=1을 안쓰더라도 넓게 펼쳐지도록 alignItems center 등의 옵션을 뺴는 것이 이롭습니다

as="button"
bg={mode === key ? '$text' : 'transparent'}
border="1px solid $text"
borderRadius="9999px"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50%가 같은 의미일겁니다.

Comment on lines +40 to +51
<MathTransInput
latex={latex}
onLatexChange={setLatex}
placeholder="수식을 입력하면 이곳에 수학 점자가 표시됩니다."
/>
<DemoArrow />
<TransInput
blurPlaceholder={'예: 사분의 삼 → ⠼⠙⠌⠼⠉'}
focusPlaceholder={'예: 사분의 삼 → ⠼⠙⠌⠼⠉'}
readOnly
value={braille}
/>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것만 따로 클라이언트 컴포넌트로 뺴는게 맞습니다

const braille = latex.trim() ? translateToUnicode(`$${latex}$`) : ''

return (
<VStack flex="1" gap={['16px', null, null, '30px']}>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flex 1 위 피드백과 같이 개선되어야 합니다

Comment on lines +23 to +64
export function normalizeFracBraces(latex: string): string {
let out = ''
let i = 0
while (i < latex.length) {
if (latex.startsWith('\\frac', i) && !/[a-zA-Z]/.test(latex[i + 5] ?? '')) {
const [num, j] = readArg(latex, i + 5)
const [den, k] = readArg(latex, j)
out += `\\frac${num}${den}`
i = k
continue
}
out += latex[i]
i += 1
}
return out
}

/** i 위치부터 LaTeX 인자 하나를 읽어 중괄호로 감싼 형태와 다음 인덱스를 돌려준다. */
function readArg(latex: string, i: number): [string, number] {
while (latex[i] === ' ') i += 1
if (latex[i] === '{') {
let depth = 0
let j = i
do {
if (latex[j] === '{') depth += 1
else if (latex[j] === '}') depth -= 1
j += 1
} while (j < latex.length && depth > 0)
// depth === 0 이면 짝이 맞는 '}' 를 j-1 에서 소비한 것이고,
// depth > 0 이면 닫는 중괄호 없이 끝난 것이라 내용을 j 까지 살린다.
const end = depth === 0 ? j - 1 : j
return [`{${normalizeFracBraces(latex.slice(i + 1, end))}}`, j]
}
if (latex[i] === '\\') {
let j = i + 1
while (j < latex.length && /[a-zA-Z]/.test(latex[j] ?? '')) j += 1
// 제어기호(\, \! 등)는 백슬래시 뒤에 글자가 없으므로 기호 한 글자를 포함시킨다.
if (j === i + 1 && j < latex.length) j += 1
return [`{${latex.slice(i, j)}}`, j]
}
return [`{${latex[i] ?? ''}}`, i + 1]
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

순수 함수는 ts파일로 빼는게 낫습니다

// 바깥 Flex 는 padding 없는 flex 아이템으로, 출력측 TransInput 의 외곽
// Flex(flex=1 h=100% w=100%)와 flex-basis 를 동일하게 맞춰 좌우 박스 너비를
// 같게 한다. 실제 배경/여백은 안쪽 박스가 담당한다.
<Flex flex="1" h="100%" w="100%">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위 피드백과 같은 이슈

bg="$containerBackground"
borderRadius={['16px', null, null, '30px']}
cursor="text"
flex="1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 flex 1이 필요 없지 않나요

onClick={() => fieldRef.current?.focus()}
p={['16px', null, null, '40px']}
>
<Flex flex="1" flexDirection="column" gap="8px">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VStack 사용

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants