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

App skeleton #1

Merged
merged 33 commits into from
Apr 17, 2018
Merged

App skeleton #1

merged 33 commits into from
Apr 17, 2018

Conversation

jakearchibald
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@surma surma left a 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",
Copy link
Collaborator

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?

Copy link
Collaborator

@developit developit Mar 26, 2018

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

@@ -0,0 +1,245 @@
let fs = require('fs');
Copy link
Collaborator

@surma surma Mar 26, 2018

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.


module.exports = WatchTimestampsPlugin;

function WatchTimestampsPlugin(patterns) {
Copy link
Collaborator

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?

Copy link
Collaborator

@developit developit Mar 26, 2018

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

Copy link
Collaborator

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup.

@@ -0,0 +1,23 @@
let fs = require('fs');

module.exports = WatchTimestampsPlugin;
Copy link
Collaborator

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 😅

Copy link
Collaborator

@developit developit Mar 26, 2018

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.

WatchTimestampsPlugin.prototype.apply = function (compiler) {
compiler.plugin('watch-run', (watch, callback) => {
let patterns = this.patterns;
let timestamps = watch.fileTimestamps || watch.compiler.fileTimestamps;
Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@developit developit Mar 26, 2018

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

files: [fileObj]
});

let fr = new FileReader();
Copy link
Collaborator

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.

Copy link
Collaborator

@developit developit Mar 26, 2018

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.

  • Move loadFileAsBlob() to a util
  • Use new Response(blob).text()

Copy link
Collaborator

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.


enableDrawer = false;

openDrawer = updater(this, 'showDrawer', true);
Copy link
Collaborator

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()

Copy link
Collaborator

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.

Copy link
Collaborator

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.

render({ url }, { showDrawer, showFab, files }) {
if (showDrawer) this.enableDrawer = true;

if (showFab===true) showFab = files.length>0;
Copy link
Collaborator

@surma surma Mar 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • if(showFab)? :D

<div id="app" class={style.app}>
<Fab showing={showFab} />

<Header toggleDrawer={this.toggleDrawer} loadFile={this.loadFile} />
Copy link
Collaborator

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?

Copy link
Collaborator

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)

Copy link
Collaborator

@developit developit Mar 26, 2018

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

</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" />
Copy link
Collaborator

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.

Copy link
Collaborator

@developit developit Mar 26, 2018

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

@developit
Copy link
Collaborator

Alrighty @surma - that should be all the feedback acted on!


let html = dom.serialize();
callback(null, html);
// return html = `module.exports = ${JSON.stringify(html)}`;
Copy link
Collaborator

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;
Copy link
Collaborator

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.

Copy link
Collaborator Author

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';
Copy link
Collaborator

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';
Copy link
Collaborator

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');
Copy link
Collaborator

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 {
Copy link
Collaborator

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" /> -->
Copy link
Collaborator

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';
Copy link
Collaborator

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'),
Copy link
Collaborator

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?

Copy link
Collaborator Author

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;
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

@jakearchibald
Copy link
Collaborator Author

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.

@surma
Copy link
Collaborator

surma commented Apr 9, 2018

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 });
Copy link
Collaborator Author

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?

Copy link
Collaborator

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>
Copy link
Collaborator Author

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)?

Copy link
Collaborator

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)

@developit
Copy link
Collaborator

note: rest of the stuff started here is getting its own PR's.

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

Successfully merging this pull request may close these issues.

3 participants