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

Web components #8

Open
hexus opened this issue Mar 16, 2019 · 4 comments
Open

Web components #8

hexus opened this issue Mar 16, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@hexus
Copy link
Owner

hexus commented Mar 16, 2019

A set of web components could be used to either fully render a form, or selectively render parts of a form. Using field definitions for layout is then optional.

<pragma-form> would be a decorator element that propagates field data to any relevant children, internally managing a Pragma Form instance.

<pragma-form fields="..." data="...">
  <form>
    <div class="saves">
      <!-- Automatically render a subset of fields -->
      <pragma-fields path="defense.saves"/>
    </div>

    <!-- Manually lay out elements for fields -->
    <textarea name="defense.notes"></textarea>

    <!-- Define layout for field templates -->
    <template name="templates.spell">
      <div class="spell">
        <input type="text" name="templates.spell.name"/>
        <!-- ... -->
      </div>
    </template>
  </form>
</pragma-form>

<pragma-form> and <pragma-fields> elements could optionally load field sets by themselves.

<pragma-form src="/fields.json" data="...">
  <pragma-fields/>
</pragma>

<pragma-fields src="/fields.yaml" path="defense.saves"/>
@hexus hexus added the enhancement New feature or request label Mar 16, 2019
@hexus hexus self-assigned this Oct 30, 2019
@hexus
Copy link
Owner Author

hexus commented Jan 23, 2020

Allowing layout to be defined separately means data structure doesn't need to be tied to layout.

This may add complexity, but improves versatility and separation of concerns (data vs. presentation). It means that markup wouldn't be the only way to define form layout; it can be data-driven.

<pragma-fields fields="..." layout="..." data="..."></pragma-fields>

If no layout is provided, it can be generated from the field set.

The real question is how different a layout object structure would look, and what they would be allowed to override. For example, it'd make sense for a layout field to override a field's input type, but probably not its actual data type.

@hexus
Copy link
Owner Author

hexus commented Mar 2, 2020

Unsolved problem

Integrating Stencil with the webpack build process to avoid two separate pipelines and NPM projects. Ouch.

Unexplored problem

Mapping fields, in <pragma-form>, to arbitrary HTML elements. 🤔

Perhaps only:

  • Map to known HTML5 inputs
  • Also map to the field property of any element in case it understands Pragma fields. Doesn't feel great, but what else can be done?

@hexus
Copy link
Owner Author

hexus commented Sep 6, 2020

A registerFieldElementMapping() method, or similar, on <pragma-form> might be the best way to do the latter, above. It would allow field mappings for custom elements can always be defined somehow.

hexus added a commit that referenced this issue Sep 6, 2020
Lots of components (pragma-fields, pragma-section, pragma-list, pragma-list-item) need hacks to force providing new field references, otherwise they don't re-render children
hexus added a commit that referenced this issue Sep 29, 2020
hexus added a commit that referenced this issue May 1, 2021
hexus added a commit that referenced this issue May 1, 2021
hexus added a commit that referenced this issue May 1, 2021
Sometimes you've got to break things to fix things
hexus added a commit that referenced this issue May 3, 2021
Renamed field properties: input -> tag, name -> label
hexus added a commit that referenced this issue May 3, 2021
This caching needs rethinking, weird how we didn't see this with Riot but it's probably because Stencil is updating the correct number of times on load: once.
@hexus
Copy link
Owner Author

hexus commented May 8, 2021

Extending built-ins with Stencil: ionic-team/stencil#1382 (comment)

hexus added a commit that referenced this issue May 8, 2021
hexus added a commit that referenced this issue May 9, 2021
Now to get adding them to a list working, and clean up the component code quite a bit...
hexus added a commit that referenced this issue May 9, 2021
Started thinking about the <pragma-picker> add button; this could be a separate field to be honest
hexus added a commit that referenced this issue May 17, 2021
Adding spells now works
hexus added a commit that referenced this issue Aug 7, 2021
Also started updating <pragma-picker>
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

1 participant