sonia-ui v1.0
시작하기›앱 (Expo)

시작하기

앱 (Expo)

React Native에서는 같은 값을 Restyle의 Box · Text로 쓴다. 이름이 웹 클래스와 1:1로 맞는다.

1. 설치

Terminal
npm i github:ckdtjs505/sonia-ui @shopify/restyle react-native-safe-area-context

2. ThemeProvider로 감싸기

App.tsx
import { ThemeProvider, getTheme } from "sonia-ui/native";

export default function App() {
  return (
    <ThemeProvider theme={getTheme("dark")}>
      <Home />
    </ThemeProvider>
  );
}

3. Box · Text 쓰기

Home.tsx
import { Box, Text } from "sonia-ui/native";

<Box backgroundColor="$surface" padding="lg" borderRadius="md">
  <Text variant="title">안녕</Text>
  <Text variant="caption">sonia-ui로 만든 카드</Text>
</Box>

웹 ↔ 앱 이름

ClassStyles
bg-primarybackgroundColor="$primary"
text-mutedcolor="$muted"
p-lgpadding="lg"
gap-mdgap="md"
rounded-mdborderRadius="md"
text-titlevariant="title"
data-theme="dark"getTheme("dark")

Jest

TS 소스를 그대로 배포하므로 transformIgnorePatterns 허용 목록에 sonia-ui를 넣는다.