Download next.js/examples/cms-sitecore-xmcloud/src/components/Promo.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.39 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/cms-sitecore-xmcloud/src/components/Promo.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/examples/cms-sitecore-xmcloud/src/components/Promo.tsx
-
curl -L -o Promo.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/examples/cms-sitecore-xmcloud/src/components/Promo.tsx
2.39 kB
| import React from "react"; | |
| import { | |
| Image as JssImage, | |
| Link as JssLink, | |
| RichText as JssRichText, | |
| ImageField, | |
| Field, | |
| LinkField, | |
| Text, | |
| } from "@sitecore-jss/sitecore-jss-nextjs"; | |
| interface Fields { | |
| PromoIcon: ImageField; | |
| PromoText: Field<string>; | |
| PromoLink: LinkField; | |
| PromoText2: Field<string>; | |
| } | |
| type PromoProps = { | |
| params: { [key: string]: string }; | |
| fields: Fields; | |
| }; | |
| const PromoDefaultComponent = (props: PromoProps): JSX.Element => ( | |
| <div className={`component promo ${props.params.styles}`}> | |
| <div className="component-content"> | |
| <span className="is-empty-hint">Promo</span> | |
| </div> | |
| </div> | |
| ); | |
| export const Default = (props: PromoProps): JSX.Element => { | |
| const id = props.params.RenderingIdentifier; | |
| if (props.fields) { | |
| return ( | |
| <div | |
| className={`component promo ${props.params.styles}`} | |
| id={id ? id : undefined} | |
| > | |
| <div className="component-content"> | |
| <div className="field-promoicon"> | |
| <JssImage field={props.fields.PromoIcon} /> | |
| </div> | |
| <div className="promo-text"> | |
| <div> | |
| <div className="field-promotext"> | |
| <JssRichText field={props.fields.PromoText} /> | |
| </div> | |
| </div> | |
| <div className="field-promolink"> | |
| <JssLink field={props.fields.PromoLink} /> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return <PromoDefaultComponent {...props} />; | |
| }; | |
| export const WithText = (props: PromoProps): JSX.Element => { | |
| const id = props.params.RenderingIdentifier; | |
| if (props.fields) { | |
| return ( | |
| <div | |
| className={`component promo ${props.params.styles}`} | |
| id={id ? id : undefined} | |
| > | |
| <div className="component-content"> | |
| <div className="field-promoicon"> | |
| <JssImage field={props.fields.PromoIcon} /> | |
| </div> | |
| <div className="promo-text"> | |
| <div> | |
| <div className="field-promotext"> | |
| <Text className="promo-text" field={props.fields.PromoText} /> | |
| </div> | |
| </div> | |
| <div className="field-promotext"> | |
| <Text className="promo-text" field={props.fields.PromoText2} /> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| return <PromoDefaultComponent {...props} />; | |
| }; | |