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 @@ -45,7 +45,7 @@ export const base = ({ parameters }) => {
language="${ifNonNull(language)}"
lang-display="${ifNonNull(langDisplay)}"
size="${ifNonNull(size)}"
languageList="${ifNonNull(langList)}"
lang-list="${ifNonNull(langList)}"
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
.legalLinks="${ifNonNull(legalLinks)}"
.links="${ifNonNull(links)}"
.localeList="${ifNonNull(localeList)}"
Expand All @@ -60,7 +60,7 @@ export const base = ({ parameters }) => {
language="${ifNonNull(language)}"
lang-display="${ifNonNull(langDisplay)}"
size="${ifNonNull(size)}"
languageList="${ifNonNull(langList)}"
lang-list="${ifNonNull(JSON.stringify(langList))}"
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
.legalLinks="${ifNonNull(legalLinks)}"
.links="${ifNonNull(links)}"
.localeList="${ifNonNull(localeList)}"
Expand Down Expand Up @@ -146,7 +146,7 @@ export default {
return {
FooterComposite: {
langDisplay: !useMock ? undefined : 'United States - English',
langList: !useMock ? undefined : mockLangList,
langList: mockLangList,
legalLinks: !useMock ? undefined : mockLegalLinks,
links: !useMock ? undefined : mockLinks,
localeList: !useMock ? undefined : mockLocaleList,
Expand Down
22 changes: 11 additions & 11 deletions packages/web-components/src/components/footer/footer-composite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
@property()
language?: string;

@property({ attribute: false })
langList?;
/**
* Placeholder list of languages to populate language selector
*
* @internal
*/
@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.


/**
* The language to show in the UI.
Expand Down Expand Up @@ -244,14 +249,10 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
_languageCallback: languageCallback,
} = this;

console.log(languageSelectorLabel);
const parsedList = !langList ? undefined : JSON.parse(langList as string);
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved

return html`
<dds-footer
size="${ifNonNull(size)}"
enableLanguageSelector="${enableLanguageSelector}"
languageSelectorLabel="${languageSelectorLabel}"
selectedLanguage="${selectedLanguage}"
>
<dds-footer size="${ifNonNull(size)}">
<dds-footer-logo></dds-footer-logo>
<dds-footer-nav>
${links?.map(
Expand All @@ -275,11 +276,10 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
: html`
<dds-language-selector
trigger-content="${languageSelectorLabel}"
size="xl"
value="${selectedLanguage}"
@bx-combo-box-selected="${languageCallback}"
>
${langList?.map(
${parsedList?.map(
({ text: language }) => html`
<bx-combo-box-item value="${ifNonNull(language)}">${ifNonNull(language)}</bx-combo-box-item>
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
LocaleModalContainerActions,
} from '../locale-modal/locale-modal-container';
import DDSFooterComposite from './footer-composite';
import languageList from './__stories__/language-list';

const { stablePrefix: ddsPrefix } = ddsSettings;

Expand Down Expand Up @@ -101,7 +100,6 @@ export function mapStateToProps(state: FooterContainerState): FooterContainerSta
localeList: !language ? undefined : localeLists?.[language],
links: !language ? undefined : translations?.[language]?.footerMenu,
legalLinks: !language ? undefined : translations?.[language]?.footerThin,
langList: languageList,
},
value => value !== undefined
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { html, property, customElement, query } from 'lit-element';
import ddsSettings from '@carbon/ibmdotcom-utilities/es/utilities/settings/settings.js';
import BXComboBox from 'carbon-web-components/es/components/combo-box/combo-box.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';
Expand All @@ -20,19 +20,25 @@ import { findIndex, forEach } from '../../globals/internal/collection-helpers';
const { stablePrefix: ddsPrefix } = ddsSettings;

/**
* Language selector
* Language selector component.
* The API for language selection is still subject to change.
*
* @element dds-language-selector
* @internal
*/
@customElement(`${ddsPrefix}-language-selector`)
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;

@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;

/**
* Size property to apply different styles.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#### `should render minimum attributes`

```
<dds-footer-composite size="">
<dds-footer-composite
language-selector-label="undefined"
selected-language="undefined"
size=""
>
<dds-footer
data-autoid="dds--footer"
role="footer"
Expand Down Expand Up @@ -39,6 +43,8 @@
<dds-footer-composite
lang-display="lang-display-foo"
language="ko-KR"
language-selector-label="undefined"
selected-language="undefined"
size=""
>
<dds-footer
Expand Down