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

[CHOPS-890] Add optional logo link to homepage #2061

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ebury/chameleon-components",
"version": "2.8.18",
"version": "2.8.19",
"main": "src/main.ts",
"sideEffects": false,
"author": "Ebury Team (http://labs.ebury.rocks/)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ exports[`EcNavigation > mobile navigation > should render mobile header if "isRe
class="tw-leading-reset"
>

<img
alt="Test Brand"
class="ec-navigation__mobile-header-logo"
data-test="ec-navigation__mobile-header-logo"
src="/img/my-brand.png"
/>
<a
href="https://example.com"
>
<img
alt="My Branding"
class="ec-navigation__mobile-header-logo"
data-test="ec-navigation__mobile-header-logo"
src="/img/my.png"
/>
</a>

</div>
<button
Expand Down Expand Up @@ -682,6 +686,65 @@ exports[`EcNavigation > should render branding logo and name when given 1`] = `
</div>
`;

exports[`EcNavigation > should render branding logo, name and link when given > Branding should have alt, src, href. 1`] = `
<div
class="ec-navigation__branding"
data-test="ec-navigation__branding"
>
<a
href="https://example.com"
>
<img
alt="My Branding"
class="ec-navigation__branding-logo"
data-test="ec-navigation__branding-logo"
src="/img/my.png"
/>
</a>
</div>
`;

exports[`EcNavigation > should render branding logo, name and link when given 1`] = `
<div
class="ec-navigation"
data-test="ec-navigation"
>
<div
class=""
>
<div
class="ec-navigation__branding"
data-test="ec-navigation__branding"
>
<a
href="https://example.com"
>
<img
alt="My Branding"
class="ec-navigation__branding-logo"
data-test="ec-navigation__branding-logo"
src="/img/my.png"
/>
</a>
</div>
<!--v-if-->
</div>
<!--v-if-->
<!--v-if-->
<!--v-if-->
<div
class="ec-navigation__block ec-navigation__menu"
data-test="ec-navigation__block ec-navigation__menu"
>


</div>
<!--v-if-->
<!--v-if-->
<!--v-if-->
</div>
`;

exports[`EcNavigation > should render with custom attributes 1`] = `
<div
class="ec-navigation my-class"
Expand Down
13 changes: 11 additions & 2 deletions src/components/ec-navigation/ec-navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ describe('EcNavigation', () => {
});

it('should not render branding if no logo is given in branding object', () => {
const wrapper = mountNavigation({ branding: { logo: '', name: 'Test Brand' } });
const wrapper = mountNavigation({ branding: { logo: '', name: 'Test Brand', link: 'https://example.com' } });
expect(wrapper.element).toMatchSnapshot();
expect(wrapper.findByDataTest('ec-navigation__branding').exists()).toBe(false);
});

it('should not render branding if logo is given in branding object but showBrandingLogo is set to false', () => {
const wrapper = mountNavigation({
branding: { logo: '/img/my.png', name: 'Test Brand' },
branding: { logo: '/img/my.png', name: 'Test Brand', link: 'https://example.com' },
showBrandingLogo: false,
});
expect(wrapper.element).toMatchSnapshot();
Expand All @@ -71,6 +71,14 @@ describe('EcNavigation', () => {
expect(wrapper.findByDataTest('ec-navigation__branding').element).toMatchSnapshot('Branding should have alt and src.');
});

it('should render branding logo, name and link when given', () => {
const wrapper = mountNavigation({
branding: { logo: '/img/my.png', name: 'My Branding', link: 'https://example.com' },
});
expect(wrapper.element).toMatchSnapshot();
expect(wrapper.findByDataTest('ec-navigation__branding').element).toMatchSnapshot('Branding should have alt, src, href.');
});

it('should only render mandatory slot if no other slots were given', () => {
const wrapper = mountNavigation();
expect(wrapper.element).toMatchSnapshot();
Expand Down Expand Up @@ -104,6 +112,7 @@ describe('EcNavigation', () => {
describe('mobile navigation', () => {
it('should render mobile header if "isResponsive" prop is true', () => {
const wrapper = mountNavigation({
branding: { logo: '/img/my.png', name: 'My Branding', link: 'https://example.com' },
isResponsive: true,
});

Expand Down
2 changes: 2 additions & 0 deletions src/components/ec-navigation/ec-navigation.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ basic.args = {
branding: {
name: 'My Branding',
logo: '/ebury-logo-sm-inverse.png',
link: '#',
},
isCollapsable: true,
isCollapsed: false,
Expand Down Expand Up @@ -219,6 +220,7 @@ responsive.args = {
branding: {
name: 'My Branding',
logo: '/ebury-logo-sm.png',
link: '#',
},
isCollapsable: false,
isCollapsed: false,
Expand Down
25 changes: 25 additions & 0 deletions src/components/ec-navigation/ec-navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@
@open-mobile-menu="isMobileMenuOpen = true"
>
<template #logo>
<a
v-if="branding.link"
:href="branding.link"
>
<img
class="ec-navigation__mobile-header-logo"
:src="branding.logo"
:alt="branding.name"
data-test="ec-navigation__mobile-header-logo"
>
</a>
<img
v-else
class="ec-navigation__mobile-header-logo"
:src="branding.logo"
:alt="branding.name"
Expand Down Expand Up @@ -40,7 +52,20 @@
class="ec-navigation__branding"
data-test="ec-navigation__branding"
>
<a
v-if="branding.link"
:href="branding.link"
>
<img
class="ec-navigation__branding-logo"
:class="{ 'ec-navigation__branding-logo--light-mode': isInLightMode }"
:src="branding.logo"
:alt="branding.name"
data-test="ec-navigation__branding-logo"
>
</a>
<img
v-else
class="ec-navigation__branding-logo"
:class="{ 'ec-navigation__branding-logo--light-mode': isInLightMode }"
:src="branding.logo"
Expand Down
1 change: 1 addition & 0 deletions src/components/ec-navigation/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface NavigationBranding {
logo: string,
name: string,
link?: string,
}

export interface NavigationProps {
Expand Down