Skip to content

Commit

Permalink
fix: add semantics to contact information
Browse files Browse the repository at this point in the history
  • Loading branch information
stardustmeg committed Jun 3, 2024
1 parent 49f4e1e commit 75710e5
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/widgets/Footer/view/FooterView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ type Goal = {
type Contact = {
alt: string;
description: string;
href?: string;
src: string;
tag: keyof HTMLElementTagNameMap;
};

type Img = {
Expand Down Expand Up @@ -98,16 +100,21 @@ const CONTACTS: Contact[] = [
alt: 'location greenshop',
description: '70 West Buckingham Ave. Farmingdale, NY 11735',
src: '/img/png/location.png',
tag: 'address',
},
{
alt: 'email greenshop',
description: '[email protected]',
href: 'mailto:[email protected]',
src: '/img/png/message.png',
tag: 'a',
},
{
alt: 'phone greenshop',
description: '+88 01911 717 490',
href: 'tel:+8801911717490',
src: '/img/png/calling.png',
tag: 'a',
},
];

Expand Down Expand Up @@ -250,11 +257,19 @@ class FooterView {
return wrap;
}

private createContactItemHTML(contact: Contact): HTMLDivElement {
private createContactItemHTML(contact: Contact): HTMLElement {
const attributes: { [key: string]: string } = {};

if (contact.href) {
attributes.href = contact.href;
}

const wrap = createBaseElement({
attributes,
cssClasses: [styles.contactItem],
tag: 'div',
tag: contact.tag,
});

const icon = createBaseElement({
attributes: {
alt: contact.alt,
Expand All @@ -263,11 +278,13 @@ class FooterView {
cssClasses: [styles.contactIcon],
tag: 'img',
});

const title = createBaseElement({
cssClasses: [styles.contactText],
innerContent: contact.description,
tag: 'p',
tag: 'span',
});

wrap.append(icon, title);
return wrap;
}
Expand Down

1 comment on commit 75710e5

@stardustmeg
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.