-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
App skeleton #1
App skeleton #1
Conversation
…ml) to webpack config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, so we got together and went through the code. We just commented on everything that we didn’t understand — that doesn’t mean it’s wrong.
@developit please take a look and humor our ignorance. We kept the comments quite terse because we wanted to keep going while we are all 3 in the same physical room.
But, since this is the basis for the entire project, we just wanna make sure we all understand it and feel comfortable working with it.
.babelrc
Outdated
{ | ||
"loose": true, | ||
"uglify": true, | ||
"modules": "commonjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for? Isn’t webpack taking care of all module-y stuff?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - this was here for when I was trying to do prerendering without bundling via Webpack, but I've abandoned that attempt.
- remove "modules" option
webpack.config.js
Outdated
@@ -0,0 +1,245 @@ | |||
let fs = require('fs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- We should be using
const
here.
config/watch-timestamps-plugin.js
Outdated
|
||
module.exports = WatchTimestampsPlugin; | ||
|
||
function WatchTimestampsPlugin(patterns) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use real classes here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, they should be Node 4+.
- Use classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are all on Node 8, no? We should use all the goodness — our build system is not gonna turn into a library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup.
config/watch-timestamps-plugin.js
Outdated
@@ -0,0 +1,23 @@ | |||
let fs = require('fs'); | |||
|
|||
module.exports = WatchTimestampsPlugin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d really like a comment to explain what this does 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I'll find the GH issue I retrofitted this from.
config/watch-timestamps-plugin.js
Outdated
WatchTimestampsPlugin.prototype.apply = function (compiler) { | ||
compiler.plugin('watch-run', (watch, callback) => { | ||
let patterns = this.patterns; | ||
let timestamps = watch.fileTimestamps || watch.compiler.fileTimestamps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these two alternatives?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Webpack 3 and prior vs Webpack 4+. Also I believe it may vary depending on whether the plugin is invoked in a child compiler instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above — we decide what WebPack version we use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - likely this came from before I committed to v4.
- Remove webpack 3 & prior stuff from WatchTimestampsPlugin
src/components/app/index.tsx
Outdated
files: [fileObj] | ||
}); | ||
|
||
let fr = new FileReader(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jake says you should new new Response()
here (example)
I think we should move this into a util
modules as loadFileAsBlob()
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason I never remember that Response accepts a Blob.
-
MoveloadFileAsBlob()
to a util - Use
new Response(blob).text()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up being as simple as new Response(file).text()
, not worth a util.
src/components/app/index.tsx
Outdated
|
||
enableDrawer = false; | ||
|
||
openDrawer = updater(this, 'showDrawer', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be proper methods. We can use TypeScript decorators to tie in stuff like updater()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try making a decorator. Personally I've been gravitating towards using a "store" to house data + mutators/actions. I also threw some ideas around with @davideast last week for simplifying state+selectors, and he published something called selectrify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just turned these into methods for now.
src/components/app/index.tsx
Outdated
render({ url }, { showDrawer, showFab, files }) { | ||
if (showDrawer) this.enableDrawer = true; | ||
|
||
if (showFab===true) showFab = files.length>0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
if(showFab)
? :D
src/components/app/index.tsx
Outdated
<div id="app" class={style.app}> | ||
<Fab showing={showFab} /> | ||
|
||
<Header toggleDrawer={this.toggleDrawer} loadFile={this.loadFile} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is toggleDrawe
an event handler? If so, we probably wanna call it onToggleDrawer
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same for the other eventhandler-y stuff)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you mean the left-hand side? If so I agree!
-
onToggleDrawer
src/components/app/index.tsx
Outdated
</div> | ||
|
||
{/* This ends up in the body when prerendered, which makes it load async. */} | ||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn’t make it load async, it just renders what is before it, and even that is not very widely implemented. We should figure out how we handle fonts in this project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, plus without prerendering my comment is inaccurate anyway (though I believe stylesheets added by script are async, unlike those dumped into body).
- move it
… up files, so we need to explicitly feed it a files list via `tsconfig.json`.
Alrighty @surma - that should be all the feedback acted on! |
…in order to defer binding until there is an instance to bind to, the simpler implementation actually bound methods to the prototype itself.
… config, drop threaded type checking (couldn't get it working)
|
||
let html = dom.serialize(); | ||
callback(null, html); | ||
// return html = `module.exports = ${JSON.stringify(html)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these comments all go?
.content { | ||
flex: 1 1 auto; | ||
contain: size layout style; | ||
overflow: auto; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really wanna scroll on content? It usually ends up causing problems. I’d prefer scrolling on body and having sidebar/topbar position: fixed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we've got too much layout in the PR. If it's either-or, I'd rather we landed something that simply demonstrated that CSS could be included, and didn't otherwise worry about layout.
Layout is something we can plan & do in another PR.
import MdlDrawer from 'preact-material-components-drawer'; | ||
import 'preact-material-components/Drawer/style.css'; | ||
import List from 'preact-material-components/List'; | ||
// import 'preact-material-components/List/style.css'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
import { When, bind } from '../../lib/util'; | ||
import Fab from '../fab'; | ||
import Header from '../header'; | ||
// import Drawer from 'async!../drawer'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
global.history = {}; | ||
global.location = { href: url, pathname: url }; | ||
|
||
// let app = require('app-entry-point'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
@@ -0,0 +1,20 @@ | |||
@import '~style/helpers.scss'; | |||
|
|||
// :global { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
</head> | ||
<body> | ||
<div id="app" prerender></div> | ||
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" /> --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
@@ -0,0 +1,27 @@ | |||
// @import './material-icons.scss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
font-weight: 400; | ||
src: local('Material Icons'), | ||
local('MaterialIcons-Regular'), | ||
url(https://example.com/MaterialIcons-Regular.woff2) format('woff2'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quotes like in index.scss
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this PR should contain anything like icon fonts.
user-select: none; | ||
-webkit-user-select: none; | ||
user-drag: none; | ||
-webkit-user-drag: none; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use something like autoprefixer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should decide that as part of this PR.
In general, I think this PR is trying to do too much. We don't really need large parts of the app complete, we just need a build system that supports a mix of assets, preact & web components. I worry that by bringing in things like icon fonts, and making layout decisions, is just delaying this being able to land. Any chance of keeping it to the basics? Then we can start planning and dividing up the rest of the work. |
I’m absolutely fine with punting on the specifics and picking those back up when they get touched. Mostly want the dead code gone, tho. |
|
||
render({ value, children = [] }: WhenProps, { ready }: WhenState) { | ||
let child = children[0]; | ||
if (value && !ready) this.setState({ ready: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of ready
here? Can't you just test value
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would create an infinite loop if the component loaded was undefined
<link rel="manifest" href="/manifest.json"> | ||
</head> | ||
<body> | ||
<div id="app" prerender></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why invent an attribute here rather than use a class name (or a data attribute)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in subsequent branch (prerender)
note: rest of the stuff started here is getting its own PR's. |
No description provided.