@codeandmoney/soelma 0.0.0-dev.1 → 0.0.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/.eslintrc.js +27 -0
- package/.github/workflows/nodejs.yml +33 -0
- package/.size-limit.json +6 -0
- package/babel.config.js +3 -0
- package/biome.jsonc +73 -0
- package/docs/api.md +103 -0
- package/docs/appearance.md +54 -0
- package/docs/dark-mode.md +46 -0
- package/docs/dimensions.md +29 -0
- package/docs/i18n.md +67 -0
- package/docs/logo.png +0 -0
- package/docs/media-query.md +274 -0
- package/docs/orientation.md +44 -0
- package/docs/safe-area.md +62 -0
- package/docs/testting.md +51 -0
- package/docs/ts.md +127 -0
- package/example/AppStyleX/.watchmanconfig +1 -0
- package/example/AppStyleX/android/build.gradle +26 -0
- package/example/AppStyleX/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/AppStyleX/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/example/AppStyleX/android/gradle.properties +53 -0
- package/example/AppStyleX/android/gradlew +249 -0
- package/example/AppStyleX/android/gradlew.bat +92 -0
- package/example/AppStyleX/android/settings.gradle +12 -0
- package/example/AppStyleX/app.json +16 -0
- package/example/AppStyleX/babel.config.js +3 -0
- package/example/AppStyleX/index.js +9 -0
- package/example/AppStyleX/ios/Podfile +7 -0
- package/example/AppStyleX/ios/Podfile.lock +1252 -0
- package/example/AppStyleX/metro.config.js +51 -0
- package/example/AppStyleX/package.json +43 -0
- package/example/AppStyleX/react-native.config.js +23 -0
- package/example/AppStyleX/src/App.tsx +22 -0
- package/example/AppStyleX/src/BottomNav/index.tsx +26 -0
- package/example/AppStyleX/src/BottomNav/styles.ts +42 -0
- package/example/AppStyleX/src/Circle/index.tsx +53 -0
- package/example/AppStyleX/src/Circle/styles.ts +22 -0
- package/example/AppStyleX/src/Root/index.tsx +35 -0
- package/example/AppStyleX/src/Root/styles.ts +18 -0
- package/example/AppStyleX/src/ToggleButton/index.tsx +52 -0
- package/example/AppStyleX/src/ToggleButton/styles.ts +67 -0
- package/example/AppStyleX/src/style-system/hooks/useAnimatedBgColor.ts +5 -0
- package/example/AppStyleX/src/style-system/hooks/useAnimatedTextColor.ts +5 -0
- package/example/AppStyleX/src/style-system/hooks/useIsDark.ts +8 -0
- package/example/AppStyleX/src/style-system/palette.ts +11 -0
- package/example/AppStyleX/src/style-system/theme.ts +14 -0
- package/example/AppStyleX/src/style-system/utils.ts +8 -0
- package/example/AppStyleX/src/stylex.d.ts +6 -0
- package/example/AppStyleX/tsconfig.json +3 -0
- package/example/AppStyleX/yarn.lock +6767 -0
- package/jest.config.js +19 -0
- package/package.json +38 -3
- package/src/appearance/index.ts +30 -0
- package/src/appearance/init.ts +12 -0
- package/{context.js → src/context.ts} +4 -1
- package/src/create-event-emitter.ts +26 -0
- package/src/dark-mode/index.ts +26 -0
- package/src/dark-mode/init.ts +19 -0
- package/{dark-mode/state.js → src/dark-mode/state.ts} +2 -1
- package/src/default-theme.ts +4 -0
- package/src/dependency-registry.ts +21 -0
- package/src/dependency-usage.ts +21 -0
- package/src/dimensions/index.ts +20 -0
- package/src/dimensions/init.ts +32 -0
- package/src/dimensions/utils.ts +9 -0
- package/src/i18n.ts +15 -0
- package/src/index.ts +7 -0
- package/{makeUseStyles/createUseStylesTheme.js → src/make-use-styles/create-use-styles-theme.js} +23 -6
- package/src/make-use-styles/create-use-styles-theme.test.js +137 -0
- package/{makeUseStyles/createUseStylesWithoutTheme.js → src/make-use-styles/create-use-styles-without-theme.js} +20 -4
- package/src/make-use-styles/create-use-styles-without-theme.test.js +63 -0
- package/src/make-use-styles/index.d.ts +20 -0
- package/src/make-use-styles/index.js +12 -0
- package/src/make-use-styles/index.test.js +28 -0
- package/src/make-use-styles/types.ts +43 -0
- package/{makeUseStyles → src/make-use-styles}/utils.js +5 -10
- package/src/media-query/base.ts +32 -0
- package/src/media-query/breakpoints.ts +96 -0
- package/src/media-query/index.ts +12 -0
- package/src/orientation.ts +13 -0
- package/{safe-area/eventEmitter.js → src/safe-area/event-emitter.ts} +2 -1
- package/src/safe-area/index.tsx +16 -0
- package/src/safe-area/init.tsx +6 -0
- package/src/safe-area/safe-area-provider.tsx +18 -0
- package/{safe-area/state.js → src/safe-area/state.ts} +7 -5
- package/src/safe-area/stylex-save-area-consumer.ts +22 -0
- package/{safe-area/types.d.ts → src/safe-area/types.ts} +7 -6
- package/src/tests/createBreakpoints.test.ts +152 -0
- package/src/tests/createBreakpointsMatcher.test.ts +188 -0
- package/src/tests/createBreakpointsMatcher.types-test.ts +81 -0
- package/src/tests/createEventEmitter.test.ts +37 -0
- package/src/tests/dark-mode.test.ts +56 -0
- package/src/tests/dependencyRegistry.test.ts +16 -0
- package/src/tests/dependencyUsage.test.ts +13 -0
- package/src/tests/dimensions.test.ts +33 -0
- package/src/tests/makeUseStyles.types-test.ts +69 -0
- package/src/tests/media-query.test.ts +196 -0
- package/src/tests/orientation.test.ts +61 -0
- package/src/tests/useTheme.test.ts +26 -0
- package/src/tests/withStyles.types-test.tsx +172 -0
- package/src/use-color-transition.ts +50 -0
- package/src/use-theme.ts +14 -0
- package/src/with-styles.tsx +22 -0
- package/tsconfig.build.json +31 -0
- package/tsconfig.json +30 -0
- package/DefaultTheme.d.ts +0 -2
- package/DefaultTheme.js +0 -1
- package/appearance/consts.d.ts +0 -1
- package/appearance/index.d.ts +0 -8
- package/appearance/index.js +0 -18
- package/appearance/init.d.ts +0 -1
- package/appearance/init.js +0 -7
- package/context.d.ts +0 -4
- package/createEventEmitter.d.ts +0 -8
- package/createEventEmitter.js +0 -11
- package/dark-mode/consts.d.ts +0 -1
- package/dark-mode/index.d.ts +0 -7
- package/dark-mode/index.js +0 -16
- package/dark-mode/init.d.ts +0 -1
- package/dark-mode/init.js +0 -13
- package/dark-mode/state.d.ts +0 -3
- package/dependencyRegistry.d.ts +0 -5
- package/dependencyRegistry.js +0 -12
- package/dependencyUsage.d.ts +0 -7
- package/dependencyUsage.js +0 -10
- package/dimensions/consts.d.ts +0 -2
- package/dimensions/index.d.ts +0 -4
- package/dimensions/index.js +0 -13
- package/dimensions/init.d.ts +0 -1
- package/dimensions/init.js +0 -21
- package/dimensions/utils.d.ts +0 -1
- package/dimensions/utils.js +0 -7
- package/i18n.d.ts +0 -7
- package/i18n.js +0 -9
- package/index.d.ts +0 -7
- package/index.js +0 -5
- package/makeUseStyles/index.d.ts +0 -7
- package/makeUseStyles/index.js +0 -12
- package/media-query/base.d.ts +0 -12
- package/media-query/base.js +0 -18
- package/media-query/breakpoints.d.ts +0 -18
- package/media-query/breakpoints.js +0 -60
- package/media-query/index.d.ts +0 -2
- package/media-query/index.js +0 -2
- package/orientation.d.ts +0 -7
- package/orientation.js +0 -7
- package/safe-area/SafeAreaProvider.d.ts +0 -3
- package/safe-area/SafeAreaProvider.js +0 -9
- package/safe-area/StylexSaveAreaConsumer.d.ts +0 -2
- package/safe-area/StylexSaveAreaConsumer.js +0 -15
- package/safe-area/consts.d.ts +0 -1
- package/safe-area/eventEmitter.d.ts +0 -1
- package/safe-area/index.d.ts +0 -5
- package/safe-area/index.js +0 -10
- package/safe-area/init.d.ts +0 -1
- package/safe-area/init.js +0 -4
- package/safe-area/state.d.ts +0 -8
- package/safe-area/types.js +0 -1
- package/useColorTransition.d.ts +0 -5
- package/useColorTransition.js +0 -38
- package/useTheme.d.ts +0 -2
- package/useTheme.js +0 -9
- package/withStyles.d.ts +0 -7
- package/withStyles.js +0 -13
- /package/{appearance/consts.js → src/appearance/consts.ts} +0 -0
- /package/{dark-mode/consts.js → src/dark-mode/consts.ts} +0 -0
- /package/{dimensions/consts.js → src/dimensions/consts.ts} +0 -0
- /package/{makeUseStyles → src/make-use-styles}/test-type.js +0 -0
- /package/{safe-area/consts.js → src/safe-area/consts.ts} +0 -0
package/.eslintignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*.js
|
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: "@typescript-eslint/parser",
|
|
3
|
+
extends: ["plugin:react/recommended", "plugin:@typescript-eslint/recommended", "prettier"],
|
|
4
|
+
parserOptions: {
|
|
5
|
+
ecmaVersion: 2020,
|
|
6
|
+
sourceType: "module",
|
|
7
|
+
},
|
|
8
|
+
settings: {
|
|
9
|
+
react: {
|
|
10
|
+
version: "detect",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
"react/prop-types": "off",
|
|
15
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
16
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
17
|
+
"@typescript-eslint/ban-types": [
|
|
18
|
+
"error",
|
|
19
|
+
{
|
|
20
|
+
extendDefaults: true,
|
|
21
|
+
types: {
|
|
22
|
+
object: false,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Code Quality
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- master
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
18
|
+
strategy:
|
|
19
|
+
matrix:
|
|
20
|
+
os: [ubuntu-22.04, macos-14]
|
|
21
|
+
node-version: [20.x]
|
|
22
|
+
steps:
|
|
23
|
+
- name: Checkout repository
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
with:
|
|
26
|
+
fetch-depth: 0
|
|
27
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
28
|
+
uses: actions/setup-node@v4
|
|
29
|
+
with:
|
|
30
|
+
cache: 'yarn'
|
|
31
|
+
node-version: ${{ matrix.node-version }}
|
|
32
|
+
- run: yarn install --frozen-lockfile --ignore-engines
|
|
33
|
+
- run: yarn ci
|
package/.size-limit.json
ADDED
package/babel.config.js
ADDED
package/biome.jsonc
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.2.5/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": false,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": false
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": false,
|
|
10
|
+
"maxSize": 1001048576
|
|
11
|
+
},
|
|
12
|
+
"formatter": {
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"indentStyle": "space",
|
|
15
|
+
"lineWidth": 160,
|
|
16
|
+
"includes": ["**", "!**/*/routeTree.gen.ts"],
|
|
17
|
+
"formatWithErrors": true
|
|
18
|
+
},
|
|
19
|
+
"css": {
|
|
20
|
+
"parser": {
|
|
21
|
+
"tailwindDirectives": true
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"linter": {
|
|
25
|
+
"enabled": true,
|
|
26
|
+
"rules": {
|
|
27
|
+
"recommended": true,
|
|
28
|
+
"complexity": {
|
|
29
|
+
"noVoid": "off",
|
|
30
|
+
"noArguments": "error",
|
|
31
|
+
"noBannedTypes": "error",
|
|
32
|
+
"noCommaOperator": "error",
|
|
33
|
+
"noEmptyTypeParameters": "error",
|
|
34
|
+
"noExtraBooleanCast": "off",
|
|
35
|
+
"noFlatMapIdentity": "error",
|
|
36
|
+
"noForEach": "error",
|
|
37
|
+
"noImplicitCoercions": "error",
|
|
38
|
+
"noStaticOnlyClass": "error",
|
|
39
|
+
"noUselessCatch": "error",
|
|
40
|
+
"noUselessConstructor": "error",
|
|
41
|
+
"noUselessContinue": "error",
|
|
42
|
+
"noUselessFragments": "error",
|
|
43
|
+
"noUselessLabel": "error",
|
|
44
|
+
"useArrowFunction": "off",
|
|
45
|
+
"useOptionalChain": "error",
|
|
46
|
+
"useSimpleNumberKeys": "error",
|
|
47
|
+
"useWhile": "error"
|
|
48
|
+
},
|
|
49
|
+
"suspicious": {
|
|
50
|
+
"noVar": "error",
|
|
51
|
+
"useAwait": "error",
|
|
52
|
+
"useDefaultSwitchClauseLast": "error"
|
|
53
|
+
},
|
|
54
|
+
"correctness": {
|
|
55
|
+
"noUnusedVariables": "off",
|
|
56
|
+
"noVoidTypeReturn": "off"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"javascript": {
|
|
61
|
+
"formatter": {
|
|
62
|
+
"quoteStyle": "double"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"assist": {
|
|
66
|
+
"enabled": true,
|
|
67
|
+
"actions": {
|
|
68
|
+
"source": {
|
|
69
|
+
"organizeImports": "on"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
package/docs/api.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
Also read:
|
|
4
|
+
|
|
5
|
+
- [Media query](media-query.md)
|
|
6
|
+
- [Orientation](orientation.md)
|
|
7
|
+
- [I18n](i18n.md)
|
|
8
|
+
- [react-native-safe-area-view](safe-area.md)
|
|
9
|
+
- [react-native-dark-mode](dark-mode.md);
|
|
10
|
+
- [Typescript](ts.md);
|
|
11
|
+
- [Testing with Jest](testting.md).
|
|
12
|
+
|
|
13
|
+
Use a `makeUseStyles` function to create a hook function that can be used in react components
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { makeUseStyles } from "react-native-stylex";
|
|
17
|
+
|
|
18
|
+
export const useStyles = makeUseStyles((theme) => ({
|
|
19
|
+
root: {
|
|
20
|
+
color: theme.palette.xColor,
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Using styles 🧲
|
|
26
|
+
|
|
27
|
+
You can use styles in function or class components:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import React, { Component } from "react";
|
|
31
|
+
import { useStyles } from "./styles";
|
|
32
|
+
|
|
33
|
+
// Functional component (hooks variant)
|
|
34
|
+
const Root = () => {
|
|
35
|
+
const styles = useStyles();
|
|
36
|
+
|
|
37
|
+
return <View style={styles.root} />;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default Root;
|
|
41
|
+
|
|
42
|
+
// ----------------------------
|
|
43
|
+
// Class component (HOC variant)
|
|
44
|
+
class Root extends Component {
|
|
45
|
+
render() {
|
|
46
|
+
const { styles } = this.props;
|
|
47
|
+
|
|
48
|
+
return <View style={styles.row} />;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default withStyles(useStyles)(Root);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Theming support 🔋
|
|
56
|
+
|
|
57
|
+
You need wrap you're root component with ThemeProvider and pass theme
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
import { ThemeProvider } from "react-native-stylex";
|
|
61
|
+
|
|
62
|
+
const theme = {
|
|
63
|
+
palette: {
|
|
64
|
+
textColor: "black",
|
|
65
|
+
},
|
|
66
|
+
utils: {
|
|
67
|
+
fade(color, value) {
|
|
68
|
+
/*...*/
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const App = () => (
|
|
74
|
+
<ThemeProvider value={theme}>
|
|
75
|
+
<Root />
|
|
76
|
+
</ThemeProvider>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
export default App;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Then use a `makeUseStyles` function and extract passed theme ⚡️
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
import { makeUseStyles } from "react-native-stylex";
|
|
86
|
+
import { minWidth } from "react-native-stylex/media-query";
|
|
87
|
+
|
|
88
|
+
// Theme-dependent styles
|
|
89
|
+
const useStyles = makeUseStyles(({ palette, utils }) => ({
|
|
90
|
+
root: {
|
|
91
|
+
color: palette.textColor,
|
|
92
|
+
...minWidth(320, {
|
|
93
|
+
color: utils.fade(palette.textColor, 0.7),
|
|
94
|
+
}),
|
|
95
|
+
},
|
|
96
|
+
}));
|
|
97
|
+
|
|
98
|
+
const Root = () => {
|
|
99
|
+
const styles = useStyles();
|
|
100
|
+
|
|
101
|
+
return <View style={styles.root} />;
|
|
102
|
+
};
|
|
103
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Appearance 🕳️
|
|
2
|
+
|
|
3
|
+
To start using integration with [react-native Appearance](https://reactnative.dev/docs/appearance) module, you need to use react-native [0.62.x](https://reactnative.dev/blog/2020/03/26/version-0.62#new-dark-mode-features).
|
|
4
|
+
|
|
5
|
+
> ⚠️ If you need to support React Native below `0.62.x`, please see [react-native-dark-mode](docs/dark-mode.md)
|
|
6
|
+
|
|
7
|
+
After that you can use special API:
|
|
8
|
+
|
|
9
|
+
- `appearance({ dark, light, default })`
|
|
10
|
+
- `darkAppearance(value)`
|
|
11
|
+
- `lightAppearance(value)`
|
|
12
|
+
- `noPreferenceAppearance(value)`
|
|
13
|
+
|
|
14
|
+
`dark` - The user prefers a dark color theme.
|
|
15
|
+
`light` - The user prefers a light color theme.
|
|
16
|
+
`default` - The user has not indicated a preferred color theme.
|
|
17
|
+
|
|
18
|
+
**Example:**
|
|
19
|
+
|
|
20
|
+
```typescript jsx
|
|
21
|
+
import { makeUseStyles } from "react-native-stylex";
|
|
22
|
+
import {
|
|
23
|
+
appearance,
|
|
24
|
+
darkAppearance,
|
|
25
|
+
lightAppearance,
|
|
26
|
+
noPreferenceAppearance,
|
|
27
|
+
} from "react-native-stylex/appearance";
|
|
28
|
+
|
|
29
|
+
export default makeUseStyles(() => ({
|
|
30
|
+
root: {
|
|
31
|
+
// you can pass styles
|
|
32
|
+
...appearance({
|
|
33
|
+
dark: { color: "#fff", backgroundColor: "#000" },
|
|
34
|
+
light: { color: "#000", backgroundColor: "#fff" },
|
|
35
|
+
}),
|
|
36
|
+
|
|
37
|
+
// or string value for property
|
|
38
|
+
backgroundColor: appearance({ dark: "#000", light: "#fff" }),
|
|
39
|
+
},
|
|
40
|
+
cell: {
|
|
41
|
+
// styles variant
|
|
42
|
+
...lightAppearance({ color: "#000" }),
|
|
43
|
+
// specific value variant
|
|
44
|
+
backgroundColor: lightAppearance("#fff"),
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
row: {
|
|
48
|
+
// styles variant
|
|
49
|
+
...darkAppearance({ color: "#000" }),
|
|
50
|
+
// specific value variant
|
|
51
|
+
backgroundColor: darkAppearance("#fff"),
|
|
52
|
+
},
|
|
53
|
+
}));
|
|
54
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Dark mode 🕳️
|
|
2
|
+
|
|
3
|
+
> ⚠️ If you use React Native `0.62.x` and higher, please use [Appearance](docs/appearance.md)
|
|
4
|
+
|
|
5
|
+
To start using integration with [react-native-dark-mode](https://github.com/codemotionapps/react-native-dark-mode) module
|
|
6
|
+
|
|
7
|
+
You need just install it using [instructions](https://github.com/codemotionapps/react-native-dark-mode#installation)!
|
|
8
|
+
|
|
9
|
+
After that you can use special API:
|
|
10
|
+
|
|
11
|
+
- `uiMode({ dark, light })`
|
|
12
|
+
- `darkUiMode(value)`
|
|
13
|
+
- `lightUiMode(value)`
|
|
14
|
+
|
|
15
|
+
**Example:**
|
|
16
|
+
|
|
17
|
+
```typescript jsx
|
|
18
|
+
import { makeUseStyles } from "react-native-stylex";
|
|
19
|
+
import { uiMode, darkUiMode, lightUiMode } from "react-native-stylex/dark-mode";
|
|
20
|
+
|
|
21
|
+
export const useStyles = makeUseStyles(() => ({
|
|
22
|
+
root: {
|
|
23
|
+
// you can pass styles
|
|
24
|
+
...uiMode({
|
|
25
|
+
dark: { color: "#fff", backgroundColor: "#000" },
|
|
26
|
+
light: { color: "#000", backgroundColor: "#fff" },
|
|
27
|
+
}),
|
|
28
|
+
|
|
29
|
+
// or string value for property
|
|
30
|
+
backgroundColor: uiMode({ dark: "#000", light: "#fff" }),
|
|
31
|
+
},
|
|
32
|
+
cell: {
|
|
33
|
+
// styles variant
|
|
34
|
+
...lightUiMode({ color: "#000" }),
|
|
35
|
+
// specific value variant
|
|
36
|
+
backgroundColor: lightUiMode("#fff"),
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
row: {
|
|
40
|
+
// styles variant
|
|
41
|
+
...darkUiMode({ color: "#000" }),
|
|
42
|
+
// specific value variant
|
|
43
|
+
backgroundColor: darkUiMode("#fff"),
|
|
44
|
+
},
|
|
45
|
+
}));
|
|
46
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Dimensions 📐
|
|
2
|
+
|
|
3
|
+
Nothing special just two helper functions that use [Dimensions](https://reactnative.dev/docs/dimensions) API
|
|
4
|
+
|
|
5
|
+
- `getWindowDimensions`
|
|
6
|
+
- `getScreenDimensions`
|
|
7
|
+
|
|
8
|
+
These functions return an object with the next properties:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
scale: number;
|
|
14
|
+
fontScale: number;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
**Example:**
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { makeUseStyles } from "react-native-stylex";
|
|
21
|
+
import { getWindowDimensions } from "react-native-stylex/dimensions";
|
|
22
|
+
|
|
23
|
+
export const useStyles = makeUseStyles(() => ({
|
|
24
|
+
video: {
|
|
25
|
+
width: getWindowDimensions().width,
|
|
26
|
+
height: getWindowDimensions().width,
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
```
|
package/docs/i18n.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# i18n 🗺
|
|
2
|
+
|
|
3
|
+
We use [I18nManager](https://github.com/facebook/react-native/blob/e36247030575e93c1d7087cdb04e1498e9577056/Libraries/ReactNative/I18nManager.js) to handler correct direction
|
|
4
|
+
|
|
5
|
+
**!!! ⚠️ React Native include special mechanism to revert 'left' to 'right' value [`I18nManager.swapLeftAndRightInRTL(true)`](https://reactnative.dev/blog/2017/11/06/react-native-monthly-5#facebook) ⚠️ !!!**
|
|
6
|
+
|
|
7
|
+
- `i18n({ ltr, ltr })`
|
|
8
|
+
- `rtl(value)`
|
|
9
|
+
- `ltr(value)`
|
|
10
|
+
|
|
11
|
+
It means that don't need to use this apis above for setting next values:
|
|
12
|
+
|
|
13
|
+
- Position:
|
|
14
|
+
- (left|right) → (start|end)
|
|
15
|
+
- Margin:
|
|
16
|
+
- margin(Left|Right) → margin(Start|End)
|
|
17
|
+
- Padding:
|
|
18
|
+
- padding(Left|Right) → padding(Start|End)
|
|
19
|
+
- Border:
|
|
20
|
+
- borderTop(Left|Right)Radius → borderTop(Start|End)Radius
|
|
21
|
+
- borderBottom(Left|Right)Radius → borderBottom(Start|End)Radius
|
|
22
|
+
- border(Left|Right)Width → border(Start|End)Width
|
|
23
|
+
- border(Left|Right)Color → border(Start|End)Color
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { i18n } from "react-native-stylex/i18n";
|
|
27
|
+
|
|
28
|
+
// ✅ Good https://reactnative.dev/blog/2017/11/06/react-native-monthly-5#facebook
|
|
29
|
+
good: {
|
|
30
|
+
start: 20,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ❌ Bad
|
|
34
|
+
bad: {
|
|
35
|
+
...i18n({ ltr: { left: 20 }, rtl: { right: 20 } }),
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Example:**
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { makeUseStyles } from "react-native-stylex";
|
|
43
|
+
import { i18n, rtl, ltr } from "react-native-stylex/i18n";
|
|
44
|
+
|
|
45
|
+
export const useStyles = makeUseStyles(() => ({
|
|
46
|
+
root: {
|
|
47
|
+
// you can pass styles
|
|
48
|
+
...i18n({ ltr: { left: 20 }, rtl: { right: 20 } }),
|
|
49
|
+
|
|
50
|
+
// or string value for property
|
|
51
|
+
textAlign: i18n({ ltr: "left", rtl: "right" }),
|
|
52
|
+
},
|
|
53
|
+
cell: {
|
|
54
|
+
// styles variant
|
|
55
|
+
...ltr({ left: 0 }),
|
|
56
|
+
// specific value variant
|
|
57
|
+
alignItems: ltr("flex-start"),
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
row: {
|
|
61
|
+
// styles variant
|
|
62
|
+
...rtl({ right: 0 }),
|
|
63
|
+
// specific value variant
|
|
64
|
+
alignItems: rtl("flex-end"),
|
|
65
|
+
},
|
|
66
|
+
}));
|
|
67
|
+
```
|
package/docs/logo.png
ADDED
|
Binary file
|