rn-css 1.10.0 → 1.10.2

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/README.md CHANGED
@@ -61,6 +61,7 @@ There is only partial support for `%` units as I didn't find a way to retrieve t
61
61
  * left
62
62
  * right
63
63
  * flex-basis
64
+ * border
64
65
 
65
66
  **`%` with `calc`, `min`, `max`**: You can try using `%` inside `calc`, `min` or `max` with the following CSS props, it should work as expected:
66
67
 
@@ -22,7 +22,8 @@ function convertValue(key, value, units) {
22
22
  // Percentage values need to rely on an other unit as reference
23
23
  const finalUnits = { ...units };
24
24
  if (value.includes('%')) {
25
- if (react_native_1.Platform.OS === 'web')
25
+ // Percentage is not supported on borders in web
26
+ if (react_native_1.Platform.OS === 'web' && (!key.toLowerCase().includes('border') || key.toLowerCase().includes('radius')))
26
27
  return value;
27
28
  if (['marginTop', 'marginBottom', 'translateY'].includes(key) || key.startsWith('borderTop') || key.startsWith('borderBottom'))
28
29
  finalUnits['%'] = units.height / 100;
@@ -126,8 +126,12 @@ function cssChunkToStyle(css) {
126
126
  break;
127
127
  case 'boxShadow':
128
128
  case 'textShadow':
129
+ // To provide support for the 4th element (spread-radius) at least for web
130
+ if (react_native_1.Platform.OS === 'web')
131
+ Object.assign(result, { [key]: value });
129
132
  // We need to replace boxShadow by shadow
130
- Object.assign(result, (0, convert_1.shadow)(key === 'boxShadow' ? 'shadow' : key, value));
133
+ else
134
+ Object.assign(result, (0, convert_1.shadow)(key === 'boxShadow' ? 'shadow' : key, value));
131
135
  break;
132
136
  // Other keys don't require any special treatment
133
137
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.10.0",
3
+ "version": "1.10.2",
4
4
  "scripts": {
5
5
  "test": "jest",
6
6
  "prepare": "rm -rf dist && tsc",
@@ -21,7 +21,8 @@ export function convertValue (key: keyof PartialStyle | keyof Transform, value:
21
21
  // Percentage values need to rely on an other unit as reference
22
22
  const finalUnits = { ...units }
23
23
  if (value.includes('%')) {
24
- if (Platform.OS === 'web') return value
24
+ // Percentage is not supported on borders in web
25
+ if (Platform.OS === 'web' && (!key.toLowerCase().includes('border') || key.toLowerCase().includes('radius'))) return value
25
26
  if (['marginTop', 'marginBottom', 'translateY'].includes(key) || key.startsWith('borderTop') || key.startsWith('borderBottom')) finalUnits['%'] = units.height! / 100
26
27
  else if (['marginLeft', 'marginRight', 'translateX'].includes(key) || key.startsWith('borderLeft') || key.startsWith('borderRight')) finalUnits['%'] = units.width! / 100
27
28
  else if (key.startsWith('border') && key.endsWith('Radius')) finalUnits['%'] = (units.width! + units.height!) / 200
@@ -1,4 +1,4 @@
1
- import { Dimensions } from 'react-native'
1
+ import { Dimensions, Platform } from 'react-native'
2
2
  import convertStyle from '../convertStyle'
3
3
  import { CompleteStyle, Context, PartialStyle, Style, Units } from '../types'
4
4
  import { sideValue, border, borderLike, cornerValue, font, textDecoration, shadow, placeContent, flex, flexFlow, transform, background } from './convert'
@@ -123,8 +123,10 @@ function cssChunkToStyle (css: string) {
123
123
  break
124
124
  case 'boxShadow':
125
125
  case 'textShadow':
126
+ // To provide support for the 4th element (spread-radius) at least for web
127
+ if (Platform.OS === 'web') Object.assign(result, { [key]: value })
126
128
  // We need to replace boxShadow by shadow
127
- Object.assign(result, shadow(key === 'boxShadow' ? 'shadow' : key, value))
129
+ else Object.assign(result, shadow(key === 'boxShadow' ? 'shadow' : key, value))
128
130
  break
129
131
  // Other keys don't require any special treatment
130
132
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment