74 lines
2.6 KiB
TypeScript
74 lines
2.6 KiB
TypeScript
import type { ReactNode, Ref } from 'react';
|
|
import { ScrollView, TextInput, View, type TextInputProps } from 'react-native';
|
|
import { Text } from '@/components/text';
|
|
import Svg, { Path } from 'react-native-svg';
|
|
|
|
import { Skel } from '@/components/ui';
|
|
import { useSky } from '@/lib/sky';
|
|
|
|
/** 웹의 연한 판(#f3f6fb)·입력칸·따뜻한 판(#fff4ec)을 밤엔 어두운 판으로 */
|
|
export function useSoft() {
|
|
const night = useSky().kind === 'night';
|
|
return {
|
|
soft: night ? '#2b3470' : '#f3f6fb',
|
|
field: night ? '#2b3470' : '#f7f9fc',
|
|
fieldBorder: night ? 'rgba(255,255,255,0.12)' : '#dfe5ee',
|
|
warm: night ? 'rgba(255,138,87,0.16)' : '#fff4ec',
|
|
bar: night ? 'rgba(255,255,255,0.12)' : '#e3eaf4',
|
|
placeholder: night ? '#a1a9db' : '#8a92aa',
|
|
};
|
|
}
|
|
|
|
export function Body({ children, className }: { children: ReactNode; className?: string }) {
|
|
return (
|
|
<ScrollView className="shrink" contentContainerClassName={`px-4 pt-3.5 pb-[18px] ${className ?? ''}`} keyboardShouldPersistTaps="handled">
|
|
{children}
|
|
</ScrollView>
|
|
);
|
|
}
|
|
|
|
/** 입력칸: 둥근 연한 판 */
|
|
export function Field({ round = false, style, ...props }: TextInputProps & { round?: boolean; ref?: Ref<TextInput> }) {
|
|
const s = useSoft();
|
|
return (
|
|
<TextInput
|
|
placeholderTextColor={s.placeholder}
|
|
className={`px-3.5 text-[16px] text-ink ${round ? 'rounded-full py-2.5' : 'rounded-[14px] py-3'}`}
|
|
style={[{ backgroundColor: s.field, borderWidth: 1, borderColor: s.fieldBorder }, style]}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export function HeartIcon({ size, fill, stroke }: { size: number; fill: string; stroke: string }) {
|
|
return (
|
|
<Svg viewBox="0 0 24 24" width={size} height={size} fill={fill} stroke={stroke} strokeWidth={2}>
|
|
<Path d="M12 20.5s-8-4.9-8-11A4.6 4.6 0 0 1 12 6.8a4.6 4.6 0 0 1 8 2.7c0 6.1-8 11-8 11z" />
|
|
</Svg>
|
|
);
|
|
}
|
|
|
|
const N3 = [0, 1, 2];
|
|
|
|
/** 읽을거리·이번 주 특집: 그림 150px · 머리말 · 제목 · 본문 */
|
|
export function ArticleSkel() {
|
|
return (
|
|
<View className="gap-2.5">
|
|
<View className="h-[150px] rounded-[20px] bg-skel" />
|
|
<Skel className="w-24" />
|
|
<Skel className="h-6 w-4/5" />
|
|
{N3.map((k) => (
|
|
<View key={k} className="gap-1.5">
|
|
<Skel className="w-full" />
|
|
<Skel className="w-2/3" />
|
|
</View>
|
|
))}
|
|
</View>
|
|
);
|
|
}
|
|
|
|
/** 빨간 안내 한 줄 (자리 높이는 그대로) */
|
|
export function ErrorLine({ text, className }: { text?: string; className?: string }) {
|
|
return <Text className={`min-h-5 text-center text-[13px] font-bold text-heart ${className ?? ''}`}>{text ?? ''}</Text>;
|
|
}
|