react-google-reviews
Advanced tools
Comparing version 1.1.0 to 1.1.1
import React from "react"; | ||
import "../../css/index.css"; | ||
import { DateDisplay, GoogleReview, LogoVariant, NameDisplay, ReviewVariant, Theme } from "../../types/review"; | ||
interface ReactGoogleReviewsBaseProps { | ||
type StructuredDataProps = { | ||
/** | ||
* Total number of reviews. | ||
* This is automatically fetched when passing `featurableId`. | ||
* Required if `structuredData` is true and passing `reviews`. | ||
*/ | ||
totalReviewCount?: number; | ||
/** | ||
* Average star rating from 1 to 5. | ||
* This is automatically fetched when passing `featurableId`. | ||
* Required if `structuredData` is true and passing `reviews`. | ||
*/ | ||
averageRating?: number; | ||
}; | ||
type ReactGoogleReviewsBaseProps = { | ||
/** | ||
* Layout of the reviews. | ||
@@ -63,4 +77,4 @@ */ | ||
accessibility?: boolean; | ||
} | ||
interface ReactGoogleReviewsWithPlaceIdProps extends ReactGoogleReviewsBaseProps { | ||
} & StructuredDataProps; | ||
type ReactGoogleReviewsWithPlaceIdBaseProps = ReactGoogleReviewsBaseProps & { | ||
/** | ||
@@ -72,4 +86,11 @@ * If using Google Places API, use `dangerouslyFetchPlaceDetails` to get reviews server-side and pass them to the client. | ||
featurableId?: never; | ||
} | ||
interface ReactGoogleReviewsWithFeaturableIdProps extends ReactGoogleReviewsBaseProps { | ||
}; | ||
type ReactGoogleReviewsWithPlaceIdWithStructuredDataProps = { | ||
structuredData: true; | ||
} & Required<StructuredDataProps>; | ||
type ReactGoogleReviewsWithPlaceIdWithoutStructuredDataProps = { | ||
structuredData?: false; | ||
}; | ||
type ReactGoogleReviewsWithPlaceIdProps = ReactGoogleReviewsWithPlaceIdBaseProps & (ReactGoogleReviewsWithPlaceIdWithStructuredDataProps | ReactGoogleReviewsWithPlaceIdWithoutStructuredDataProps); | ||
type ReactGoogleReviewsWithFeaturableIdProps = ReactGoogleReviewsBaseProps & { | ||
reviews?: never; | ||
@@ -82,5 +103,5 @@ /** | ||
featurableId: string; | ||
} | ||
type ReactGooglereviewsBasePropsWithRequired = ReactGoogleReviewsBaseProps & (ReactGoogleReviewsWithPlaceIdProps | ReactGoogleReviewsWithFeaturableIdProps); | ||
type ReactGoogleReviewsCarouselProps = ReactGooglereviewsBasePropsWithRequired & { | ||
}; | ||
type ReactGoogleReviewsBasePropsWithRequired = ReactGoogleReviewsBaseProps & (ReactGoogleReviewsWithPlaceIdProps | ReactGoogleReviewsWithFeaturableIdProps); | ||
type ReactGoogleReviewsCarouselProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "carousel"; | ||
@@ -103,11 +124,11 @@ /** | ||
}; | ||
type ReactGoogleReviewsBadgeProps = ReactGooglereviewsBasePropsWithRequired & { | ||
type ReactGoogleReviewsBadgeProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "badge"; | ||
/** | ||
* Google profile URL, if manually fetching Google Places API. | ||
* This is automatically fetched when using the Featurable API. | ||
* Google profile URL, if manually fetching Google Places API and passing `reviews`. | ||
* This is automatically fetched when passing `featurableId`. | ||
*/ | ||
profileUrl?: string; | ||
}; | ||
type ReactGoogleReviewsCustomProps = ReactGooglereviewsBasePropsWithRequired & { | ||
type ReactGoogleReviewsCustomProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "custom"; | ||
@@ -114,0 +135,0 @@ renderer: (reviews: GoogleReview[]) => React.ReactNode; |
import { ReactGoogleReviews } from "./components"; | ||
import "./css/index.css"; | ||
import { dangerouslyFetchPlaceReviews } from "./lib/fetchPlaceReviews"; | ||
export { ReactGoogleReviews, dangerouslyFetchPlaceReviews }; | ||
import { FeaturableAPIResponse, GoogleReview } from "./types/review"; | ||
export { FeaturableAPIResponse, GoogleReview as ReactGoogleReview, ReactGoogleReviews, dangerouslyFetchPlaceReviews, }; |
import React from "react"; | ||
import "../../css/index.css"; | ||
import { DateDisplay, GoogleReview, LogoVariant, NameDisplay, ReviewVariant, Theme } from "../../types/review"; | ||
interface ReactGoogleReviewsBaseProps { | ||
type StructuredDataProps = { | ||
/** | ||
* Total number of reviews. | ||
* This is automatically fetched when passing `featurableId`. | ||
* Required if `structuredData` is true and passing `reviews`. | ||
*/ | ||
totalReviewCount?: number; | ||
/** | ||
* Average star rating from 1 to 5. | ||
* This is automatically fetched when passing `featurableId`. | ||
* Required if `structuredData` is true and passing `reviews`. | ||
*/ | ||
averageRating?: number; | ||
}; | ||
type ReactGoogleReviewsBaseProps = { | ||
/** | ||
* Layout of the reviews. | ||
@@ -63,4 +77,4 @@ */ | ||
accessibility?: boolean; | ||
} | ||
interface ReactGoogleReviewsWithPlaceIdProps extends ReactGoogleReviewsBaseProps { | ||
} & StructuredDataProps; | ||
type ReactGoogleReviewsWithPlaceIdBaseProps = ReactGoogleReviewsBaseProps & { | ||
/** | ||
@@ -72,4 +86,11 @@ * If using Google Places API, use `dangerouslyFetchPlaceDetails` to get reviews server-side and pass them to the client. | ||
featurableId?: never; | ||
} | ||
interface ReactGoogleReviewsWithFeaturableIdProps extends ReactGoogleReviewsBaseProps { | ||
}; | ||
type ReactGoogleReviewsWithPlaceIdWithStructuredDataProps = { | ||
structuredData: true; | ||
} & Required<StructuredDataProps>; | ||
type ReactGoogleReviewsWithPlaceIdWithoutStructuredDataProps = { | ||
structuredData?: false; | ||
}; | ||
type ReactGoogleReviewsWithPlaceIdProps = ReactGoogleReviewsWithPlaceIdBaseProps & (ReactGoogleReviewsWithPlaceIdWithStructuredDataProps | ReactGoogleReviewsWithPlaceIdWithoutStructuredDataProps); | ||
type ReactGoogleReviewsWithFeaturableIdProps = ReactGoogleReviewsBaseProps & { | ||
reviews?: never; | ||
@@ -82,5 +103,5 @@ /** | ||
featurableId: string; | ||
} | ||
type ReactGooglereviewsBasePropsWithRequired = ReactGoogleReviewsBaseProps & (ReactGoogleReviewsWithPlaceIdProps | ReactGoogleReviewsWithFeaturableIdProps); | ||
type ReactGoogleReviewsCarouselProps = ReactGooglereviewsBasePropsWithRequired & { | ||
}; | ||
type ReactGoogleReviewsBasePropsWithRequired = ReactGoogleReviewsBaseProps & (ReactGoogleReviewsWithPlaceIdProps | ReactGoogleReviewsWithFeaturableIdProps); | ||
type ReactGoogleReviewsCarouselProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "carousel"; | ||
@@ -103,11 +124,11 @@ /** | ||
}; | ||
type ReactGoogleReviewsBadgeProps = ReactGooglereviewsBasePropsWithRequired & { | ||
type ReactGoogleReviewsBadgeProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "badge"; | ||
/** | ||
* Google profile URL, if manually fetching Google Places API. | ||
* This is automatically fetched when using the Featurable API. | ||
* Google profile URL, if manually fetching Google Places API and passing `reviews`. | ||
* This is automatically fetched when passing `featurableId`. | ||
*/ | ||
profileUrl?: string; | ||
}; | ||
type ReactGoogleReviewsCustomProps = ReactGooglereviewsBasePropsWithRequired & { | ||
type ReactGoogleReviewsCustomProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "custom"; | ||
@@ -114,0 +135,0 @@ renderer: (reviews: GoogleReview[]) => React.ReactNode; |
import { ReactGoogleReviews } from "./components"; | ||
import "./css/index.css"; | ||
import { dangerouslyFetchPlaceReviews } from "./lib/fetchPlaceReviews"; | ||
export { ReactGoogleReviews, dangerouslyFetchPlaceReviews }; | ||
import { FeaturableAPIResponse, GoogleReview } from "./types/review"; | ||
export { FeaturableAPIResponse, GoogleReview as ReactGoogleReview, ReactGoogleReviews, dangerouslyFetchPlaceReviews, }; |
@@ -24,5 +24,34 @@ import React from 'react'; | ||
type Theme = "light" | "dark"; | ||
interface FeaturableAPIResponseBase { | ||
success: boolean; | ||
} | ||
interface FeaturableAPIResponseSuccess extends FeaturableAPIResponseBase { | ||
success: true; | ||
profileUrl: string | null; | ||
batchSize: number; | ||
totalReviewCount: number; | ||
averageRating: number; | ||
reviews: GoogleReview[]; | ||
} | ||
interface FeaturableAPIResponseError extends FeaturableAPIResponseBase { | ||
success: false; | ||
} | ||
type FeaturableAPIResponse = FeaturableAPIResponseSuccess | FeaturableAPIResponseError; | ||
interface ReactGoogleReviewsBaseProps { | ||
type StructuredDataProps = { | ||
/** | ||
* Total number of reviews. | ||
* This is automatically fetched when passing `featurableId`. | ||
* Required if `structuredData` is true and passing `reviews`. | ||
*/ | ||
totalReviewCount?: number; | ||
/** | ||
* Average star rating from 1 to 5. | ||
* This is automatically fetched when passing `featurableId`. | ||
* Required if `structuredData` is true and passing `reviews`. | ||
*/ | ||
averageRating?: number; | ||
}; | ||
type ReactGoogleReviewsBaseProps = { | ||
/** | ||
* Layout of the reviews. | ||
@@ -85,4 +114,4 @@ */ | ||
accessibility?: boolean; | ||
} | ||
interface ReactGoogleReviewsWithPlaceIdProps extends ReactGoogleReviewsBaseProps { | ||
} & StructuredDataProps; | ||
type ReactGoogleReviewsWithPlaceIdBaseProps = ReactGoogleReviewsBaseProps & { | ||
/** | ||
@@ -94,4 +123,11 @@ * If using Google Places API, use `dangerouslyFetchPlaceDetails` to get reviews server-side and pass them to the client. | ||
featurableId?: never; | ||
} | ||
interface ReactGoogleReviewsWithFeaturableIdProps extends ReactGoogleReviewsBaseProps { | ||
}; | ||
type ReactGoogleReviewsWithPlaceIdWithStructuredDataProps = { | ||
structuredData: true; | ||
} & Required<StructuredDataProps>; | ||
type ReactGoogleReviewsWithPlaceIdWithoutStructuredDataProps = { | ||
structuredData?: false; | ||
}; | ||
type ReactGoogleReviewsWithPlaceIdProps = ReactGoogleReviewsWithPlaceIdBaseProps & (ReactGoogleReviewsWithPlaceIdWithStructuredDataProps | ReactGoogleReviewsWithPlaceIdWithoutStructuredDataProps); | ||
type ReactGoogleReviewsWithFeaturableIdProps = ReactGoogleReviewsBaseProps & { | ||
reviews?: never; | ||
@@ -104,5 +140,5 @@ /** | ||
featurableId: string; | ||
} | ||
type ReactGooglereviewsBasePropsWithRequired = ReactGoogleReviewsBaseProps & (ReactGoogleReviewsWithPlaceIdProps | ReactGoogleReviewsWithFeaturableIdProps); | ||
type ReactGoogleReviewsCarouselProps = ReactGooglereviewsBasePropsWithRequired & { | ||
}; | ||
type ReactGoogleReviewsBasePropsWithRequired = ReactGoogleReviewsBaseProps & (ReactGoogleReviewsWithPlaceIdProps | ReactGoogleReviewsWithFeaturableIdProps); | ||
type ReactGoogleReviewsCarouselProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "carousel"; | ||
@@ -125,11 +161,11 @@ /** | ||
}; | ||
type ReactGoogleReviewsBadgeProps = ReactGooglereviewsBasePropsWithRequired & { | ||
type ReactGoogleReviewsBadgeProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "badge"; | ||
/** | ||
* Google profile URL, if manually fetching Google Places API. | ||
* This is automatically fetched when using the Featurable API. | ||
* Google profile URL, if manually fetching Google Places API and passing `reviews`. | ||
* This is automatically fetched when passing `featurableId`. | ||
*/ | ||
profileUrl?: string; | ||
}; | ||
type ReactGoogleReviewsCustomProps = ReactGooglereviewsBasePropsWithRequired & { | ||
type ReactGoogleReviewsCustomProps = ReactGoogleReviewsBasePropsWithRequired & { | ||
layout: "custom"; | ||
@@ -169,2 +205,2 @@ renderer: (reviews: GoogleReview[]) => React.ReactNode; | ||
export { ReactGoogleReviews, dangerouslyFetchPlaceReviews }; | ||
export { type FeaturableAPIResponse, type GoogleReview as ReactGoogleReview, ReactGoogleReviews, dangerouslyFetchPlaceReviews }; |
{ | ||
"name": "react-google-reviews", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A React component to easily display Google reviews using Google Places API or Google My Business API.", | ||
@@ -41,2 +41,3 @@ "scripts": { | ||
"rollup": "^4.18.0", | ||
"rollup-plugin-analyzer": "^4.0.0", | ||
"rollup-plugin-dts": "^6.1.1", | ||
@@ -58,5 +59,5 @@ "rollup-plugin-peer-deps-external": "^2.2.4", | ||
"peerDependencies": { | ||
"@types/react": "^18.3.3", | ||
"react": ">= 16.8 || 18.0.0", | ||
"react-dom": ">= 16.8 || 18.0.0", | ||
"@types/react": "^18.3.3" | ||
"react-dom": ">= 16.8 || 18.0.0" | ||
}, | ||
@@ -63,0 +64,0 @@ "dependencies": { |
@@ -167,2 +167,4 @@ | ||
### Common Props | ||
| Prop | Type | Description | | ||
@@ -184,7 +186,17 @@ | --- | --- | --- | | ||
| accessibility? | boolean | Enable/disable accessibility features | | ||
| --- | **Carousel Props** | --- | | ||
| totalReviewCount? | number | Total number of reviews on Google Business profile. This is automatically fetched if using `featurableId`. Otherwise, this is required if passing reviews manually and `structuredData` is true. | | ||
| averageRating? | number | Average rating for Google Business profile. This is automatically fetched if using `featurableId`. Otherwise, this is required if passing reviews manually and `structuredData` is true. | | ||
### Carousel Props | ||
| Prop | Type | Description | | ||
| --- | --- | --- | | ||
| carouselSpeed? | number | Autoplay speed of the carousel in milliseconds | | ||
| carouselAutoplay? | boolean | Whether to autoplay the carousel | | ||
| maxItems? | number | Maximum number of items to display at any one time in carousel | | ||
| --- | **Badge Props** | --- | | ||
### Badge Props | ||
| Prop | Type | Description | | ||
| --- | --- | --- | | ||
| profileUrl? | string | Link to Google Business profile, if manually fetching reviews via Place API. Using Featurable API will automatically supply this URL. | | ||
@@ -191,0 +203,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
847739
1428
212
21