Code Monkey home page Code Monkey logo

Comments (14)

pddivine avatar pddivine commented on June 29, 2024 2

Perhaps Touchable should be generalized to Input since it is also responding to a form of input. TextInput implies input from a keyboard. If we had a general Input primitive it could be bound to different input types, like mouse, touch, keyboard, gyroscope, location, etc.

from react-primitives.

mathieudutour avatar mathieudutour commented on June 29, 2024 1

Might be worth listing it in the Readme alongside react-primitivessvg`

from react-primitives.

obartra avatar obartra commented on June 29, 2024

I'm interested on this as well, @lelandrichardson do you have any further insight on the topic? Happy to contribute if needed

from react-primitives.

necolas avatar necolas commented on June 29, 2024

FWIW, you can prototype that / try it out in your environment by setting up your own injection (e.g., web injection). For Sketch, you could create a faux TextInput from Views/Text elements.

from react-primitives.

ekryski avatar ekryski commented on June 29, 2024

I agree I think TextInput or even just Input (a base input component) should be a primitive. I started prototyping a version today but would love to hear from you guys as to what it should support.

My first stab was modeling it more after the react-native-web interface but I'm not 100% sold on that.

from react-primitives.

necolas avatar necolas commented on June 29, 2024

My first stab was modeling it more after the react-native-web interface but I'm not 100% sold on that

It's the same as React Native

from react-primitives.

ekryski avatar ekryski commented on June 29, 2024

@necolas yes you are right but what I found is that the browser supports more HTML5 input types (ie. dates, numbers, etc.) and a bunch of the RN interface doesn't make a whole lot of sense for web (ie. keyboard options, potentially capitalization, etc.).

A lot of the current components in here are quite similar across all platforms. What is the pattern that you guys are thinking for handling stuff where there is more variance?

  • Do as you did with react-native-web and mark certain props as platform specific and abstract/polyfill as best a possible? or...
  • Do you have a base component that implements all common functionality and then the platform specifics are left to the developer to determine?

from react-primitives.

necolas avatar necolas commented on June 29, 2024

TextInput is not a replacement for all HTML inputs, so there's no problem there

from react-primitives.

ekryski avatar ekryski commented on June 29, 2024

So after re-reading #54, now I actually take it back. @lelandrichardson gave an example of other interfaces like console or something where TextInput might not make as much sense.

Given what @lelandrichardson identified in the RFC:

We want to be careful in choosing these "primitives". We need enough to be able to build bigger more complex things, but need to keep it minimal enough so that it's reasonable to expect a new platform to be able to implement the full set of them. I believe things like TextInput may be really important in terms of some platforms, but not others, and so should maybe not be a primitive. This will have to be defined over time, but I think being conservative at first is ideal.

To be honest, I'm actually not sure if I'm even confident about the primitives listed above. For instance, if we wanted to add a platform like "console" and create something like react-curses, it's not clear if Image or Touchable actually make sense. These components were mainly chosen because after creating a fairly complete Component Library for Airbnb in React Native, I noticed that almost 95% of it could be implemented with just these primitives. The four that seem really clear to me are StyleSheet, View, Text, and Platform, but it's a balance.

My thought is that maybe react-primitives should have an Input component which has a subset API and we don't presume that it is a TextInput, Checkbox, Picker/Select, etc. Instead those would be core components (outside of react-primitives) built on top of the Input primitive.

So in this case an Input component would be more like an API and implement:

  • value - getter and setter
  • onChange
  • onLayout
  • onFocus
  • onBlur
  • blur
  • focus
  • clear
  • disabled
  • accessibility attributes

Thoughts??

from react-primitives.

sladiri avatar sladiri commented on June 29, 2024

Hi, I believe that this would be a good way to adopt the accessibility notion of interactive and non-interactive element. So I agree that both Touchable and Input are interactive elements for example.

from react-primitives.

dwicao avatar dwicao commented on June 29, 2024

I created better primitives with support TextInput and FlatList
Also, it's not use react-native-web package
So you can use latest react v16+ and react-native v0.48+
Take a look the repo https://github.com/dwicao/react-universal-rendering

from react-primitives.

mathieudutour avatar mathieudutour commented on June 29, 2024

see #54 for the discussion

from react-primitives.

brodybits avatar brodybits commented on June 29, 2024

I just published react-primitives-input in case it may help anyone.

from react-primitives.

brodybits avatar brodybits commented on June 29, 2024

Might be worth listing it in the Readme alongside react-primitives-svg

I just added them to the description of #136

from react-primitives.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.