rn-css 1.7.0 → 1.8.1

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.8
4
+
5
+ * Accept returning an RN Style object in the tagged template string
6
+ * Fix a type issue in the style prop of the components
7
+
8
+ ## Version 1.7
9
+
10
+ * Improve type support for the Theming system
11
+
3
12
  ## Version 1.6
4
13
 
5
14
  * Creation of RemContext to control rem units value
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This is basically [styled-components](https://github.com/styled-components/styled-components) with a much better support for React-Native, and some awesome additional features. You can check the docs of [styled-components](https://github.com/styled-components/styled-components) for more details about the basic API. I'll focus here on the differences.
4
4
 
5
- **Current version: 1.5** [See the Changelog](./CHANGELOG.md)
5
+ **Current version: 1.8** [See the Changelog](./CHANGELOG.md)
6
6
 
7
7
  ---
8
8
 
@@ -91,6 +91,17 @@ const View = styled.View<{ color: string }>`
91
91
  `
92
92
  ```
93
93
 
94
+ Here is an example returning directly a Style object:
95
+
96
+ ```javascript
97
+ const View = styled.View`
98
+ color: black;
99
+ ${props => ({ justifyContent: props.center })}
100
+ `
101
+ ```
102
+
103
+
104
+
94
105
  ---
95
106
 
96
107
  ### <ins>attrs:</ins>
@@ -323,7 +334,7 @@ const View = styled.View`
323
334
 
324
335
  ### <ins>Typescript:</ins>
325
336
 
326
- For Typescript, `shared` will always be typed with `unknown`. You need to manually declare the type of your shared object. Be careful: you won't have typecheck this way. We don't have any better way for now.
337
+ For Typescript, `shared` will always be typed with `unknown`. You need to manually declare the type of your shared object. Read the Theming section to learn more about workarounds.
327
338
 
328
339
  ```typescript
329
340
  // Create your theme
@@ -1,5 +1,4 @@
1
- import { /* StyleSheet, */ TextStyle, ViewStyle } from 'react-native';
2
- import type { PartialStyle, Units } from './types';
1
+ import type { AnyStyle, PartialStyle, Units } from './types';
3
2
  /** Mix the calculated RN style within the object style */
4
- declare const convertStyle: (rnStyle: PartialStyle, units: Units) => TextStyle & ViewStyle;
3
+ declare const convertStyle: <T extends AnyStyle = AnyStyle>(rnStyle: PartialStyle, units: Units) => T;
5
4
  export default convertStyle;
@@ -12,7 +12,7 @@ function parseValue(value) {
12
12
  exports.parseValue = parseValue;
13
13
  /** Convert a value using the provided unit transform table */
14
14
  function convertValue(key, value, units) {
15
- if (!(Object(value) instanceof String)) {
15
+ if (typeof value !== 'string') {
16
16
  console.error(`Failed to parse CSS instruction: ${key}=${value}. We expect a string, but ${value} was of type ${typeof value}.`);
17
17
  return 0;
18
18
  }
@@ -4,5 +4,5 @@ export declare function cssToRNStyle(css: string, units?: {
4
4
  em?: number;
5
5
  width?: number;
6
6
  height?: number;
7
- }): import("react-native").TextStyle & import("react-native").ViewStyle;
7
+ }): import("../types").AnyStyle;
8
8
  export default cssToStyle;