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

feat(footer): language only for web component variations #4772

Merged

Conversation

IgnacioBecerra
Copy link
Contributor

@IgnacioBecerra IgnacioBecerra commented Dec 23, 2020

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>

@asudoh
Copy link
Contributor

asudoh commented Dec 23, 2020

Good to see some progress @IgnacioBecerra! One question; Can usage of <bx-combo-box> be an option? https://web-components.carbondesignsystem.com/?path=/story/components-combo-box--default-story

@IgnacioBecerra IgnacioBecerra changed the title WIP: feat(footer): language only for web component variations feat(footer): language only for web component variations Jan 6, 2021
@IgnacioBecerra IgnacioBecerra marked this pull request as ready for review January 6, 2021 05:17
@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jan 6, 2021

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jan 6, 2021

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Jan 6, 2021

Copy link
Contributor

@asudoh asudoh left a 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)}"
Copy link
Contributor

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.

Copy link
Contributor Author

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..

Copy link
Contributor

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.

Comment on lines 133 to 134
@property({ attribute: false })
langList?;
Copy link
Contributor

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?

Copy link
Contributor Author

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/footer.scss Outdated Show resolved Hide resolved
Copy link
Contributor

@asudoh asudoh left a 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!

Comment on lines 251 to 253
enableLanguageSelector="${enableLanguageSelector}"
languageSelectorLabel="${languageSelectorLabel}"
selectedLanguage="${selectedLanguage}"
Copy link
Contributor

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?

Copy link
Contributor Author

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

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'll remove these, we actually don't need them

Comment on lines 36 to 41
/**
* Size property to apply different styles.
*/

@property({ attribute: 'footer-size' })
footerSize = FOOTER_SIZE.REGULAR;
Copy link
Contributor

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>?

Copy link
Contributor Author

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

Copy link
Contributor

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!

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regular styles:
Screen Shot 2021-01-07 at 5 38 15 PM

Micro:
Screen Shot 2021-01-07 at 5 38 22 PM

The background color, border, and position are the most prominent differences between the two. Here's the Reactversion for reference.

Copy link
Contributor

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',
}

Comment on lines 96 to 101
/**
* The placeholder for `setLanguage()` Redux action that may be mixed in.
*
* @internal
*/
_languageCallback?: (e) => void;
Copy link
Contributor

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...?

Copy link
Contributor

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!

Copy link
Contributor

@asudoh asudoh left a 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!

Comment on lines 138 to 139
@property({ attribute: 'lang-list' })
langList?: string;
Copy link
Contributor

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:

Suggested change
@property({ attribute: 'lang-list' })
langList?: string;
@property({ attribute: false })
langList?: string[];

Copy link
Contributor Author

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.

Comment on lines 36 to 41
/**
* Size property to apply different styles.
*/

@property({ attribute: 'footer-size' })
footerSize = FOOTER_SIZE.REGULAR;
Copy link
Contributor

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?

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

Good progress @IgnacioBecerra!

Comment on lines 36 to 41
/**
* Size property to apply different styles.
*/

@property({ attribute: 'footer-size' })
footerSize = FOOTER_SIZE.REGULAR;
Copy link
Contributor

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',
}

Copy link
Contributor

@asudoh asudoh left a 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!

Comment on lines 96 to 101
/**
* The placeholder for `setLanguage()` Redux action that may be mixed in.
*
* @internal
*/
_languageCallback?: (e) => void;
Copy link
Contributor

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;
Copy link
Contributor

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 _:

Suggested change
private filterInputNode!: HTMLInputElement;
private _filterInputNode!: HTMLInputElement;

Comment on lines 69 to 70
protected _handleClickOutside = e => {
if (!this.contains(e.target as Node)) {
Copy link
Contributor

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.
Suggested change
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;
Copy link
Contributor

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.

Copy link
Contributor

@asudoh asudoh left a 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.

Copy link
Contributor

@asudoh asudoh left a 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) {
Copy link
Contributor

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:

Suggested change
updated(changedProperties) {
// The parent class does not define `changedProperties`
// @ts-ignore
updated(changedProperties) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

Copy link
Contributor

@asudoh asudoh left a comment

Choose a reason for hiding this comment

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

LGTM 👍 - Thanks @IgnacioBecerra!

@IgnacioBecerra
Copy link
Contributor Author

🙌 🎉 Thank you so much for all the guidance @asudoh!

@jeffchew
Copy link
Member

jeffchew commented Jan 8, 2021

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

@IgnacioBecerra IgnacioBecerra added the Ready to merge Label for the pull requests that are ready to merge label Jan 8, 2021
| Attribute | Description |
| ------------------------ | -------------------------------------- |
| `language-selector-label`| `The input box placeholder` |
| `selected-language` | `The initial selected language` |
Copy link
Member

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.

Copy link
Contributor Author

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

@kodiakhq kodiakhq bot merged commit ebf603c into carbon-design-system:master Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge Label for the pull requests that are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants