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
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3d81568
temp commit
IgnacioBecerra Dec 23, 2020
5eca34f
feat(footer): language only selector introduced
IgnacioBecerra Jan 6, 2021
c2363bf
Merge branch 'master' into footer-language-only
IgnacioBecerra Jan 6, 2021
4c580d7
feat(footer): added fixes
IgnacioBecerra Jan 6, 2021
2c3b990
feat(footer): ran prettier
IgnacioBecerra Jan 6, 2021
6810126
feat(footer): addressed comments and updated snapshots
IgnacioBecerra Jan 7, 2021
83e5b2e
feat(footer): using property binding to deserialize list
IgnacioBecerra Jan 8, 2021
9c607a4
feat(language-selector): addressed more comments
IgnacioBecerra Jan 8, 2021
d835127
feat(footer): updated to conform to coding guidelines
IgnacioBecerra Jan 8, 2021
058d5fb
feat(foot): removed callback
IgnacioBecerra Jan 8, 2021
4f7b782
feat(footer): updated snapshots
IgnacioBecerra Jan 8, 2021
0391e72
feat(footer): addressed feedback
IgnacioBecerra Jan 8, 2021
f3a8186
feat(footer): removed enableSelector
IgnacioBecerra Jan 8, 2021
d7e678e
feat(footer): reorganized code
IgnacioBecerra Jan 8, 2021
c77c436
feat(footer): replaced updated with super call
IgnacioBecerra Jan 8, 2021
a797ad5
Merge branch 'master' into footer-language-only
asudoh Jan 8, 2021
aa982e7
chore(footer): added documentation
IgnacioBecerra Jan 8, 2021
3294e29
Merge branch 'master' into footer-language-only
IgnacioBecerra Jan 8, 2021
8642b95
chore(footer): updated readme
IgnacioBecerra Jan 8, 2021
0679e46
Merge branch 'master' into footer-language-only
IgnacioBecerra Jan 8, 2021
e2fe580
Merge branch 'master' into footer-language-only
kodiakhq[bot] Jan 8, 2021
ea5db15
Merge branch 'master' into footer-language-only
kodiakhq[bot] Jan 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,151 +7,43 @@
* LICENSE file in the root directory of this source tree.
*/

const languageList: Object[] = [
{
id: 'ar',
text: 'Arabic / عربية',
},
{
id: 'bs',
text: 'Bosnian / Bosanski',
},
{
id: 'bg',
text: 'Bulgarian / Български',
},
{
id: 'ca',
text: 'Catalan / Català',
},
{
id: 'zh',
text: 'Chinese Simplified / 简体中文',
},
{
id: 'zh-tw',
text: 'Chinese Traditional / 繁體中文',
},
{
id: 'hr',
text: 'Croatian / Hrvatski',
},
{
id: 'cs',
text: 'Czech / Čeština',
},
{
id: 'da',
text: 'Danish / Dansk',
},
{
id: 'nl',
text: 'Dutch / Nederlands',
},
{
id: 'en',
text: 'English',
},
{
id: 'fi',
text: 'Finnish / Suomi',
},
{
id: 'fr',
text: 'French / Français',
},
{
id: 'de',
text: 'German / Deutsch',
},
{
id: 'el',
text: 'Greek / Ελληνικά',
},
{
id: 'he',
text: 'Hebrew / עברית',
},
{
id: 'hu',
text: 'Hungarian / Magyar',
},
{
id: 'it',
text: 'Italian / Italiano',
},
{
id: 'ja',
text: 'Japanese / 日本語',
},
{
id: 'kk',
text: 'Kazakh / Қазақша',
},
{
id: 'ko',
text: 'Korean / 한국어',
},
{
id: 'mk',
text: 'Macedonian / македонски',
},
{
id: 'no',
text: 'Norwegian / Norsk',
},
{
id: 'pl',
text: 'Polish / polski',
},
{
id: 'pt-br',
text: 'Portuguese/Brazil/Brazil / Português/Brasil',
},
{
id: 'pt',
text: 'Portuguese/Portugal / Português/Portugal',
},
{
id: 'ro',
text: 'Romanian / Română',
},
{
id: 'ru',
text: 'Russian / Русский',
},
{
id: 'sr',
text: 'Serbian / srpski',
},
{
id: 'sk',
text: 'Slovak / Slovenčina',
},
{
id: 'sl',
text: 'Slovenian / Slovenščina',
},
{
id: 'es',
text: 'Spanish / Español',
},
{
id: 'sv',
text: 'Swedish / Svenska',
},
{
id: 'th',
text: 'Thai / ภาษาไทย',
},
{
id: 'tr',
text: 'Turkish / Türkçe',
},
{
id: 'vi',
text: 'Vietnamese / Tiếng Việt',
},
const languageList: string[] = [
'Arabic / عربية',
'Bosnian / Bosanski',
'Bulgarian / Български',
'Catalan / Català',
'Chinese Simplified / 简体中文',
'Chinese Traditional / 繁體中文',
'Croatian / Hrvatski',
'Czech / Čeština',
'Danish / Dansk',
'Dutch / Nederlands',
'English',
'Finnish / Suomi',
'French / Français',
'German / Deutsch',
'Greek / Ελληνικά',
'Hebrew / עברית',
'Hungarian / Magyar',
'Italian / Italiano',
'Japanese / 日本語',
'Kazakh / Қазақша',
'Korean / 한국어',
'Macedonian / македонски',
'Norwegian / Norsk',
'Polish / polski',
'Portuguese/Brazil/Brazil / Português/Brasil',
'Portuguese/Portugal / Português/Portugal',
'Romanian / Română',
'Russian / Русский',
'Serbian / srpski',
'Slovak / Slovenčina',
'Slovenian / Slovenščina',
'Spanish / Español',
'Swedish / Svenska',
'Thai / ภาษาไทย',
'Turkish / Türkçe',
'Vietnamese / Tiếng Việt',
];

export default languageList;
18 changes: 17 additions & 1 deletion packages/web-components/src/components/footer/defs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020
* Copyright IBM Corp. 2020, 2021
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -26,3 +26,19 @@ export enum FOOTER_SIZE {
*/
MICRO = 'micro',
}

/**
* 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',
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
* @internal
*/
@property({ attribute: false })
langList?: any[];
langList?: string[];

/**
* The language to show in the UI.
Expand Down Expand Up @@ -277,7 +277,7 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
@bx-combo-box-selected="${languageCallback}"
>
${langList?.map(
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
({ text: language }) => html`
language => html`
<bx-combo-box-item value="${ifNonNull(language)}">${ifNonNull(language)}</bx-combo-box-item>
`
)}
Expand Down
21 changes: 10 additions & 11 deletions packages/web-components/src/components/footer/language-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* LICENSE file in the root directory of this source tree.
*/

import { html, property, customElement, query } from 'lit-element';
import { html, property, customElement, query, internalProperty } from 'lit-element';
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
import BXComboBox, { DROPDOWN_SIZE } from 'carbon-web-components/es/components/combo-box/combo-box.js';
import BXComboBoxItem from 'carbon-web-components/es/components/combo-box/combo-box-item.js';
import HostListener from 'carbon-web-components/es/globals/decorators/host-listener.js';
import HostListenerMixin from 'carbon-web-components/es/globals/mixins/host-listener.js';
import { FOOTER_SIZE } from './footer';
import { LANGUAGE_SELECTOR_STYLE_SCHEME } from './defs';
import styles from './footer.scss';
import { findIndex, forEach } from '../../globals/internal/collection-helpers';

Expand All @@ -30,11 +30,10 @@ const { stablePrefix: ddsPrefix } = ddsSettings;
class DDSLanguageSelector extends HostListenerMixin(BXComboBox) {
/**
* Property that saves the last valid language to use on reset cases.
* @private
*/

IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
@property({ attribute: 'last-valid-lang' })
lastValidLang;
@internalProperty()
_lastValidLang?: string;
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved

@property()
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
size = DROPDOWN_SIZE.EXTRA_LARGE;
Expand All @@ -44,7 +43,7 @@ class DDSLanguageSelector extends HostListenerMixin(BXComboBox) {
*/

IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
@property({ attribute: 'footer-size' })
footerSize = FOOTER_SIZE.REGULAR;
footerSize = LANGUAGE_SELECTOR_STYLE_SCHEME.REGULAR;

/**
* The `<input>` for filtering.
Expand All @@ -69,8 +68,8 @@ class DDSLanguageSelector extends HostListenerMixin(BXComboBox) {
@HostListener('document:click')
protected _handleClickOutside = e => {
if (!this.contains(e.target as Node)) {
this._filterInputValue = this.lastValidLang;
this.filterInputNode.value = this.lastValidLang;
this._filterInputValue = this._lastValidLang as string;
this.filterInputNode.value = this._lastValidLang as string;
this.open = false;
this.requestUpdate(); // If the only change is to `_filterInputValue`, auto-update doesn't happen
}
Expand Down Expand Up @@ -104,7 +103,7 @@ class DDSLanguageSelector extends HostListenerMixin(BXComboBox) {
(item as BXComboBoxItem).highlighted = false;
(item as BXComboBoxItem).selected = false;
});
this.lastValidLang = this._filterInputValue;
this._lastValidLang = this._filterInputValue;
this._filterInputValue = '';
this.filterInputNode.focus();
this.open = false;
Expand All @@ -131,13 +130,13 @@ class DDSLanguageSelector extends HostListenerMixin(BXComboBox) {
this.open = false;
this.requestUpdate();
}
this.lastValidLang = item?.textContent as string;
this._lastValidLang = item?.textContent as string;
(item as BXComboBoxItem).selected = true;
super._handleUserInitiatedSelectItem(item);
}

render() {
this.lastValidLang = this.value;
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.

return html`
${super.render()}
`;
Expand Down