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

Update card macro paths #137

Merged
merged 1 commit into from
Sep 3, 2024
Merged

Update card macro paths #137

merged 1 commit into from
Sep 3, 2024

Conversation

davidhunter08
Copy link
Collaborator

While adding NHS App components to the NHS HTML prototype using the Nunjucks macro:

{% from "nhsapp/components/card/macro.njk" import nhsappCard %}

{{ nhsappCard({
  title: 'Request repeat prescriptions',
  href: '#'
}) }}

It threw up errors for the card links component (all other components worked as expected):

Error 1

Couldn't find the badge macro.

Template render error: (/Users/davidhunter/Documents/prototypes/nhs-app-design-styles-components-patterns/node_modules/nhsapp-frontend/dist/nhsapp/components/card/card.njk)
Error: template not found: badge/large/macro.njk

Fix

Prefixing the path with ../:

{% from "../badge/large/macro.njk" import nhsappBadgeLarge %}

Error 2

Couldn't find the icons macro.

Template render error: (/Users/davidhunter/Documents/prototypes/nhs-app-design-styles-components-patterns/node_modules/nhsapp-frontend/dist/nhsapp/components/card/card.njk)
Error: template not found: icon/macro.njk

Fix

Prefixing the paths with ../../ and ../:

{% from "../../styles/icon/macro.njk" import nhsappIcon %}

{% import "../icon/icons.njk" as iconHtml %}

Error 3

Couldn't find the icon svgs.

Template render error: (/Users/davidhunter/Documents/prototypes/nhs-app-design-styles-components-patterns/node_modules/nhsapp-frontend/dist/nhsapp/components/card/card.njk)
Error: template not found: icons/chevron-right.svg

Fix

Prefixing all the icons with ../../assets/:

{% include "../../assets/icons/account.svg" %}

Summary

Updating the paths in the macros fixes the problem:

Screenshot 2024-08-22 at 11 20 16

Is it the best solution? Is there a smarter way to do this?

@davidhunter08
Copy link
Collaborator Author

davidhunter08 commented Aug 22, 2024

Screenshot showing all the components Nunjucks macros working in the HTML prototype kit with these changes.

screencapture-localhost-3000-nhs-app-components-2024-08-22-11_28_13

Copy link
Collaborator

@edwardscull edwardscull left a comment

Choose a reason for hiding this comment

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

Discussed offline and feel relative paths are a better approach overall 👍

@davidhunter08 davidhunter08 merged commit 8994fa6 into main Sep 3, 2024
4 checks passed
@davidhunter08 davidhunter08 deleted the macro-paths-update branch September 3, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants