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 11 commits
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
@@ -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 @@ -13,24 +13,45 @@ import inPercy from '@percy-io/in-percy';
import { FOOTER_SIZE } from '../footer';
import '../footer-composite';
import '../footer-container';
import mockLangList from './language-list';
import mockLinks from './links';
import mockLegalLinks from './legal-links';
import mockLocaleList from '../../locale-modal/__stories__/locale-data.json';
import readme from './README.stories.mdx';
import styles from './footer.stories.scss';

export const base = ({ parameters }) => {
const { langDisplay, language, size, legalLinks, links, localeList } = parameters?.props?.FooterComposite ?? {};
const {
langDisplay,
language,
size,
langList,
legalLinks,
links,
localeList,
enableLanguageSelector,
languageSelectorLabel,
selectedLanguage,
} = parameters?.props?.FooterComposite ?? {};
const { useMock } = parameters?.props?.Other ?? {};

return html`
<style>
${styles}
</style>
${useMock
? html`
<dds-footer-composite
language="${ifNonNull(language)}"
lang-display="${ifNonNull(langDisplay)}"
size="${ifNonNull(size)}"
.langList="${ifNonNull(langList)}"
.legalLinks="${ifNonNull(legalLinks)}"
.links="${ifNonNull(links)}"
.localeList="${ifNonNull(localeList)}"
?enable-language-selector="${enableLanguageSelector}"
language-selector-label="${ifNonNull(languageSelectorLabel)}"
selected-language="${ifNonNull(selectedLanguage)}"
>
</dds-footer-composite>
`
Expand All @@ -39,9 +60,13 @@ export const base = ({ parameters }) => {
language="${ifNonNull(language)}"
lang-display="${ifNonNull(langDisplay)}"
size="${ifNonNull(size)}"
.langList="${ifNonNull(langList)}"
.legalLinks="${ifNonNull(legalLinks)}"
.links="${ifNonNull(links)}"
.localeList="${ifNonNull(localeList)}"
?enable-language-selector="${enableLanguageSelector}"
language-selector-label="${ifNonNull(languageSelectorLabel)}"
selected-language="${ifNonNull(selectedLanguage)}"
>
</dds-footer-container>
`}
Expand All @@ -53,6 +78,19 @@ export const Default = ({ parameters }) => {
props.FooterComposite = {
...(props.FooterComposite || {}),
size: FOOTER_SIZE.REGULAR,
enableLanguageSelector: false,
};
return base({ parameters });
};

export const defaultLanguageOnly = ({ parameters }) => {
const { props = {} } = parameters;
props.FooterComposite = {
...(props.FooterComposite || {}),
size: FOOTER_SIZE.REGULAR,
enableLanguageSelector: true,
languageSelectorLabel: 'Choose a language',
selectedLanguage: 'English',
};
return base({ parameters });
};
Expand All @@ -62,15 +100,33 @@ export const short = ({ parameters }) => {
props.FooterComposite = {
...(props.FooterComposite || {}),
size: FOOTER_SIZE.SHORT,
enableLanguageSelector: false,
};
return base({ parameters });
};

export const shortDefaultLanguageOnly = ({ parameters }) => {
const { props = {} } = parameters;
props.FooterComposite = {
...(props.FooterComposite || {}),
size: FOOTER_SIZE.SHORT,
enableLanguageSelector: true,
languageSelectorLabel: 'Choose a language',
selectedLanguage: 'English',
};
return html`
<div class="micro-container">
${base({ parameters })}
</div>
`;
};

export const micro = ({ parameters }) => {
const { props = {} } = parameters;
props.FooterComposite = {
...(props.FooterComposite || {}),
size: FOOTER_SIZE.MICRO,
enableLanguageSelector: false,
};
return html`
<div class="micro-container">
Expand All @@ -90,6 +146,7 @@ export default {
return {
FooterComposite: {
langDisplay: !useMock ? undefined : 'United States - English',
langList: mockLangList,
legalLinks: !useMock ? undefined : mockLegalLinks,
links: !useMock ? undefined : mockLinks,
localeList: !useMock ? undefined : mockLocaleList,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* @license
*
* 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.
*/

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',
}
46 changes: 43 additions & 3 deletions packages/web-components/src/components/footer/footer-composite.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 Down Expand Up @@ -35,6 +35,8 @@ import './locale-button';
import './legal-nav';
import './legal-nav-item';
import './legal-nav-cookie-preferences-placeholder';
import './language-selector';
import 'carbon-web-components/es/components/combo-box/combo-box-item';

const { stablePrefix: ddsPrefix } = ddsSettings;

Expand Down Expand Up @@ -109,18 +111,44 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
@property({ attribute: 'disable-locale-button' })
disableLocaleButton = false;

/**
* `true` to enable language selector.
*/
@property({ type: Boolean, attribute: 'enable-language-selector' })
enableLanguageSelector = false;
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved

/**
* The language used for query.
*/
@property()
language?: string;

/**
* Placeholder list of languages to populate language selector
*
* @internal
*/
@property({ attribute: false })
langList?: string[];

/**
* The language to show in the UI.
*/
@property({ attribute: 'lang-display' })
langDisplay?: string;

/**
* The placeholder label for language selector.
*/
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
@property({ attribute: 'language-selector-label' })
languageSelectorLabel?: string;

/**
* The initial selected language in the selector.
*/
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
@property({ attribute: 'selected-language' })
selectedLanguage?: string;

/**
* The legal nav links.
*/
Expand Down Expand Up @@ -202,7 +230,11 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
const {
buttonLabel,
disableLocaleButton,
enableLanguageSelector,
langDisplay,
langList,
languageSelectorLabel,
selectedLanguage,
size,
links,
legalLinks,
Expand All @@ -224,13 +256,21 @@ class DDSFooterComposite extends ModalRenderMixin(HybridRenderMixin(HostListener
`
)}
</dds-footer-nav>
${!disableLocaleButton && size !== FOOTER_SIZE.MICRO
${!disableLocaleButton && size !== FOOTER_SIZE.MICRO && !enableLanguageSelector
? html`
<dds-locale-button buttonLabel="${ifNonNull(buttonLabel)}" @click="${handleClickLocaleButton}"
>${langDisplay}</dds-locale-button
>
`
: html``}
: html`
<dds-language-selector trigger-content="${languageSelectorLabel}" value="${selectedLanguage}">
${langList?.map(
IgnacioBecerra marked this conversation as resolved.
Show resolved Hide resolved
language => html`
<bx-combo-box-item value="${ifNonNull(language)}">${ifNonNull(language)}</bx-combo-box-item>
`
)}
</dds-language-selector>
`}
<dds-legal-nav size="${ifNonNull(size)}">
${legalLinks?.map(
({ title, url }) => html`
Expand Down
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 Down
Loading