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

Closes: #39 Add a way to specify the position of child components. #70

Merged
merged 25 commits into from
Sep 8, 2023

Conversation

SuelenKarbivnychyy
Copy link
Contributor

Added special tag which specify position of inner content of it's parent component

In component class I defined new list to store inner content of special tag . I also defined a variable called is_costum "meaning that is our tag" to be True. In parser.py I check if the parent node is our special tag '', and if it's true, the current component is appended to the inner content list instead of the children list. Then in the dom_methods.py I render the component properties of inner_content list. For every child in children list, I check if the child tag is our , and if it's true, I added the component inner content to its own properties.

BREAKING CHANGE: this closes issue #39

@SuelenKarbivnychyy
Copy link
Contributor Author

@sansyrox Please review.

.gitignore Outdated Show resolved Hide resolved
starfyre/component.py Outdated Show resolved Hide resolved
Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

Hey @SuelenKarbivnychyy 👋

Thank you for the PR. I have left some reviews on the PR.

Also, I don't think we require the test/ folder in the repo. Can you please remove it?

Do let me know if you require any more information from me 😄

@SuelenKarbivnychyy
Copy link
Contributor Author

SuelenKarbivnychyy commented Aug 1, 2023

Do let me know if you require any more information from me 😄

Hey, Yes. I'll remove it. I'm still getting use to Commitzen 😄
Also, Would you be ok of using as our special tag, or would you suggest other name?

starfyre/dom_methods.py Outdated Show resolved Hide resolved
Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

Hey @SuelenKarbivnychyy 👋

Thank you for answering the questions. I have some suggestions for the design. Do let me know if you have any questions 😄

starfyre/dom_methods.py Outdated Show resolved Hide resolved
starfyre/dom_methods.py Outdated Show resolved Hide resolved
starfyre/parser.py Outdated Show resolved Hide resolved
starfyre/component.py Outdated Show resolved Hide resolved
starfyre/component.py Outdated Show resolved Hide resolved
starfyre/dom_methods.py Outdated Show resolved Hide resolved
Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

Hey @SuelenKarbivnychyy 👋

Great work! I have some suggestions 😄

Do let me know if you have questions from me :D

…: Added special tag <slot> which specify position of inner content of it's parent component

In component class I defined new list to store inner content of special tag <slot>. I also defined a variable called is_costum "meaning that is our <slot> tag"  to be True. In parser.py I check if the parent node is our special tag '<slot>', and if it's true, the current component is appended to the inner content list instead of the children list. Then in the dom_methods.py I render the component properties of inner_content list. For every child in children list, I check if the child tag is our <slot>, and if it's true, I added the <slot> component inner content to its own properties.

BREAKING CHANGE: this closes issue 39
…hild

Implemented code with a variable is_slot_used = False. Then if childrenElement.tag is the <slot>, I set is_slot_used equals True. Then if the <slot> tag is not used in the component definition but we have content in inner_html, that means the user forgot "or is not aware" that he should specify where the children content should be added. Based on that I raise an error to let user knows that he is missing the <slot> tag.
…updated the code to instead of raising a error when <slot> is not found, update the html, js and css anyway
…ation that will be deleted before merging the pr
…cture to follow design best practice

implemented the code to make usage of children list instead of using a separate list to handle the custom component content we want to add to the slot
@sansyrox
Copy link
Member

@SuelenKarbivnychyy 👋

Updated. Let me know if you still have any questions.

starfyre/parser.py Outdated Show resolved Hide resolved
starfyre/parser.py Outdated Show resolved Hide resolved
starfyre/parser.py Outdated Show resolved Hide resolved
starfyre/parser.py Outdated Show resolved Hide resolved
@SuelenKarbivnychyy
Copy link
Contributor Author

Hey @SuelenKarbivnychyy 👋

Where are we testing for slots in the code base?

@sansyrox
There is <slot> tag on <parent.fyre> file on line 20

deleted extra <div> tag that didnt have closing tag for it.
new_children = []
is_slot_used = False
for child_component in endtag_node.children:
if child_component.is_slot_component:
new_children.extend(self.current_children)
Copy link
Member

Choose a reason for hiding this comment

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

@SuelenKarbivnychyy , we should investigate this line. This is the line that determines the order of rendering of slot elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm on it :)

Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

