devlinjunker / template.webpack.fend

Example using Webpack to build a FEND Browser App (with HTML/CSS/JS and Image files)
http://devlinjunker.github.io/template.webpack.fend
MIT License
3 stars 2 forks source link

Components (HTML/JS) #11

Closed devlinjunker closed 4 years ago

devlinjunker commented 4 years ago

Description

Trying to break out separate UI sections and code into smaller "components" that can be added to HTML Pages and are re-usable. We want to also maybe include each of these in the styleguide (todo later)

Set up a basic todo list example app in another folder with a new js entry point

It seems like we can have two different types of components/templates

  1. static -- that are built during the webpack compile and included in the page (e.g. header)
  2. dynamic -- that are imported/required in javascript files and render html and change based on the users actions/setting (e.g. todo and add-input)

Important changes here

Related

N/A

Visual

Screenshot 2020-05-03 15 04 01

TODO

devlinjunker commented 4 years ago

I think we might want to use this webpack-underscore-loader for the static templates (may want to rename the top level components/ directory to something like static/.

Then we can use handlebars maybe for dynamic templates/components, this will make it easy to use Fractal for a styleguide

devlinjunker commented 4 years ago

It looks like handlebars can be used for both the compiled “static” and rendered “component” templates (again I think we should make the difference being wether or not javascript is included/needed for them)

In handlebars they are called dynamic partials, where we can pass values in through the handlebar partial parameters

devlinjunker commented 4 years ago

So handlebars is great for templating the HTML and structure of the page.... However for now, I am just using vanilla JS and functions to create the DOM and attach handlers to elements but this still feels clunky... https://github.com/devlinjunker/template.webpack.fend/pull/11/files#diff-99f85621a787732f493ae3952ad09617R25

https://github.com/hadijaveed/reactive-handlebars looks interesting for managing handlers and updating the DOM when properties change... added some todos about that

also https://medium.com/@hadijaveed/writing-reactive-templates-with-handlebarsjs-c163a2816510

devlinjunker commented 4 years ago

Got svg icons to be inlined during build process on simple handlebars partials: https://github.com/devlinjunker/template.webpack.fend/pull/11/commits/36d682405d656eb05638732d3175364cc237628a

Quite the task to figure out how to precompile the handlebars partials to in-line svgs

Q: Will this work on larger things?

Tests:

devlinjunker commented 4 years ago

Screenshot 2020-05-07 20 17 34

Styling:

devlinjunker commented 4 years ago

TODO Create Separate PRS into this one for each new idea (help keep code changes small -- eventually this will be a huge PR but you can go through smaller ones to see the individual changes)

devlinjunker commented 4 years ago

Q: Should we just create html-inline-loader (html-svg-inline-loader?)

devlinjunker commented 4 years ago

progress report: Screenshot 2020-05-16 18 53 01

Screenshot 2020-05-16 18 12 28

devlinjunker commented 4 years ago

Attempting Partial Linting:

./src/components/list/list-item.hbs 2:2 error Handlebars partials are not supported: "{{> (lookup . 'template')" at L2:C2 undefined



- looked into html linters but couldn't find any that looked like small libraries and/or didn't require access to the internet to validate