Skip to content

Commit

Permalink
feat: PrismicLink progress
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Apr 21, 2023
1 parent 57c836f commit 61020b5
Show file tree
Hide file tree
Showing 17 changed files with 696 additions and 1,177 deletions.
56 changes: 14 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 4 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@
"test": "npm run lint && npm run types && npm run unit && npm run build && npm run size"
},
"dependencies": {
"@prismicio/helpers": "^2.3.9",
"@prismicio/richtext": "^2.1.4",
"@prismicio/types": "^0.2.7"
"@prismicio/richtext": "^2.1.4"
},
"devDependencies": {
"@prismicio/client": "^6.7.3",
"@prismicio/client": "^7.0.0-alpha.1",
"@prismicio/mock": "^0.2.0",
"@size-limit/preset-small-lib": "^8.2.4",
"@testing-library/react": "^14.0.0",
Expand Down Expand Up @@ -102,13 +100,8 @@
"vitest": "^0.29.8"
},
"peerDependencies": {
"@prismicio/client": "^6",
"react": "^16.8 || ^17 || ^18"
},
"peerDependenciesMeta": {
"@prismicio/client": {
"optional": true
}
"@prismicio/client": "^7",
"react": "^18"
},
"engines": {
"node": ">=12.7.0"
Expand Down
17 changes: 8 additions & 9 deletions src/PrismicImage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from "react";
import * as prismicT from "@prismicio/types";
import * as prismicH from "@prismicio/helpers";
import * as prismic from "@prismicio/client";

import { __PRODUCTION__ } from "./lib/__PRODUCTION__";
import { devMsg } from "./lib/devMsg";
Expand All @@ -18,14 +17,14 @@ export type PrismicImageProps = Omit<
/**
* The Prismic Image field or thumbnail to render.
*/
field: prismicT.ImageFieldImage | null | undefined;
field: prismic.ImageFieldImage | null | undefined;

/**
* An object of Imgix URL API parameters to transform the image.
*
* See: https://docs.imgix.com/apis/rendering
*/
imgixParams?: Parameters<typeof prismicH.asImageSrc>[1];
imgixParams?: Parameters<typeof prismic.asImageSrc>[1];

/**
* Declare an image as decorative by providing `alt=""`.
Expand Down Expand Up @@ -58,7 +57,7 @@ export type PrismicImageProps = Omit<
*/
widths?:
| NonNullable<
Parameters<typeof prismicH.asImageWidthSrcSet>[1]
Parameters<typeof prismic.asImageWidthSrcSet>[1]
>["widths"]
| "defaults";
/**
Expand All @@ -79,7 +78,7 @@ export type PrismicImageProps = Omit<
*/
pixelDensities:
| NonNullable<
Parameters<typeof prismicH.asImagePixelDensitySrcSet>[1]
Parameters<typeof prismic.asImagePixelDensitySrcSet>[1]
>["pixelDensities"]
| "defaults";
}
Expand Down Expand Up @@ -123,20 +122,20 @@ const _PrismicImage = (
}
}

if (prismicH.isFilled.imageThumbnail(field)) {
if (prismic.isFilled.imageThumbnail(field)) {
let src: string | undefined;
let srcSet: string | undefined;

if (widths || !pixelDensities) {
const res = prismicH.asImageWidthSrcSet(field, {
const res = prismic.asImageWidthSrcSet(field, {
...imgixParams,
widths: widths === "defaults" ? undefined : widths,
});

src = res.src;
srcSet = res.srcset;
} else if (pixelDensities) {
const res = prismicH.asImagePixelDensitySrcSet(field, {
const res = prismic.asImagePixelDensitySrcSet(field, {
...imgixParams,
pixelDensities:
pixelDensities === "defaults" ? undefined : pixelDensities,
Expand Down
Loading

0 comments on commit 61020b5

Please sign in to comment.