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(bal-footer): make footer links customizable #1540

Merged
merged 5 commits into from
Dec 5, 2024
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
5 changes: 5 additions & 0 deletions .changeset/popular-carpets-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/ds-core': minor
---

**footer**: Introduce overrideLinks property to enable consumers to change the legal links in the footer
13 changes: 13 additions & 0 deletions e2e/cypress/component/bal-footer.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Components } from '../../generated'

describe('bal-footer', () => {
it('should contain custom links', () => {
cy.mount<Components.BalFooter, HTMLBalFooterElement>(`<bal-footer></bal-footer>`, {
props: {
overrideLinks: [{ label: 'Test Link', link: 'https://www.baloise.ch' }],
},
})
cy.get('bal-footer').contains('Test Link')
cy.get('bal-footer').should('not.contain', 'Datenschutz')
})
})
18 changes: 18 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BalCarouselItemData, BalSlide } from "./components/bal-carousel/bal-car
import { BalCheckboxOption } from "./components/bal-checkbox/bal-checkbox.type";
import { BalAriaForm } from "./utils/form";
import { BalOption } from "./utils/dropdown";
import { FooterLink } from "@baloise/web-app-utils";
import { OverlayEventDetail } from "./components/bal-modal/bal-modal.type";
import { PopoverPresentOptions } from "./components/bal-popover/bal-popover";
import { BalRadioOption } from "./components/bal-radio/bal-radio.type";
Expand All @@ -23,6 +24,7 @@ export { BalCarouselItemData, BalSlide } from "./components/bal-carousel/bal-car
export { BalCheckboxOption } from "./components/bal-checkbox/bal-checkbox.type";
export { BalAriaForm } from "./utils/form";
export { BalOption } from "./utils/dropdown";
export { FooterLink } from "@baloise/web-app-utils";
export { OverlayEventDetail } from "./components/bal-modal/bal-modal.type";
export { PopoverPresentOptions } from "./components/bal-popover/bal-popover";
export { BalRadioOption } from "./components/bal-radio/bal-radio.type";
Expand Down Expand Up @@ -106,6 +108,10 @@ export namespace Components {
* The color to use from your application's color palette.
*/
"color": BalProps.BalButtonColor;
/**
* If `true` the button is aligned over the whole width
*/
"expanded": boolean;
/**
* BalIcon of the open trigger button
*/
Expand Down Expand Up @@ -1203,6 +1209,10 @@ export namespace Components {
* If `true` the legal Baloise links will be hidden.
*/
"hideLinks": boolean;
/**
* If provided, the footer links will be overridden.
*/
"overrideLinks": FooterLink[] | undefined;
/**
* If `true` the social media links will be shown.
*/
Expand Down Expand Up @@ -5128,6 +5138,10 @@ declare namespace LocalJSX {
* The color to use from your application's color palette.
*/
"color"?: BalProps.BalButtonColor;
/**
* If `true` the button is aligned over the whole width
*/
"expanded"?: boolean;
/**
* BalIcon of the open trigger button
*/
Expand Down Expand Up @@ -6275,6 +6289,10 @@ declare namespace LocalJSX {
* If `true` the legal Baloise links will be hidden.
*/
"hideLinks"?: boolean;
/**
* If provided, the footer links will be overridden.
*/
"overrideLinks"?: FooterLink[] | undefined;
/**
* If `true` the social media links will be shown.
*/
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/components/bal-footer/bal-footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export class Footer implements BalConfigObserver, Loggable {
*/
@Prop() hideLinks = false

/**
* If provided, the footer links will be overridden.
*/
@Prop() overrideLinks: FooterLink[] | undefined = undefined

/**
* If `true` the social media links will be shown.
*/
Expand Down Expand Up @@ -94,7 +99,9 @@ export class Footer implements BalConfigObserver, Loggable {
}

private updateFooterLinks() {
if (!this.hideLinks && (this.region === 'CH' || this.region === 'DE')) {
if (this.overrideLinks) {
this.links = this.overrideLinks
} else if (!this.hideLinks && (this.region === 'CH' || this.region === 'DE')) {
// The following footer links only apply to swiss and german applications
const region = this.region
rIC(() => {
Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/components/bal-footer/test/bal-footer.cy.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ <h2 class="title text-xx-large">All variations</h2>
<div class="container">Footer</div>
</bal-footer>
</section>

<h2 class="title text-xx-large">Override links</h2>
<section>
<bal-footer id="override-links-footer"></bal-footer>
</section>
</div>
</body>
<script>
const overrideLinksFooter = document.getElementById('override-links-footer')
overrideLinksFooter.overrideLinks = [
{ label: 'Test Link', link: 'https://baloise.com' },
{ label: 'Second Test Link', link: 'https://baloise.ch' },
]
</script>
</html>
Loading