UI Architecture #2
ctapobep
started this conversation in
Conventions & Approaches
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Directory structure
For a good example of page structure & components look in Peaksel at
GlobalSettings
page.Components
A typical component consist of 2 JS files (XxxCmp and XxxHtml):
HTML Layout
<div>
and<span>
must be our last resort.<some-component>
. This isn't a Web Component (see below)! Browsers treat unrecognized tags just fine. But we have to have at least one-
in the tag. This is the convention that separates browser-native tags from our custom ones.document.queryBySelector('.className')
. Prefertag-name
for custom components,name
or other attributes for standard components. Classes should be used only in CSS.JS Modules
In the new code we're supposed to use JavaScript modules:
import
instead ofrequire()
, as well asexport and export default
.Approaches that we DON'T use
Why we don't use MVC frameworks like React, Angular or Vue
We don't use MVC frameworks on UI in order to:
Having said that, there are some things that we're missing out on:
Why not Web Components
Web Components is an attempt of to implement HTML-native components. We define a custom tag
<some-component>
and then separately in JS we define which JS class implements it. Unfortunately, this approach has big problems:So instead to isolate the styles of components we use BEM.
Beta Was this translation helpful? Give feedback.
All reactions