rn-css 1.10.0 → 1.10.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/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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-css",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
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