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

Create the ucdlib-properties element #57

Open
jrmerz opened this issue Jun 6, 2022 · 2 comments
Open

Create the ucdlib-properties element #57

jrmerz opened this issue Jun 6, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@jrmerz
Copy link
Contributor

jrmerz commented Jun 6, 2022

It would be nice for server side renders sites (PHP/Twig, Express with templating) to be able to hydrate complex properties of a webcomponent without using javascript. Example:

<ucdlib-my-cool-component>
  <ucdlib-properties type="json">
    {"testing":"ok", "complex" : {"values": 1, "can-be": "nested"}}
  </ucdlib-properties>
</ucdlib-my-cool-component>

In the above example, properties testing and complex should be set on ucdlib-my-cool-component when ucdlib-my-cool-component is first attached to the DOM assuming ucdlib-my-cool-component implements the SSRPropertiesController (see below).

General component spec:

  • The ucdlib-properties element should NEVER display, so display: none should be set.
  • The ucdlib-properties element itself doesn't do anything but store config data
  • A type property should set the format, eg yaml, json, etc. For v1 only JSON will be supported (and should be the default type parameter value), but want to leave options open.
  • A lit controller SSRPropertiesController should be created to hydrate an set the properties from the ucdlib-properties element to the parent: https://lit.dev/docs/composition/controllers/
  • The controller should only fire once, when the element is first attached
  • The controller should only check direct children elements for ucdlib-properties elements. We will allow for multiple, but order will matter.

Note. This is using connected as the fire event and not the constructor due to the parent constructor element possibly firing before children are registered.

@jrmerz jrmerz added the enhancement New feature or request label Jun 6, 2022
@UcDust
Copy link
Collaborator

UcDust commented Jun 16, 2022

Justin/Steve mentioned to add this as well so no ugly flashes are rendered before the custom element is defined.

@UcDust
Copy link
Collaborator

UcDust commented Jun 21, 2022

Created a PR / code review here.

UcDust added a commit that referenced this issue Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants