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

Adds docs about templating, minor housekeeping #180

Merged
merged 6 commits into from
Oct 11, 2024
Merged

Conversation

klebba
Copy link
Collaborator

@klebba klebba commented Apr 26, 2024

Covers templating in more detail. Creates doc directory.

return html`
<select name="my-options">
${repeat(options, option => option.id, option => html`
<option value="${option.value}" ?selected="${option.id === selectedId}">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TODO: does this example work? #179 tracks a potential problem

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it works now — but we should use map

@klebba klebba force-pushed the minor-housekeeping branch 3 times, most recently from 4b1b285 to 50454ab Compare April 26, 2024 19:41
doc/TEMPLATES.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@theengineear theengineear left a comment

Choose a reason for hiding this comment

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

Just left some nit-picks here and there. Have a look at your leisure 🤙

One thought though — should we call it /docs? I find the singular there a little weird, but that’s just a minor preference thing.

doc/TEMPLATES.md Outdated
| attribute | `<div foo="${bar}">` |
| attribute (boolean) | `<div ?foo="${bar}">` |
| property | `<div .foo="${bar}">` |
| text | `<div>${foo}</div>` |
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should just say content here? I like text / content? I find the additional line slightly confusing.

doc/TEMPLATES.md Outdated
| text | `<div>${foo}</div>` |
| content | `${foo}` |

Equivalent to:
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: “Equivalent” might be too strong a word. Maybe “Compare with:” or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

how about

emulates

- If the features of our custom element are really basic, we could do this easily without any libraries. As your features become more complex some common concerns and conveniences start to emerge (in our case these items became the `x-element` project).
- Regardless of the manner in which the element has been defined, the current page context now guarantees a relationship between the new tag `<my-custom-element>` and the class `MyCustomElement`. This concept is critical to understand because this normalization liberates developers from the need to choose a single framework (or framework version) to define their features.
- Note that it is possible to create a DOM node named `my-custom-element` _before_ the custom element has been defined via `customElements.define('my-custom-element', MyCustomElement)`. This can be done using declarative HTML like `<my-custom-element></my-custom-element>` or with imperative API calls like `const el = document.createElement('my-custom-element')`. However at this stage the `my-custom-element` DOM node is functionally equivalent to a `span`.
- When `my-custom-element` is eventually defined within the page context all instances of that element are instantly "upgraded" using the `MyCustomElement` class. This is the second important concept: DOM composition is independent from custom element definition. This decoupling enables composible feature developers to have flexibility when selecting a DOM template engine. Because child nodes within `my-custom-element` can be fully encapsulated using the [Shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM) creating and managing them becomes an implementation detail that template engines have no awareness of.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like some of the discussion in here is more about element lifecycle versus choosing a template engine. Might want to figure out if some of this makes sense elsewhere?


* Custom elements are not a framework (native feature)
* Custom elements provide DOM, JS and CSS encapsulation (native feature)
* Developers can choose a framework to manage the DOM within their custom element
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just another thought on this — I think this file is trying to cover both picking a template engine and interoperability. IMO, these are kinda different topics. I kinda get why you’re trying to cover them both in here, but I also find it confusing because it conflates the two concepts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thats good feedback — shall we defer to a future revision?

doc/TESTING.md Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

The way I typically test locally is to npm start, then, visit the /test page in the browser. Can we cover that case in here as well?

"tap-parser": "^15.3.1"
"eslint": "^9.8.0",
"puppeteer": "^23.0.2",
"tap-parser": "^18.0.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hrm, they sorta bundled all the tapjs stuff into a single changelog. It’s much harder to tell exactly what changed related to the tap-parser library. Anyways, it should still be working with TAP 14 output, so that should still interop with x-test.

Copy link
Collaborator

@theengineear theengineear left a comment

Choose a reason for hiding this comment

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

LGTM!

@klebba klebba merged commit 6db5f79 into main Oct 11, 2024
1 check passed
@klebba klebba deleted the minor-housekeeping branch October 11, 2024 18:43
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