Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component-Oriented UI #107

Open
6 of 11 tasks
btzr-io opened this issue Jul 14, 2017 · 30 comments
Open
6 of 11 tasks

Component-Oriented UI #107

btzr-io opened this issue Jul 14, 2017 · 30 comments

Comments

@btzr-io
Copy link
Contributor

btzr-io commented Jul 14, 2017

Simplify UI with modular and reusable components:

Todo

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 14, 2017

https://github.com/workhorsy/comic_book_reader/tree/polymer
is this branch still active?

@workhorsy
Copy link
Owner

This is a good idea. I have been looking into different libraries to do this: angular, react, vue, polymer, et cetera. Unfortunately right now I don't know enough about either to properly use them.

@workhorsy
Copy link
Owner

@btzr-io That polymer branch was accidentally pushed to github. I don't think there is anything even in it. It was just for a test. I'm not even sure if polymer is the right component library to use.

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 15, 2017

Ok, here's a basic implementation of react (not ready yet):
https://github.com/btzr-io/comic_book_reader/tree/react

Run for development

http://localhost:3000/

npm start

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 15, 2017

Now we just need to split UI into react-components:

  • Menu
  • Settings
  • Welcome screen
  • ...

@workhorsy
Copy link
Owner

Since you started porting to React, I've been looking into it more. Surprisingly it has a problem with its license. From what I understand, it uses the 3 clause BSD license with a patent rider clause added:

https://en.wikipedia.org/wiki/React_(JavaScript_library)#Licensing

This would make it so Facebook could terminate someones right to use React, if Facebook thinks they violated one of Facebook's patents. Or if they made a patent claim against Facebook.

It looks like there is a recent effort to fix this:
facebook/react#10191

Until this is resolved, there is no way I can support using React. You can continue changing it to use React if you want. But there is no way I can merge this into master with the license problem.

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 16, 2017

Well, we could use: preact

Preact

Fast 3kB alternative to React, with the same ES2015 API.

And if facebook ever fix that issue we could migrate to react:

Preact-compat

This module is a compatibility layer that makes React-based modules work with Preact, without any code changes.

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 16, 2017

Preact License: MIT License

@workhorsy
Copy link
Owner

I'll look into preact. Thanks

@workhorsy
Copy link
Owner

workhorsy commented Jul 16, 2017

Right now I'm looking at a bunch of different component libraries. Here are a few requirements that will need to be met for us to select one:

  • Must work with Internet Explorer 11, Chrome, Firefox, and Safari
  • Must have a standard open source license such as MIT, GPL, AGPL, Apache, or 3 clause BSD
  • Must be easy to setup on Linux, Mac, and Windows
  • Size of the library does not matter, since we will need 3MB of code to uncompress Rar, Zip, Tar, and view PDF files.

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 16, 2017

I think preact it's a really good option (lightweight, fast, react-compatible, works with redux)
but I only can think about: react, riot, vue.js, polymer

License

Preact License: MIT License

Setup

https://github.com/developit/preact#getting-started

Preact-cli

Start building a Preact Progressive Web App in seconds

https://github.com/developit/preact-cli

Benchmark

http://developit.github.io/preact-perf

Browser support

Browsers

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 16, 2017

Riot.js

Framework size comparison

Riot | 3.6.1 | 10.43kb

Browser support

Riot is supported by all modern browsers and it does not require any additional polyfill

License MIT

@codyhatch
Copy link

This would make it so Facebook could terminate someones right to use React, if Facebook thinks they violated one of Facebook's patents. Or if they made a patent claim against Facebook.

That's incorrect. Facebook cannot terminate your right to use React, they can only terminate your right to use any patents which they may or may not have on the concepts underlying React. And that termination does not happen if Facebook thinks you've violated their patents, only if you make a patent claim against Facebook. That's clarified explicitly here.

Q: Does termination of the additional patent grant in the Facebook BSD+Patents license cause the copyright license to also terminate?

A: No.

@j127
Copy link

j127 commented Jul 16, 2017

they can only terminate your right to use any patents which they may or may not have on the concepts underlying React

I think that it isn't wise to have any of that hanging over software projects, especially as those PATENTS files get scattered throughout dependencies (Immutable, etc.). It creates a power imbalance, since Facebook could violate your patents, and then you would have to figure out what that untested file really means in practice.

Until those PATENTS files are removed, many companies won't be able to use open-source software that depends on Facebook libraries.

@workhorsy
Copy link
Owner

@btzr-io What do you think of polymer 2? It seems to be closest to what vanilla Web Components will be. The only down side I can see is that it still uses Bower, which is basically dead.

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 17, 2017

http://riotjs.com/compare/#polymer

  • It still uses Bower, which is basically dead.
  • Some features used by Polymer are not yet supported natively in all browsers.
  • The Web Components syntax is experimental and complex.

I never used polymer before, I'm looking at the docs...

@workhorsy
Copy link
Owner

It looks like they are comparing polymer 1.8. Polymer 2.0 is a rewrite that is relatively new and allegedly solves performance problems.

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 17, 2017

Polymer(v1.8.0) + WebComponents(v0.7.24) is 6x bigger than Riot

@workhorsy
Copy link
Owner

I'm not really concerned about size, since we will be shipping around 3MB of code just to uncompress Rar, Zip, Tar, and view PDF files.

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 17, 2017

