Skip to content

Directly allow strings for margin and size, too? #450

Closed

Description

@cknitt

Should we use the approach for color props from #448 for margin and size props, too? I.e. have modules Margin and Size with "safe" helper functions, but Margin.t = Size.t = string?

Would make things easier for people coming from React Native JS.

@MoOx @sgny

Activity

  1. MoOx commented on Apr 27, 2019

    @MoOx
    Member

    I am more than ok with this change.

  2. cknitt commented on Apr 27, 2019

    @cknitt
    MemberAuthor

    Hmmm, compared to Color, the problem with margin and size is that these accept either floats or strings.

  3. MoOx commented on Apr 27, 2019

    @MoOx
    Member

    This is because in JS "1" == 1...
    Should we accept string only for unsafe usage & have method sending float as unitless value (pt) or string for %?

  4. DCKT commented on Apr 29, 2019

    @DCKT

    I think it's a good idea too, we should find the good compromise 🤔
    We have to deal with Pt(), Float(), Float this is pretty confusing for beginners

    Actually :

    fontSize(Float(12.))
    margin(Pt(12.))
    borderRadius(4.)
    

    String should be an escape hatch I think

  5. MoOx commented on Apr 29, 2019

    @MoOx
    Member

    Float won't be a thing in new bindings, that said, we still try to add a safety layer to avoid accepting anything that won't work anyway...

  6. MoOx commented on May 1, 2019

    @MoOx
    Member

    I was wondering about a thing that bother me a little (but not too much :D ). We recently moved some submodules from Style, like Margin, Size etc, but I was wondering if that's a good idea to have so much "generic names" taken as soon as you open ReactNative.

    I remember in the past being unhappy because bs-rn had generic names like "Types" taken by the open... And I just saw that in some projects (some personals & some for clients), I have a Color module, as well as a Font one & sometimes a Style one too.
    So I was asking myself if we shouldn't keep Margin & Friend in Style, even if that's require 2 () when you want to use those, to avoid this kind if "issues".

    Thoughts?

  7. cknitt commented on May 1, 2019

    @cknitt
    MemberAuthor

    @MoOx I see your point. On the other hand, that's what happens when you open modules. 😉 I am currently working on a GIS application where I have a Map module, so when I open Belt I get a warning because of Belt.Map...

    Anyway, I am not opposed to moving Margin and Size back into Style because they are only referenced from Style. We should have types/Style_Margin.re and types/Style_Size.re then and alias these in Style.

    Color should remain outside of Style though as it is used outside of Style (directly in the props of many different components).

  8. DCKT commented on May 1, 2019

    @DCKT

    +1 with @cknitt ; Margin & Size should be part of Style 😃

  9. MoOx commented on May 1, 2019

    @MoOx
    Member

    @DCKT we discussed about that in private & are going to remove those 2 in favor of simpler function directly inside Style module (less safe but way more accessible)

  10. cknitt commented on May 1, 2019

    @cknitt
    MemberAuthor

    Strings are not feasible because we need to pass floats for pt values.

    We found another simplification though, see #478.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions