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: add fallback prop to <PrismicRichText> which is rendered when given an empty field #135

Merged
merged 1 commit into from
Mar 17, 2022

Conversation

angeloashmore
Copy link
Member

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 a fallback prop to <PrismicRichText>. The value given to fallback is rendered when <PrismicRichText> is given an empty field. If a fallback prop is not given, null is rendered (this is the existing functionality).

<PrismicRichText
  field={document.data.richTextField}
  fallback={<p>Empty content</p>}
/>

In this example, <p>Empty content</p> is rendered if document.data.richTextField is empty (i.e. nullish or contains no content).

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 Report

Merging #135 (16484ca) into master (3aeeda5) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #135   +/-   ##
=======================================
  Coverage   92.67%   92.67%           
=======================================
  Files          16       16           
  Lines         273      273           
  Branches       61       62    +1     
=======================================
  Hits          253      253           
  Misses          5        5           
  Partials       15       15           
Impacted Files Coverage Δ
src/PrismicRichText.tsx 96.29% <100.00%> (ø)

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 3aeeda5...16484ca. Read the comment docs.

@github-actions
Copy link

size-limit report 📦

Path Size
dist/index.js 4.42 KB (0%)
dist/index.cjs 6.3 KB (-0.02% 🔽)

@angeloashmore angeloashmore merged commit 1c6eacb into master Mar 17, 2022
@angeloashmore angeloashmore deleted the aa/prismicrichtext-fallback branch March 17, 2022 00:59
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