Ok, I'm not sure how to implement it yet...
I rather prefer to use other framework (react / preact as I suggested)
but if you think this is the best option, I'll be glad to help you with the components

@workhorsy
Copy link
Owner

@codyhatch I'm not sure what you mean. I am not a lawyer btw. In my reading of the PATENTS file there are several ways in which the license would terminate unfairly:

  1. They define "Patent Assertion" as "including a cross-claim or counterclaim". Section (i) "against Facebook or any of its subsidiaries or corporate affiliates". Therefore any counter claim against Facebook would terminate the license.

  2. Section (ii) would terminate the license if the user ever sued Facebook for infringing their own patent. This includes any "corporate affiliates". This could be any company Facebook has any relationship with.

  3. Section (iii) says that the license would only NOT expire if the counter claim was "against that party that is unrelated to the Software". I read that as: Counter claims terminate the license if they are against the people that wrote/own the code (Facebook).

I'm sure there are more holes. I seems like this entire PATENTS file is designed to look like it is protecting Facebook from being attacked by patents claims. While in reality it is filled with double negatives, that stop people from defending themselves from attack by Facebook.

The license granted hereunder will terminate, automatically and without notice,
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
directly or indirectly, or take a direct financial interest in, any Patent
Assertion: (i) against Facebook or any of its subsidiaries or corporate
affiliates, (ii) against any party if such Patent Assertion arises in whole or
in part from any software, technology, product or service of Facebook or any of
its subsidiaries or corporate affiliates, or (iii) against any party relating
to the Software. Notwithstanding the foregoing, if Facebook or any of its
subsidiaries or corporate affiliates files a lawsuit alleging patent
infringement against you in the first instance, and you respond by filing a
patent infringement counterclaim in that lawsuit against that party that is
unrelated to the Software, the license granted hereunder will not terminate
under section (i) of this paragraph due to such counterclaim.

A "Necessary Claim" is a claim of a patent owned by Facebook that is
necessarily infringed by the Software standing alone.

A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
or contributory infringement or inducement to infringe any patent, including a
cross-claim or counterclaim.

https://github.com/facebook/react/blob/master/PATENTS

It is also possible that my understanding may be wrong. I do not have the time or resources to deal with any patent shenanigans. I do not support software patents. Until the React the PATENTS file is removed, and React is placed under a standard open source license, I won't be using it.

That is just my opinion, feel free to disagree.

@workhorsy
Copy link
Owner

@btzr-io I'll have to look at preact and polymer more later tonight.

@workhorsy
Copy link
Owner

I spent a little bit of time making a simple polymer 2.0 and preact website. I had huge problems with polymer:

  • Bower is deprecated and gives all kinds of warnings
  • Styling child elements is hard because shadow DOM is like an extra phantom element wrapping everything
  • Polymer does not have its own libraries for state, routing, et cetera. So people just end up using react libraries like redux anyway
  • The way Google segments polymer elements into Iron, Paper, Neon, Gold is very strange and confusing to me.
  • Very few people are using polymer. Even fewer are using polymer 2.0
  • Most of the ecosystem in Polymer seems to come from Google (or people with a vested interest in Google), while react/preact ecosystem seems to be more organic.

I don't want to crap all over polymer too much. I think it does have a lot of great ideas, and it is more like what I want out of standard WebComponents.

Anyway. Preact looks like it will be good enough for now. We can always move to something else, or go back to pure JavaScript if this fails. No big deal.

I started on a basic Preact port here:
https://github.com/workhorsy/comic_book_reader/tree/preact

@btzr-io
Copy link
Contributor Author

btzr-io commented Jul 20, 2017

Nice, I tried to implement translations with preact:
https://github.com/Download/preact-i18nline

But there is an issue with preact-i18nline:
Download/preact-i18nline#6
Download/i18nline#10

@workhorsy
Copy link
Owner

Cool. I should probably use preact-i18nline rather than rolling my own translation code.

@Download
Copy link

Hi guys. I just noticed this issue because I have picked up work on preact-i18nline again. If you do decide to use it, the coming weeks will be a good time to experiment with it and give some feedback about what is not working right for you, what you think should change or works well etc. So I can incorporate this feedback in my work I'm doing now.

@workhorsy
Copy link
Owner

Thanks. I haven't had any time to work on the comic book reader. Hopefully someone can continue porting to Preact.

@btzr-io
Copy link
Contributor Author

btzr-io commented Mar 30, 2018

@Download awesome, I'm currently working on some components and they have a tooltip assigned with the title attribute, does this work with preact-i18nline or just the text inside the button:

	<button class={style.button} title={label} onClick={action}>
        {...}
       </button>

@Download
Copy link

title works I think. There is a whitelist of HTML attributes that get translated as well as the contents of the element.

@Download
Copy link

Setting up the project is tricky still at the moment. So let me know if you need help. The docs are a bit out-of-date as well atm.

I'm working on making it simpler to drop into a project and as part of that work will also update the README. Until then I would advice you to keep an eye on https://github.com/backstopmedia/preact-book-example. This is an example project using Preact, created with Preact CLI. I will be pushing a branch there soon with the customizations needed to get it to work with preact-i18nline.

@btzr-io btzr-io mentioned this issue Mar 31, 2018
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants