Closed angeloashmore closed 2 years ago
Merging #140 (e070946) into master (192bdf6) will increase coverage by
0.16%
. The diff coverage is93.93%
.
@@ Coverage Diff @@
## master #140 +/- ##
==========================================
+ Coverage 92.41% 92.58% +0.16%
==========================================
Files 16 18 +2
Lines 277 310 +33
Branches 62 72 +10
==========================================
+ Hits 256 287 +31
Misses 5 5
- Partials 16 18 +2
Impacted Files | Coverage Δ | |
---|---|---|
src/PrismicImage.tsx | 93.10% <93.10%> (ø) |
|
src/index.ts | 100.00% <100.00%> (ø) |
|
src/lib/devMsg.ts | 100.00% <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 192bdf6...e070946. Read the comment docs.
Path | Size |
---|---|
dist/index.js | 5.23 KB (+18.91% 🔺) |
dist/index.cjs | 6.75 KB (+7.13% 🔺) |
Types of changes
Description
This PR adds a
<PrismicImage>
component. It renders a Prismic Image field.This renders the following HTML (using placeholder values for the full image URLs).
Note that a viewport-width-based
srcset
is automatically generated. This takes advantage of Imgix's Image URL API which is available to all Prismic users by default.Note: Prefer using framework-specific image integrations over this component. For example, use Next.js's
next/image
component or Gatsby'sgatsby-plugin-image
component if you are using those frameworks. Only use<PrismicImage>
if your environment does not have a built-in optimized image component.Editing images with Imgix
Images can be edited through the image's URL parameters. This includes transformations like saturation, cropping, and blurring.
Arbitrary Imgix parameters can be provided using the
imgixParams
prop. See Imgix's Image URL API Reference for a full list of what's available.The
src
URL and each URL insrcset
will contain thesat: -100
URL parameter as a result:Customizing the
srcset
widthsThe widths used in the produced
srcset
can be controlled using thewidths
prop. It accepts the following values:[100, 200, 300]
)"thumbnails"
- This will use the Image field's thumbnails (also called responsive views) for each srcset value and its widths."defaults"
- Use a good set of defaults (currently[640, 750, 828, 1080, 1200, 1920, 2048, 3840]
)Using pixel density-based
srcset
sPixel density
srcset
s can also be generated in place of width-basedsrcset
s by using thepixelDensities
prop.This renders the following HTML (using placeholder values for the full image URLs).
The
pixelDensities
prop accepts the following values:[2, 4]
)"defaults"
- Use a good set of defaults (currently[1, 2, 3]
)Checklist:
🖼️🦙