-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: hamza14khan <hamzaubit14@gmail.com> Co-authored-by: Hamza Khan <164040832+hamza14khan@users.noreply.github.com> Co-authored-by: Andrea Pregnolato <andrea.pregnolato@nearform.com>
- Loading branch information
1 parent
c74949c
commit 49ad582
Showing
11 changed files
with
335 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% set footerProps = { | ||
"links": [ | ||
{ | ||
"href": "#", | ||
"label": "Link 1", | ||
}, | ||
{ | ||
"href": "#", | ||
"label": "Link 2", | ||
}, | ||
{ | ||
"href": "#", | ||
"label": "Link 3", | ||
}, | ||
], | ||
"secondaryNavLinks": [ | ||
{ | ||
"heading": "Heading", | ||
"hasTwoCols": true, | ||
"links": [ | ||
{ | ||
"href": "#", | ||
"label": "Nav Link 1", | ||
}, | ||
{ | ||
"href": "#", | ||
"label": "Nav Link 2", | ||
}, | ||
{ | ||
"href": "#", | ||
"label": "Nav Link 3", | ||
}, | ||
{ | ||
"href": "#", | ||
"label": "Nav Link 4", | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{% macro govieFooter(props) %} | ||
|
||
{% from 'heading/heading.html' import govieHeading %} | ||
{% from 'footer/helpers.html' import hasTwoCols,hasTwoColsLinks, govieFooterLink %} | ||
|
||
<footer class="gi-bg-gold-50 gi-p-x-xl gi-py-3xl gi-border-solid gi-border-t-xs gi-border-gold-500 gi-pt-3xl gi-pb-2xl" data-module="gieds-footer"> | ||
{# TODO: Use Container component #} | ||
<div class="gi-w-5/6 gi-m-auto gi-max-w-screen-lg"> | ||
<div> | ||
{# secondary nav links #} | ||
<div class="gi-grid sm:gi-grid-flow-col gi-grid-flow-row gi-gap-2xl"> | ||
{% if props.secondaryNavLinks %} | ||
{% for linkObj in props.secondaryNavLinks %} | ||
<div class="{{ hasTwoCols(linkObj.hasTwoCols) | trim }}"> | ||
{{ | ||
govieHeading({ | ||
"text": linkObj.heading, | ||
"tag": "h2", | ||
"size": "lg" | ||
}) | ||
}} | ||
<ul class="gi-border-solid gi-border-t gi-border-gold-500 gi-mt-2xl gi-pt-xl {{ hasTwoColsLinks(linkObj.hasTwoCols) | trim }}"> | ||
{% for link in linkObj.links %} | ||
<li class="gi-mb-xl"> | ||
{{ govieFooterLink({ | ||
"href" : link.href, | ||
"label" : link.label | ||
}) | ||
}} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
</div> | ||
{# main links #} | ||
<ul class="gi-mt-2xl gi-flex gi-gap-lg gi-mb-xl"> | ||
{% if props.links %} | ||
{% for link in props.links %} | ||
<li data-testid=main-link-{{loop.index0}}> | ||
{{ govieFooterLink({ | ||
"href" : link.href, | ||
"label" : link.label | ||
}) | ||
}} | ||
</li> | ||
{% endfor %} | ||
{% endif %} | ||
</ul> | ||
<div class="gi-flex gi-items-end gi-justify-between"> | ||
<img class="gi-ml-auto" alt="Gov IE Logo" width="190" src="https://ds.blocks.gov.ie/_next/static/media/logo.a6bf00ac.png" /> | ||
</div> | ||
</div> | ||
</div> | ||
</footer> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as zod from 'zod'; | ||
|
||
export const footerSchema = zod.object({ | ||
links: zod | ||
.object({ | ||
label: zod.string({ | ||
description: 'The label of the link', | ||
required_error: 'The label is required', | ||
}), | ||
href: zod.string({ | ||
description: 'The url (href) of the link', | ||
required_error: 'The url is required', | ||
}), | ||
}) | ||
.array() | ||
.optional() | ||
.describe( | ||
'Array of main links used in Footer. The links use the govieLink component therefore the properties are inhertied from govieLink', | ||
), | ||
secondaryNavLinks: zod | ||
.object({ | ||
hasTwoCols: zod | ||
.boolean({ | ||
description: 'Enable two column grid for navigation links', | ||
}) | ||
.optional(), | ||
heading: zod.string({ | ||
description: 'Heading for the column of links', | ||
}), | ||
links: zod | ||
.object({ | ||
label: zod.string({ | ||
description: 'The label of the link', | ||
required_error: 'The label is required', | ||
}), | ||
href: zod.string({ | ||
description: 'The url (href) of the link', | ||
required_error: 'The url is required', | ||
}), | ||
}) | ||
.array() | ||
.describe( | ||
'Array of secondary navigation links used in Footer. The links use the govieLink component therefore the properties are inhertied from govieLink', | ||
), | ||
}) | ||
.array() | ||
.optional() | ||
.describe( | ||
'Array of secondaryNavLink object which includes heading, the ability to display the link on two columns and the navigation links', | ||
), | ||
}); | ||
|
||
export type FooterProps = zod.infer<typeof footerSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { renderComponent } from '../storybook/storybook'; | ||
import html from './footer.html?raw'; | ||
import { FooterProps } from './footer.schema'; | ||
|
||
// Name of the folder the macro resides | ||
const path = import.meta.url.split('/footer')[0]; | ||
|
||
const macro = { name: 'govieFooter', html, path }; | ||
|
||
const Footer = renderComponent<FooterProps>(macro); | ||
|
||
const meta = { | ||
component: Footer, | ||
title: 'Layout/Footer', | ||
parameters: { | ||
macro, | ||
}, | ||
} satisfies Meta<typeof Footer>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const WithLinks: Story = { | ||
args: { | ||
links: [ | ||
{ | ||
href: '#', | ||
label: 'Link 1', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 2', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 3', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export const WithSecondaryNavigation: Story = { | ||
args: { | ||
secondaryNavLinks: [ | ||
{ | ||
heading: 'Heading', | ||
links: [ | ||
{ | ||
href: '#', | ||
label: 'Link 1', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 2', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 3', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export const WithSecondaryNavigationTwoColumns: Story = { | ||
args: { | ||
secondaryNavLinks: [ | ||
{ | ||
heading: 'Heading 1', | ||
links: [ | ||
{ | ||
href: '#', | ||
label: 'Link 1', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 2', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 3', | ||
}, | ||
], | ||
}, | ||
{ | ||
heading: 'Heading 2', | ||
links: [ | ||
{ | ||
href: '#', | ||
label: 'Link 4', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 5', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 6', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export const WithSecondaryNavigationAndLinks: Story = { | ||
args: { | ||
links: [ | ||
{ | ||
href: '#', | ||
label: 'Link 1', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 2', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 3', | ||
}, | ||
], | ||
secondaryNavLinks: [ | ||
{ | ||
heading: 'Heading', | ||
links: [ | ||
{ | ||
href: '#', | ||
label: 'Link 1', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 2', | ||
}, | ||
{ | ||
href: '#', | ||
label: 'Link 3', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% macro hasTwoCols(twoCols) %} | ||
{% if twoCols %} | ||
sm:gi-col-span-2 | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% macro hasTwoColsLinks(twoCols) %} | ||
{% if twoCols %} | ||
sm:gi-columns-2 | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% macro govieFooterLink(props) %} | ||
<a class="gi-underline gi-underline-offset-sm" href="{{ props.href }}">{{ props.label }}</a> | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.