-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
@sansyrox Please review. |
df6f8d2
to
df46194
Compare
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.
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 😄
Hey, Yes. I'll remove it. I'm still getting use to Commitzen 😄 |
aa7aa7c
to
6d3fb6c
Compare
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.
Hey @SuelenKarbivnychyy 👋
Thank you for answering the questions. I have some suggestions for the design. Do let me know if you have any questions 😄
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.
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
Updated. Let me know if you still have any questions. |
1. Put nodes into current_children
@sansyrox |
deleted extra <div> tag that didnt have closing tag for it.
starfyre/parser.py
Outdated
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) |
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.
@SuelenKarbivnychyy , we should investigate this line. This is the line that determines the order of rendering of slot elements.
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'm on it :)
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.
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 :) |
…into sk-39 getting test code
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
starfyre/parser.py
Outdated
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 |
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.
Niceee. There is one final suggestion and everything should be hopefully good to go. I will complete my review by tonight. 😄
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.
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 |
test-application/parent.fyre
Outdated
<ul> | ||
<li>a</li> | ||
<li>a</li> |
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.
extra spaces
test-application/parent.fyre
Outdated
<li>b</li> | ||
<li>c</li> | ||
<li>c</li> |
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.
same
starfyre/parser.py
Outdated
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 |
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.
can you please explain a bit more here?
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.
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.
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.
Can you please articulate this explanation as a code comment? and include it there?
@@ -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 | |||
""" |
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.
@SuelenKarbivnychyy , I have added some explanation. To summarise what we have done so far.
included comments when processing data on parser
@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
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? |
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.
@SuelenKarbivnychyy , this is still left
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.
@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.
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.
@SuelenKarbivnychyy , one last thing to edit and then we can merge this PR 😄
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