peer-base / peer-pad

đź“ť Online editor providing collaborative editing in really real-time using CRDTs and IPFS.
https://peerpad.net
MIT License
678 stars 57 forks source link

Break out react bindings for codemirror <-> peer-star-app into a separate npm module #249

Open jimpick opened 5 years ago

jimpick commented 5 years ago

It would be nice to figure out how to build re-usable UI components that include the code needed to bind to peer-star-app collaborations.

The codemirror editor used in peer-pad is fairly self-contained, and has working bindings. I think it's a good candidate to break out into a re-usable component.

pgte commented 5 years ago

I agree, go for it! :)

jimpick commented 5 years ago

I need to review the current best practices for distributing react components. Can anybody think of a good modern example to pattern off of?

pgte commented 5 years ago

/cc @satazor

satazor commented 5 years ago

Will you ship styles (CSS)?

jimpick commented 5 years ago

I believe codemirror has a CSS file that comes along with it, so we'd have to figure out how to ship that along with it ... because it's wrapping a third-party component that isn't react based, it's a perhaps a more challenging starting problem than if we just had a pure react component.

satazor commented 5 years ago

Alright. For reusable modules I usually don’t include the styles implicitly but rather document which file needs to be included. Another option is to explicitly import it and document that a css loader (in case of webpack) or similar needs to be configured in the app.

parkan commented 5 years ago

@satazor would a CSS module make sense here? it's a bit of a weird case where it sort of should be separate from the parent styling conceptually, but not to the extent of using inline CSS

satazor commented 5 years ago

Yes we can indeed generate a CSS module, that is, a CSS file where selectors are hashed based on its contents. The question is how to compile the JS file in such a way that the selectors mappings are correctly included in the build. I haven’t done this yet but should be fairly easy with webpack’s css-loader.