rn-css 1.6.17 → 1.6.19-0
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/CHANGELOG.md +16 -0
- package/README.md +16 -0
- package/dist/cssToRN/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/styleComponent.d.ts +2 -1
- package/dist/useTheme.d.ts +2 -1
- package/package.json +2 -2
- package/src/cssToRN/index.ts +2 -2
- package/src/index.tsx +1 -1
- package/src/styleComponent.tsx +3 -1
- package/src/useTheme.tsx +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Version 1.6
|
|
4
|
+
|
|
5
|
+
* Creation of RemContext to control rem units value
|
|
6
|
+
* Important performance fix (500% faster!)
|
|
7
|
+
|
|
8
|
+
## Version 1.5
|
|
9
|
+
|
|
10
|
+
* Add Theming features with the same [API](https://styled-components.com/docs/advanced) as `styled-components` lib.
|
|
11
|
+
* Remove support for deprecated components: *ListView*, *SwipeableListView*, *TabBarIOS*, *ToolbarAndroid* and *ViewPagerAndroid*
|
|
12
|
+
* Fix font-weight to accept numeric values
|
|
13
|
+
|
|
14
|
+
## Version 1.4
|
|
15
|
+
|
|
16
|
+
* Change the type of `rnCSS` from `string` to `${string};` to ensure that it will end with a semicolon
|
package/README.md
CHANGED
|
@@ -347,6 +347,22 @@ To match the API of styled-components, we offer the same abilities for theming [
|
|
|
347
347
|
|
|
348
348
|
This relies on the [SharedValue](#shared-value) context. This means that you cannot use the Shared Value system **and** this theming système. Pick the one that best suits your needs.
|
|
349
349
|
|
|
350
|
+
### Custom theme type for typescript
|
|
351
|
+
|
|
352
|
+
When you use the theme prop in your components, it is initially typed as `unknown`. But you can make it follow your custom type by extending the type declaration of **rn-css**. You will need to create a file `rncss.d.ts` in the `src` of your project root and add the following lines:
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
import 'rn-css';
|
|
356
|
+
|
|
357
|
+
declare module 'rn-css' {
|
|
358
|
+
type MyTheme = {
|
|
359
|
+
// Describe your theme here.
|
|
360
|
+
// Alternatively, you can use: `type MyTheme = typeof theme` if you have a fixed `theme` object.
|
|
361
|
+
}
|
|
362
|
+
export interface DefaultTheme extends MyTheme {}
|
|
363
|
+
}
|
|
364
|
+
```
|
|
365
|
+
|
|
350
366
|
---
|
|
351
367
|
|
|
352
368
|
## Coming later:
|
package/dist/cssToRN/index.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import * as RN from 'react-native';
|
|
3
3
|
import './polyfill';
|
|
4
4
|
export { cssToRNStyle } from './cssToRN';
|
|
5
|
-
export { SharedValue, FontSizeContext, RemContext } from './styleComponent';
|
|
5
|
+
export { SharedValue, FontSizeContext, RemContext, DefaultTheme } from './styleComponent';
|
|
6
6
|
export * from './useTheme';
|
|
7
7
|
declare const styled: {
|
|
8
8
|
<T>(Component: React.ComponentType<T>): {
|
package/dist/styleComponent.d.ts
CHANGED
|
@@ -5,11 +5,12 @@ export declare const defaultUnits: Units;
|
|
|
5
5
|
export declare const RemContext: React.Context<number>;
|
|
6
6
|
export declare const FontSizeContext: React.Context<number>;
|
|
7
7
|
export declare const SharedValue: React.Context<unknown>;
|
|
8
|
+
export declare type DefaultTheme = unknown;
|
|
8
9
|
declare type Primitive = number | string | null | undefined | boolean;
|
|
9
10
|
declare type Functs<T> = (arg: T & {
|
|
10
11
|
rnCSS?: string;
|
|
11
12
|
shared: unknown;
|
|
12
|
-
theme:
|
|
13
|
+
theme: DefaultTheme;
|
|
13
14
|
}) => Primitive;
|
|
14
15
|
declare type OptionalProps = {
|
|
15
16
|
rnCSS?: `${string};`;
|
package/dist/useTheme.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { DefaultTheme } from './styleComponent';
|
|
2
3
|
/** Provider for the theme. */
|
|
3
4
|
export declare const ThemeProvider: ({ theme, children }: {
|
|
4
|
-
theme:
|
|
5
|
+
theme: DefaultTheme;
|
|
5
6
|
children: React.ReactNode;
|
|
6
7
|
}) => JSX.Element;
|
|
7
8
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rn-css",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.19-0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"test": "jest",
|
|
6
6
|
"prepare": "tsc",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"react-native-typescript-transformer": "^1.2.13",
|
|
50
50
|
"react-native-web": "^0.17.7",
|
|
51
51
|
"react-test-renderer": "17.0.2",
|
|
52
|
-
"release-it": "^
|
|
52
|
+
"release-it": "^15.6.0",
|
|
53
53
|
"ts-jest": "^27.1.1",
|
|
54
54
|
"ts-loader": "^9.2.6",
|
|
55
55
|
"typescript": "^4.5.4",
|
package/src/cssToRN/index.ts
CHANGED
package/src/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import * as RN from 'react-native'
|
|
|
3
3
|
import './polyfill'
|
|
4
4
|
import styledComponent, { styledFlatList, styledSectionList, styledVirtualizedList } from './styleComponent'
|
|
5
5
|
export { cssToRNStyle } from './cssToRN'
|
|
6
|
-
export { SharedValue, FontSizeContext, RemContext } from './styleComponent'
|
|
6
|
+
export { SharedValue, FontSizeContext, RemContext, DefaultTheme } from './styleComponent'
|
|
7
7
|
export * from './useTheme'
|
|
8
8
|
|
|
9
9
|
const styled = <T, >(Component: React.ComponentType<T>) => styledComponent<T>(Component)
|
package/src/styleComponent.tsx
CHANGED
|
@@ -15,8 +15,10 @@ export const FontSizeContext = React.createContext(defaultUnits.em)
|
|
|
15
15
|
// We use this to share value within the component (Theme, Translation, whatever)
|
|
16
16
|
export const SharedValue = React.createContext<unknown>(undefined)
|
|
17
17
|
|
|
18
|
+
export type DefaultTheme = unknown
|
|
19
|
+
|
|
18
20
|
type Primitive = number | string | null | undefined | boolean
|
|
19
|
-
type Functs<T> = (arg: T & { rnCSS?: string; shared: unknown, theme:
|
|
21
|
+
type Functs<T> = (arg: T & { rnCSS?: string; shared: unknown, theme: DefaultTheme }) => Primitive
|
|
20
22
|
type OptionalProps = {
|
|
21
23
|
rnCSS?: `${string};`;
|
|
22
24
|
onMouseEnter?: (event: MouseEvent) => void;
|
package/src/useTheme.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { SharedValue } from './styleComponent'
|
|
2
|
+
import { DefaultTheme, SharedValue } from './styleComponent'
|
|
3
3
|
|
|
4
4
|
/** Provider for the theme. */
|
|
5
|
-
export const ThemeProvider = ({ theme, children }: { theme:
|
|
5
|
+
export const ThemeProvider = ({ theme, children }: { theme: DefaultTheme; children: React.ReactNode }) => {
|
|
6
6
|
return <SharedValue.Provider value={theme}>
|
|
7
7
|
{children}
|
|
8
8
|
</SharedValue.Provider>
|