-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create review and ratings section structure (#2663)
## What's the purpose of this pull request? Establish the initial structure for the Review & Ratings section, enabling new components to branch from this foundation, thereby facilitating their testing and preview. ## How it works? - **Directory Creation**: A new directory has been created at `packages/core/src/components/sections/ReviewAndRatings`, following the Overridable section structure. - **Support Files**: Files have been added to `packages/core/src/components/plugins/overrides` and `packages/core/src/components/customizations/src/components` to support overrides. - **Product Page Integration**: The section has been integrated into the product page rendering component located at `packages/core/src/pages/[slug]/p.tsx`. - **CMS Configuration**: An entry for the Review and Ratings section has been added to the CMS JSON file at `packages/core/cms/faststore/sections.json`. Currently, only a `title` property is included; additional properties will be incorporated as new components are developed. <!--- Tell us the role of the new feature, or component, in its context. Provide details about what you have implemented and screenshots if applicable. ---> ## How to test it You can access the preview link and open any pdp. It already should be able to show the reviews sections with the title `Reviews`. If the title doesn't appear you can run `yarn cms-sync` in the `start.store` [branch](vtex-sites/starter.store#686) <!--- Describe the steps with bullet points. Is there any external link that can be used to better test it or an example? ---> ### Starters Deploy Preview [Preview](https://starter-git-feat-preview-review-ratings-section-vtex.vercel.app/) <!--- Add a link to a deploy preview from `starter.store` with this branch being used. ---> <!--- Tip: You can get an installable version of this branch from the CodeSandbox generated when this PR is created. ---> ## References [Jira Task: SFS-2084](https://vtex-dev.atlassian.net/browse/SFS-2084)
- Loading branch information
1 parent
2203c7f
commit 9c2cebb
Showing
13 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/core/src/components/sections/ReviewsAndRatings/DefaultComponents.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const ReviewsAndRatingsDefaultComponents = { | ||
// TODO: Update this with the components that will be used in ReviewsAndRatings section | ||
// Olhar o packages/core/src/components/sections/ProductGallery/DefaultComponents.ts | ||
// ou o packages/core/src/components/sections/ProductShelf/DefaultComponents.ts | ||
// para se basear | ||
} as const |
16 changes: 16 additions & 0 deletions
16
...ages/core/src/components/sections/ReviewsAndRatings/OverriddenDefaultReviewsAndRatings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { override } from 'src/customizations/src/components/overrides/ReviewsAndRatings' | ||
import { override as overridePlugin } from 'src/plugins/overrides/ReviewsAndRatings' | ||
import { getOverriddenSection } from 'src/sdk/overrides/getOverriddenSection' | ||
import type { SectionOverrideDefinitionV1 } from 'src/typings/overridesDefinition' | ||
import ReviewsAndRatings from '.' | ||
|
||
/** | ||
* This component exists to support overrides 1.0 | ||
* | ||
* This allows users to override the default ReviewsAndRatings section present in the Headless CMS | ||
*/ | ||
export const OverriddenDefaultReviewsAndRatings = getOverriddenSection({ | ||
...(overridePlugin as SectionOverrideDefinitionV1<'ReviewsAndRatings'>), | ||
...(override as SectionOverrideDefinitionV1<'ReviewsAndRatings'>), | ||
Section: ReviewsAndRatings, | ||
}) |
31 changes: 31 additions & 0 deletions
31
packages/core/src/components/sections/ReviewsAndRatings/ReviewsAndRatings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useMemo } from 'react' | ||
|
||
import ReviewsAndRatings from '../../ui/ReviewsAndRatings' | ||
import styles from '../ReviewsAndRatings/section.module.scss' | ||
import Section from '../Section' | ||
import { ReviewsAndRatingsDefaultComponents } from './DefaultComponents' | ||
import { getOverridableSection } from '../../../sdk/overrides/getOverriddenSection' | ||
|
||
interface Props { | ||
title: string | ||
} | ||
const ReviewsAndRatingsSection = ({ title }: Props) => { | ||
return ( | ||
<Section | ||
id="reviews-and-ratings" | ||
className={`${styles.section} section-reviews-and-ratings layout__section`} | ||
> | ||
<ReviewsAndRatings title={title} /> | ||
</Section> | ||
) | ||
} | ||
|
||
const OverridableReviewsAndRatings = getOverridableSection< | ||
typeof ReviewsAndRatingsSection | ||
>( | ||
'ReviewsAndRatings', | ||
ReviewsAndRatingsSection, | ||
ReviewsAndRatingsDefaultComponents | ||
) | ||
|
||
export default OverridableReviewsAndRatings |
1 change: 1 addition & 0 deletions
1
packages/core/src/components/sections/ReviewsAndRatings/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './ReviewsAndRatings' |
6 changes: 6 additions & 0 deletions
6
packages/core/src/components/sections/ReviewsAndRatings/section.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@layer components { | ||
.section { | ||
// TODO: Ajustar esses componentes para a nova section ReviewsAndRatings | ||
// @import '@faststore/ui/src/components/atoms/Ratings/styles'; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
packages/core/src/components/ui/ReviewsAndRatings/ReviewsAndRatings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export type ReviewsAndRatingsProps = { | ||
title: string | ||
} | ||
|
||
function ReviewsAndRatings({ title, ...otherProps }: ReviewsAndRatingsProps) { | ||
return ( | ||
<> | ||
<h2 className="text__title-section layout__content">{title}</h2> | ||
</> | ||
) | ||
} | ||
|
||
export default ReviewsAndRatings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default } from './ReviewsAndRatings' | ||
export type { ReviewsAndRatingsProps } from './ReviewsAndRatings' |
11 changes: 11 additions & 0 deletions
11
packages/core/src/customizations/src/components/overrides/ReviewsAndRatings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This is an example of how it can be used on the starter. | ||
|
||
import type { SectionOverride } from 'src/typings/overrides' | ||
|
||
const SECTION = 'ReviewsAndRatings' as const | ||
|
||
const override: SectionOverride = { | ||
section: SECTION, | ||
} | ||
|
||
export { override } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// This is an example of how it can be used on the plugins. | ||
|
||
export { override } from 'src/customizations/src/components/overrides/ReviewsAndRatings' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters