-
Notifications
You must be signed in to change notification settings - Fork 77
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
refactor(tabs, tab, tab-nav, tab-title): getElementProp
is refactored out in favor of inheritable props set directly on parent
#7605
refactor(tabs, tab, tab-nav, tab-title): getElementProp
is refactored out in favor of inheritable props set directly on parent
#7605
Conversation
… out in favor of inheritable props set directly on parent
getElementProp
is refactored out in favor of inheritable props set directly on parent
This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions. |
…ed scale class in the format .scale--s
…osition and other cleanup
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.
👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾
👾🕹️🕹️🕹️🕹️👾🕹️👾👾👾👾👾🕹️👾🕹️🕹️🕹️🕹️👾👾🕹️🕹️🕹️👾👾🕹️🕹️👾👾🕹️👾👾👾🕹️👾🕹️🕹️🕹️🕹️👾🕹️👾
👾🕹️👾👾🕹️👾🕹️👾👾👾👾👾🕹️👾🕹️👾👾👾👾🕹️👾👾👾👾🕹️👾👾🕹️👾🕹️🕹️👾🕹️🕹️👾🕹️👾👾👾👾🕹️👾
👾🕹️🕹️🕹️🕹️👾🕹️👾👾🕹️👾👾🕹️👾🕹️🕹️🕹️👾👾👾🕹️🕹️👾👾🕹️👾👾🕹️👾🕹️👾🕹️👾🕹️👾🕹️🕹️🕹️👾👾🕹️👾
👾🕹️👾👾🕹️👾🕹️👾🕹️👾🕹️👾🕹️👾🕹️👾👾👾👾👾👾👾🕹️👾🕹️👾👾🕹️👾🕹️👾👾👾🕹️👾🕹️👾👾👾👾👾👾
👾🕹️👾👾🕹️👾👾🕹️👾👾👾🕹️👾👾🕹️🕹️🕹️🕹️👾🕹️🕹️🕹️👾👾👾🕹️🕹️👾👾🕹️👾👾👾🕹️👾🕹️🕹️🕹️🕹️👾🕹️👾
👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾👾
packages/calcite-components/src/components/tab-nav/tab-nav.scss
Outdated
Show resolved
Hide resolved
@@ -69,7 +69,7 @@ export class Tab { | |||
role="tabpanel" | |||
tabIndex={this.selected ? 0 : -1} | |||
> | |||
<section> | |||
<section class={CSS.content}> |
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.
Not for this PR, but it'd be good to replace all selectors using section
with the content
class.
position="${select("position", ["top", "bottom"], "top")}" | ||
scale="${select("scale", ["s", "m", "l"], "l")}" | ||
> | ||
const TabNavHTMLSimple = 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.
Awesome job adding more coverage! ✨🧪🧪🧪✨
@@ -166,7 +166,7 @@ export class Tabs { | |||
} | |||
}); | |||
|
|||
private updateItems = (): void => { | |||
private updateItems(): void { |
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.
✨🏆✨
} | ||
); | ||
|
||
Array.from(this.el.querySelectorAll("calcite-tab")).forEach((tab: HTMLCalciteTabElement) => { |
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.
Queries target all descendants, so this will be an issue when you have nested tabs with different props each. Not sure how common position
and scale
being different between nested tabs would be, so this could be an edge case.
…herited props to other nested tab-titles
Related Issue: #6038
Summary
getElementProp
is refactored out across child components as an outdated pattern in favor of inheritable props set directly on the parent. Instead of thetab, tab-title, tab-nav
looking up the parent forposition
andscale
, these get set by thetabs
parent.The logic for setting these props thus moves to the parent, getting rid of the
getElementProp
altogether. The parent component gets amutationObserver
to achieve this and watchers for when it needs to modify the children. Child attribute selectors are subbed with new classes added dynamically to reflect the scale and position, as attributes are no longer reflected to be targeted.Inherited props addressed: