-
Notifications
You must be signed in to change notification settings - Fork 3
Task DS-549: [React Native] Поддержка UniStyles: Базовая конфигурация #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
761b58a
775f46a
adf7e7a
fd177db
ba3279d
5ae413b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| ios/Pods | ||
| ios | ||
| .github/workflows | ||
| .yarn | ||
| android/app/.cxx | ||
| CHANGELOG.md | ||
| android/app/build | ||
| android/build | ||
| CHANGELOG.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Миграция на Unistyles V3 | ||
|
|
||
| Стили переведены на `react-native-unistyles`. Удален собственный `React Context` | ||
| и провайдер. | ||
|
|
||
| ## Изменения | ||
|
|
||
| ### `ThemeContextProvider` — удалён | ||
|
|
||
| Темы регистрируются автоматически. Обёртка больше не нужна. | ||
|
|
||
| ### `useFonts` — deprecated | ||
|
|
||
| Используйте `useUnistyles`: | ||
|
|
||
| ```tsx | ||
| import { useUnistyles } from '@cdek-it/react-native-ui-kit' | ||
|
|
||
| const { theme } = useUnistyles() | ||
| theme.fonts | ||
| ``` | ||
|
|
||
| Или прямо в стилях через `StyleSheet.create(...)`. | ||
|
|
||
| ### `makeStyles` — deprecated | ||
|
|
||
| Используйте `StyleSheet.create(...)`: | ||
|
|
||
| ```tsx | ||
| import { StyleSheet } from '@cdek-it/react-native-ui-kit' | ||
|
|
||
| const styles = StyleSheet.create((theme) => ({ | ||
| container: { backgroundColor: theme.Button.Brand.buttonBg }, | ||
| })) | ||
| ``` | ||
|
|
||
| `makeStyles` использует `useUnistyles()`, что вызывает React-ререндеры при смене | ||
| темы. `StyleSheet.create(...)` — нативный путь, обновляет стили **без** | ||
| ререндеров. | ||
|
|
||
| SDK реэкспортирует `StyleSheet`, `useUnistyles`, `UnistylesRuntime` и | ||
| `withUnistyles`, поэтому потребителям не нужно импортировать | ||
| `react-native-unistyles` напрямую. | ||
|
|
||
| ### `useTheme()` — deprecated | ||
|
|
||
| ```tsx | ||
| import { UnistylesRuntime, useUnistyles } from '@cdek-it/react-native-ui-kit' | ||
|
|
||
| const themeName = UnistylesRuntime.themeName // 'light' | 'dark' | ||
| ``` | ||
|
|
||
| Для реактивного поведения используйте `useUnistyles()`: | ||
|
|
||
| ```tsx | ||
| const { rt } = useUnistyles() | ||
| rt.themeName | ||
| ``` | ||
|
|
||
| ### `useChangeTheme()` — deprecated | ||
|
|
||
| ```tsx | ||
| import { UnistylesRuntime } from '@cdek-it/react-native-ui-kit' | ||
|
|
||
| UnistylesRuntime.setTheme('dark') | ||
| ``` | ||
|
|
||
| ## Babel конфигурация | ||
|
|
||
| Для получения нативного обновления стилей без React-ререндеров: | ||
|
|
||
| 1. Используйте `StyleSheet.create(...)`. | ||
| 2. Добавьте `autoProcessPaths` в Babel-конфиг вашего приложения. | ||
|
|
||
| Документация: | ||
|
|
||
| - [useUnistyles](https://www.unistyl.es/v3/references/use-unistyles/) | ||
| - [StyleSheet](https://www.unistyl.es/v3/references/stylesheet/) | ||
| - [Babel plugin](https://www.unistyl.es/v3/other/babel-plugin/) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,16 +33,17 @@ | |
| "storybook-generate": "sb-rn-get-stories --config-path .storybook && sed -i -e 's/export const view = global.view/export const view: ReturnType<typeof start> = global.view/' .storybook/storybook.requires.ts && prettier .storybook --write", | ||
| "doctor": "expo-doctor", | ||
| "check": "expo install --check", | ||
| "lint:check": "eslint .", | ||
| "lint:fix": "eslint --fix .", | ||
| "lint:check": "eslint --cache .", | ||
| "lint:fix": "eslint --fix --cache .", | ||
| "prettier:check": "prettier . --check", | ||
| "prettier:fix": "prettier . --write", | ||
| "prettier:watch": "onchange . -- prettier --write --ignore-unknown \"{{changed}}\"", | ||
| "release": "release-it", | ||
| "pod-install": "bundle exec pod install --project-directory=ios" | ||
| }, | ||
| "dependencies": { | ||
| "@tabler/icons-react-native": "^3.36.0" | ||
| "@tabler/icons-react-native": "3.36.1", | ||
| "react-native-unistyles": "3.2.3" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Я не уверен, что нужно unistyles добавлять в dependencies, скорее в
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Исправлено в #38 |
||
| }, | ||
| "devDependencies": { | ||
| "@babel/core": "7.28.5", | ||
|
|
@@ -106,6 +107,7 @@ | |
| "react-native": "0.81.5", | ||
| "react-native-advanced-input-mask": "1.4.6", | ||
| "react-native-gesture-handler": "2.29.1", | ||
| "react-native-nitro-modules": "0.35.2", | ||
| "react-native-reanimated": "4.1.1", | ||
| "react-native-safe-area-context": "5.6.2", | ||
| "react-native-svg": "15.15.1", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Здесь специально была не зафиксирована версия, чтобы меньше конфликтов было в случае, когда в проекте уже используется этот пакет. Считаю, что можно оставить
^3.36.1There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вернул