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: provide a fallback string to <PrismicText> #126

Merged
merged 7 commits into from
Feb 25, 2022

Conversation

angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Feb 25, 2022

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR adds the ability to provide a fallback string to <PrismicText>. If the provided Rich Text or Title field is nullish, the fallback string is rendered. If a fallback string is not given, null is rendered (this is the existing functionality).

Example:

<PrismicText field={null} fallback="Untitled" />
// => <>Untitled</>

<PrismicText field={undefined} fallback="Untitled" />
// => <>Untitled</>

Closes #105

Checklist:

  • My change requires an update to the official documentation.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

🕊️

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2022

Codecov Report

Merging #126 (9e9a324) into master (ce32036) will increase coverage by 0.36%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #126      +/-   ##
==========================================
+ Coverage   92.25%   92.61%   +0.36%     
==========================================
  Files          16       16              
  Lines         271      271              
  Branches       60       61       +1     
==========================================
+ Hits          250      251       +1     
  Misses          5        5              
+ Partials       16       15       -1     
Impacted Files Coverage Δ
src/PrismicText.tsx 100.00% <100.00%> (ø)
src/usePrismicClient.ts 100.00% <0.00%> (+12.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update de1e8df...9e9a324. Read the comment docs.

@github-actions
Copy link

size-limit report 📦

Path Size
dist/index.js 4.11 KB (+0.41% 🔺)
dist/index.cjs 6.24 KB (+0.33% 🔺)

@angeloashmore angeloashmore merged commit e2fb4fc into master Feb 25, 2022
@angeloashmore angeloashmore deleted the aa/text-fallback branch February 25, 2022 02:32
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.

Add fallback prop to <PrismicText>
2 participants