Hey @SuelenKarbivnychyy 👋

I have added a testing application(called test-quote) based on the current logic but it is not working as expected.

@SuelenKarbivnychyy
Copy link
Contributor Author

Hey @SuelenKarbivnychyy 👋

I have added a testing application(called test-quote) based on the current logic but it is not working as expected.

I'm looking into that now :)

Fixed the text node order of slot components and implemented a approach to have the correct behavior when custom compoment is the  root node in __innit__.fyre

BREAKING CHANGE: sparckles#39
self.current_depth -= 1

if endtag_node.tag != "style" and endtag_node.tag != "script":

if endtag_node.original_name != endtag_node.tag: #We need to check if the endtag_node is a custom tag
Copy link
Member

Choose a reason for hiding this comment

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

Niceee. There is one final suggestion and everything should be hopefully good to go. I will complete my review by tonight. 😄

Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

Hey @SuelenKarbivnychyy

image

This has stopped working in the current code however it is working fine in the main branch

@SuelenKarbivnychyy
Copy link
Contributor Author

Hey @SuelenKarbivnychyy

image This has stopped working in the current code however it is working fine in the main branch

@sansyrox I'm running the main branch on my pc and the use_parent_signal() as well as get_parent_signal() are not working "And I don't remember seeing it working before". Only the ssr_request() is working as of now.

image

<ul>
<li>a</li>
<li>a</li>
Copy link
Member

Choose a reason for hiding this comment

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

extra spaces

<li>b</li>
<li>c</li>
<li>c</li>
Copy link
Member

Choose a reason for hiding this comment

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

same

data,
)

#We need to check if the wrapped component should go to the custom list aka self.current_children or to parent_node children list
Copy link
Member

Choose a reason for hiding this comment

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

can you please explain a bit more here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you please explain a bit more here?

@sansyrox
If the text node is children of a custom tag aka <parent></parent>,
that text node should go to self.current_children list that will be the replacement for the slot.
If we don't check that, the text node will be added straight to the parent_node.children and consequently placed in the wrong order on the final HTML.

Copy link
Member

Choose a reason for hiding this comment

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

@SuelenKarbivnychyy 👋

Can you please articulate this explanation as a code comment? and include it there?

starfyre/parser.py Outdated Show resolved Hide resolved
@@ -18,17 +18,41 @@ def extract_functions(obj):


class ComponentParser(HTMLParser):
# this is the grammar for the parser
# we need cover all the grammar rules
"""
Copy link
Member

Choose a reason for hiding this comment

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

@SuelenKarbivnychyy , I have added some explanation. To summarise what we have done so far.

included comments when processing data on parser
@sansyrox
Copy link
Member

sansyrox commented Sep 5, 2023

@SuelenKarbivnychyy , can you please add the TODO comment and raise the issue we talked about?

added a TODO to investigate why nested slot component is not rendered correct
@SuelenKarbivnychyy
Copy link
Contributor Author

@SuelenKarbivnychyy , can you please add the TODO comment and raise the issue we talked about?

Yes, I just did it. :)

# if the tag is not found in the generic tags but found in custom components
# we need to replace the tag with the actual component
# and add the children to the component
# @suelen can you come up with a better explanation for this?
Copy link
Member

Choose a reason for hiding this comment

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

@SuelenKarbivnychyy , this is still left

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SuelenKarbivnychyy , this is still left

@sansyrox
We already have this active discussion.

I can not explain your reasons/or why is better to have the check for closing custom component tag after processing slots component.

From my understanding, slot tag is meant to be specified on the custom component definition "parent.fyre definition" so we must check if the closing tag is a custom tag before processing slot.

To conclude, my solution is to process slot elements when we're handling closing tag for custom component. That is why check for custom component should be before slot processing. I'm not sure how can I explain proposed logic when this check happens after slot processing.

starfyre/parser.py Outdated Show resolved Hide resolved
Copy link
Member

@sansyrox sansyrox left a comment

Choose a reason for hiding this comment

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

@SuelenKarbivnychyy , one last thing to edit and then we can merge this PR 😄

@sansyrox sansyrox merged commit 14500f4 into sparckles:main Sep 8, 2023
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.

2 participants