-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Nested components proposal #265
Draft
joshiggins
wants to merge
16
commits into
adamghill:main
Choose a base branch
from
joshiggins:deep-nesting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0de6ee1
make template library available in test templates
joshiggins e04be18
add basic test for render 3 layers of components
joshiggins bf17087
always include script tags from child components, defer if parent is set
joshiggins f75fc9c
check child has deferred attrs before adding them
joshiggins ea3adb9
Bump to 0.33.0.
adamghill 1d60a29
add optional filter arg to utils.walk and two filters
joshiggins 9021281
use filter to skip nested components in refreshEventListeners
joshiggins c57aa5d
Slight formatting changes.
adamghill 6d33325
Add button below nested component.
adamghill 5156374
Add skipped test that is incomplete.
adamghill 69798d3
docs: update README.md [skip ci]
allcontributors[bot] 0d062b7
docs: update .all-contributorsrc [skip ci]
allcontributors[bot] 655aeac
Add more urls.
adamghill d4044b9
Add example for deeply nested components.
adamghill ffd91a3
Merge branch 'master' into deep-nesting
joshiggins 1dc2c6a
update example based on kwargs proposal
joshiggins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django_unicorn.components import UnicornView | ||
from example.coffee.models import Flavor | ||
|
||
|
||
class ActionsView(UnicornView): | ||
model: Flavor = None | ||
is_editing = False | ||
|
||
def edit(self): | ||
self.is_editing = True | ||
|
||
# this doesn't do what you expect because resulting dom is scoped to | ||
# this component and the parent component won't get morphed | ||
self.parent.is_editing = True | ||
|
||
def cancel(self): | ||
self.is_editing = False | ||
|
||
def save(self): | ||
self.model.save() | ||
self.is_editing = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<td> | ||
{% if is_editing %} | ||
<button unicorn:click="save">Save</button> | ||
<button unicorn:click.discard="cancel" unicorn:partial.key="{{ model.pk }}">Cancel</button> | ||
{% else %} | ||
<button unicorn:click="edit" unicorn:partial.key="{{ model.pk }}">Edit</button> | ||
{% endif %} | ||
</td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,6 @@ <h3>{{ name }}</h3> | |
{% endfor %} | ||
</table> | ||
|
||
<button unicorn:click="load_table">Load table</button> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshiggins So, I tried to add an example and kind of stumbled at this point. Your code "works" so I could merge it in as is, but
Unicorn
doesn't handle child components in a very intuitive way (I don't think). I'd love to hear any ideas about how this might work better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've put some ideas in #253, makes sense to hold this PR off for a bit since it really only solves naive use case where components are nested but otherwise independent.