Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Support attribute sourcing #30

Merged
merged 7 commits into from
Jun 10, 2022
Merged

Support attribute sourcing #30

merged 7 commits into from
Jun 10, 2022

Conversation

ockham
Copy link
Collaborator

@ockham ockham commented May 25, 2022

Here's a very bare-bones, WIP, implementation of attribute sourcing.

For more background, refer to @luisherranz' great video in #27.

Feel free to pick it up and play with it; otherwise, I'll continue working on it on Friday 🙂

image

@ockham ockham mentioned this pull request May 25, 2022
)

for ( const attr in sourcedAttributes ) {
attributes[ attr ] = matcherFromSource( sourcedAttributes[ attr ] )( this );
Copy link
Collaborator Author

@ockham ockham May 25, 2022

Choose a reason for hiding this comment

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

matcherFromSource is a wrapper around hpq's parsing functions (e.g. text or html) , which expects a DOM element tree. Good thing that this is one! 😄

Copy link
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

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

This is looking great 🙂

src/gutenberg-packages/utils.js Outdated Show resolved Hide resolved
@ockham
Copy link
Collaborator Author

ockham commented Jun 7, 2022

I was originally planning to add support for more attribute sources here (html, query, meta, etc -- see), but now I'm thinking it might not add much value to the proof-of-concept (and just amount to copying code over from GB).

So maybe this is ready for review/merging?

@ockham ockham marked this pull request as ready for review June 7, 2022 16:07
Copy link
Member

@luisherranz luisherranz left a comment

Choose a reason for hiding this comment

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

Sure, approved so you can merge as you please 🙂

However, would you mind adding a non-sourced attribute before you do so? Just a simple one can do. If not, the demo won't ship any non-sourced attribute anymore.

@ockham
Copy link
Collaborator Author

ockham commented Jun 10, 2022

Sure, approved so you can merge as you please 🙂

However, would you mind adding a non-sourced attribute before you do so? Just a simple one can do. If not, the demo won't ship any non-sourced attribute anymore.

Thanks, good point! I made the counter value an attribute (i.e. it's now possible to set the initial counter value from the editor). (Changing it on the frontend won't persist it, though.)

@ockham
Copy link
Collaborator Author

ockham commented Jun 10, 2022

Okay, Imma go ahead and merge this 🙂

@ockham ockham merged commit 4631ad7 into main Jun 10, 2022
@ockham ockham deleted the try/sourced-attributes branch June 10, 2022 14:13
@luisherranz
Copy link
Member

Awesome. Thank you, Bernie 🙂

@luisherranz luisherranz changed the title Experiment with attribute sourcing Support attribute sourcing Jun 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants