prismicio / prismic-react

React components and hooks to fetch and present Prismic content
https://prismic.io/docs/technologies/homepage-reactjs
Apache License 2.0
154 stars 40 forks source link

feat: provide a fallback string to `<PrismicText>` #126

Closed angeloashmore closed 2 years ago

angeloashmore commented 2 years ago

Types of changes

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:

🕊️

codecov-commenter commented 2 years ago

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%) :arrow_up:

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[bot] commented 2 years ago

size-limit report 📦

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