Skip to content

[feat]: Add support for custom fonts#430

Open
shraddha-kesari wants to merge 9 commits intomasterfrom
custom-fonts
Open

[feat]: Add support for custom fonts#430
shraddha-kesari wants to merge 9 commits intomasterfrom
custom-fonts

Conversation

@shraddha-kesari
Copy link
Copy Markdown
Contributor

@shraddha-kesari shraddha-kesari commented May 15, 2023

Description

At present, we support only google fonts by doing this we can support all the origin urls which AMP supports.
We will Pick up custom font url from amp config that is added in Bold. Settings > configure > amp under Fonts

Ref ticket: https://github.com/quintype/ace-planning/issues/837

Dependencies # (dependency-issue-reference)

Documentation # (link to the corresponding documentation changes)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Add custom font url in the custom font field in Bold and check whether its reflecting in the frontend or not

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Comment thread src/atoms/fonts/fonts.tsx
* If added in public folder, mention the asset host and path in the url like this "https://fea.assettype.com/malibu/assets/
MalibuHeadlineSemiBold.woff2".
*
* The following origins are allowlisted and allowed for font serving via link tags as per official AMP documentation:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reframe the sentence The following origins are allowlisted and allowed ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That line is from the original docs.

Comment thread src/atoms/fonts/fonts.tsx
Comment on lines +24 to +27
<link rel="preload" as="style" crossorigin="anonymous" href={customFonts?.primary1} />
<link rel="preload" as="style" crossorigin="anonymous" href={customFonts?.secondary1} />
<link rel="preload" as="style" crossorigin="anonymous" href={customFonts?.primary2} />
<link rel="preload" as="style" crossorigin="anonymous" href={customFonts?.secondary2} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add condition to not add these links if there is no custom font

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure.

Comment thread src/types/config.ts
Comment on lines +153 to +158
customFonts?: {
primary1?: string | null;
secondary1?: string | null;
primary2?: string | null;
secondary2?: string | null;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

doesn't make sense to add custom fonts inside render
render is for render props (custom UI elements) that the app sends

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is temp fix.
Actually plan is to add in ampConfig of BOLD. Platform team might take sometime to do the change so decided to do this change.

We can add outside render as in opts itself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes.. let's add it outside render under an object called customFonts

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.

3 participants