-
Notifications
You must be signed in to change notification settings - Fork 5
Closed
Description
Just an idea.
I find it easier and more readable to write:
<View margin="20 15 10" />Writing the shorthand like this is one String.split / Array.map / parseInt away from the original/needed array.
But one drawback is that we loose that use case:
| Shorthand | Style Result |
|---|---|
margin={[20]} |
{marginVertical: 20} |
Writing <View margin="20" /> would end up in margin = [20] but really it should be margin = 20.
There are 2 solutions to this problem:
- Pass a number instead of a string when you want "full" margin/padding:
<View margin={20} />and<View margin="20" />remainsmargin = [20] - Or always force vertical & horizontal values in shorthand, then
<View margin="20" />becomes the full margin, and if you want vertical only:<View margin="20 0" />
I'm leaning toward solution 2 because it's in line with CSS shorthand syntax. Not to mention that solution 2 would be a clearly separated syntax choice on its own, not overlapping with original Number/Array syntax.
Metadata
Metadata
Assignees
Labels
No labels