Created
February 22, 2024 11:11
-
-
Save gerhart92/64021bc9c3b752d0e4c7eae6ff6a64d8 to your computer and use it in GitHub Desktop.
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
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} />; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment