-
Notifications
You must be signed in to change notification settings - Fork 156
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
feat(footer): language only for web component variations #4772
feat(footer): language only for web component variations #4772
Conversation
Good to see some progress @IgnacioBecerra! One question; Can usage of |
Deploy preview created for package Built with commit: ea5db152c28a41ba8eb066a62c0f3163753fba7c |
Deploy preview created for package Built with commit: ea5db152c28a41ba8eb066a62c0f3163753fba7c |
Deploy preview created for package Built with commit: ea5db152c28a41ba8eb066a62c0f3163753fba7c |
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.
Good progress @IgnacioBecerra!
${useMock | ||
? html` | ||
<dds-footer-composite | ||
language="${ifNonNull(language)}" | ||
lang-display="${ifNonNull(langDisplay)}" | ||
size="${ifNonNull(size)}" | ||
languageList="${ifNonNull(langList)}" |
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.
Did you mean localeList
? Also note that property assignment (instead of attribute assignment) takes .prop
syntax.
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.
Following the React version, I'm using the language list that was passed down to create the combo-box-items
. They are different lists, unless I'm missing something..
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.
Thanks @IgnacioBecerra for clarifying! Seems that the API in React counterpart hasn't been finalized. Started a discussion offline.
packages/web-components/src/components/footer/footer-composite.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/__stories__/footer.stories.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/__stories__/footer.stories.ts
Outdated
Show resolved
Hide resolved
@property({ attribute: false }) | ||
langList?; |
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.
Does this serve a different purpose from localeList
?
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.
Yes, it maps the combo-box-item
elements to the language list that was added with this commit. The locale list has many repeated languages. See also my other comment.
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
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.
Thank you for the updates @IgnacioBecerra!
enableLanguageSelector="${enableLanguageSelector}" | ||
languageSelectorLabel="${languageSelectorLabel}" | ||
selectedLanguage="${selectedLanguage}" |
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.
The attribute names should be dash-cased. BTW has <dds-footer>
got such attributes already?
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 originally, I added these for passing into the dds-language-selector
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'll remove these, we actually don't need them
packages/web-components/src/components/footer/footer-composite.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Size property to apply different styles. | ||
*/ | ||
|
||
@property({ attribute: 'footer-size' }) | ||
footerSize = FOOTER_SIZE.REGULAR; |
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.
Does this cause any change in behavior of <dds-language-selector>
?
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 at the moment, but it's for the future micro
styling
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.
Do you have some details? Wondering if we may have a better name of this property. Thanks!
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.
The React version has a micro
version of the language selector, so just like in the dds-locale-button
we're storing a size
property to apply the proper styles for it. The reason why it's not size
like in that component is that size
is another property within combo-box
, hence footerSize
instead of just size
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 see thanks, do you have some screenshots for regular styling vs micro footer styling?
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.
The background color, border, and position are the most prominent differences between the two. Here's the Reactversion for reference.
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.
Thanks @IgnacioBecerra! In this case I suggest (below code should be defined in footer/defs.ts
):
/**
* The style scheme of language selector.
*/
export enum LANGUAGE_SELECTOR_STYLE_SCHEME {
/**
* Regular style scheme.
*/
REGULAR = '',
/**
* The style scheme that's blendid into outer style scheme.
* The primary use case is for used in micro footer.
*/
BLENDED = 'blended',
}
/** | ||
* The placeholder for `setLanguage()` Redux action that may be mixed in. | ||
* | ||
* @internal | ||
*/ | ||
_languageCallback?: (e) => 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.
Couldn't find the corresponding Redux action, that made me wonder what this is for...?
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.
@IgnacioBecerra Gentle reminder - Any thoughts? Thanks!
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.
Thank you for the updates @IgnacioBecerra!
packages/web-components/src/components/footer/footer-composite.ts
Outdated
Show resolved
Hide resolved
@property({ attribute: 'lang-list' }) | ||
langList?: string; |
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.
Please see my comment to JSON.parse()
code for more details:
@property({ attribute: 'lang-list' }) | |
langList?: string; | |
@property({ attribute: false }) | |
langList?: string[]; |
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.
Setting it to string[]
makes Typescript complain when trying to access its contents (text
does not exist on type String), though it works anyway.
Changing it to any[]
gets rid of this error.
packages/web-components/src/components/footer/__stories__/footer.stories.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/__stories__/footer.stories.ts
Outdated
Show resolved
Hide resolved
/** | ||
* Size property to apply different styles. | ||
*/ | ||
|
||
@property({ attribute: 'footer-size' }) | ||
footerSize = FOOTER_SIZE.REGULAR; |
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 see thanks, do you have some screenshots for regular styling vs micro footer styling?
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.
Good progress @IgnacioBecerra!
/** | ||
* Size property to apply different styles. | ||
*/ | ||
|
||
@property({ attribute: 'footer-size' }) | ||
footerSize = FOOTER_SIZE.REGULAR; |
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.
Thanks @IgnacioBecerra! In this case I suggest (below code should be defined in footer/defs.ts
):
/**
* The style scheme of language selector.
*/
export enum LANGUAGE_SELECTOR_STYLE_SCHEME {
/**
* Regular style scheme.
*/
REGULAR = '',
/**
* The style scheme that's blendid into outer style scheme.
* The primary use case is for used in micro footer.
*/
BLENDED = 'blended',
}
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
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.
Thank you for the update @IgnacioBecerra!
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/__stories__/footer.stories.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/__stories__/footer.stories.ts
Outdated
Show resolved
Hide resolved
/** | ||
* The placeholder for `setLanguage()` Redux action that may be mixed in. | ||
* | ||
* @internal | ||
*/ | ||
_languageCallback?: (e) => 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.
@IgnacioBecerra Gentle reminder - Any thoughts? Thanks!
*/ | ||
|
||
@query('input') | ||
private filterInputNode!: HTMLInputElement; |
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.
Please make sure private properties/methods are prefixed with _
:
private filterInputNode!: HTMLInputElement; | |
private _filterInputNode!: HTMLInputElement; |
protected _handleClickOutside = e => { | ||
if (!this.contains(e.target as Node)) { |
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.
- Please make sure method args are type-annotated:
- Style nit: Most of the codebase uses longer
event
variable name for event handlers. I think it's good to align to such naming strategy.
protected _handleClickOutside = e => { | |
if (!this.contains(e.target as Node)) { | |
protected _handleClickOutside = (event: MouseEvent) => { | |
if (!this.contains(event.target as Node)) { |
} | ||
|
||
render() { | ||
this._lastValidLang = this.value; |
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.
Did you mean to update _lastValidLang
upon change in this.value
? If so, we should use updated()
lifecycle method.
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.
Thank you for the update @IgnacioBecerra! Getting close.
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/footer-composite.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/footer-composite.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/footer-composite.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
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.
Looking good, almost there! The last style nit - Could you re-order properties/methods in the following way to align to other components?
- Private/protected properties
- Private/protected methods
- Public properties
- Public methods
- Static properties
super._handleUserInitiatedSelectItem(item); | ||
} | ||
|
||
updated(changedProperties) { |
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.
To resolve TS error observed in the CI:
updated(changedProperties) { | |
// The parent class does not define `changedProperties` | |
// @ts-ignore | |
updated(changedProperties) { |
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.
Thank you!
packages/web-components/src/components/footer/language-selector.ts
Outdated
Show resolved
Hide resolved
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.
LGTM 👍 - Thanks @IgnacioBecerra!
🙌 🎉 Thank you so much for all the guidance @asudoh! |
Thank you @IgnacioBecerra on all of the work on this! One thing to consider, for the documentation there isn't a clear section on how to use the language selector over the default locale button. you can see something similar in React, we may want to provide the same level of documentation: http://ibmdotcom-react.mybluemix.net/?path=/docs/components-footer--default |
| Attribute | Description | | ||
| ------------------------ | -------------------------------------- | | ||
| `language-selector-label`| `The input box placeholder` | | ||
| `selected-language` | `The initial selected language` | |
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.
Just checking, isn't the localeList also necessary? Might help to also show what the expected data structure should be.
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.
Hm, yeah I was under the impression localeList
would always be passed down regardless of languageSelector
being on or not for the locale-button
, but that component is also optional in the first place. Let me update
Related Ticket(s)
#4706
Description
Introduced the Regular/Short variations of the footer with the Language Selector in Web Components.
Changelog
New
<dds-language-selector>
introduced, extended from<bx-combo-box>