-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#516591: Add missing Headless row splitter component (#1146)
- Loading branch information
1 parent
29b4d83
commit e9d6650
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
packages/create-sitecore-jss/src/templates/nextjs-sxa/src/components/RowSplitter.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,45 @@ | ||
import React from 'react'; | ||
import { | ||
ComponentParams, | ||
ComponentRendering, | ||
Placeholder, | ||
} from '@sitecore-jss/sitecore-jss-nextjs'; | ||
|
||
interface ComponentProps { | ||
rendering: ComponentRendering & { params: ComponentParams }; | ||
params: ComponentParams; | ||
} | ||
|
||
export const Default = (props: ComponentProps): JSX.Element => { | ||
const styles = `${props.params.GridParameters ?? ''} ${props.params.Styles ?? ''}`.trimEnd(); | ||
const rowStyles = [ | ||
props.params.Styles1, | ||
props.params.Styles2, | ||
props.params.Styles3, | ||
props.params.Styles4, | ||
props.params.Styles5, | ||
props.params.Styles6, | ||
props.params.Styles7, | ||
props.params.Styles8, | ||
]; | ||
const enabledPlaceholders = props.params.EnabledPlaceholders.split(','); | ||
|
||
return ( | ||
<div className={`component row-splitter ${styles}`}> | ||
{enabledPlaceholders.map((ph, index) => { | ||
const phKey = `row-${ph}-{*}`; | ||
const phStyles = `${rowStyles[+ph - 1] ?? ''}`.trimEnd(); | ||
|
||
return ( | ||
<div key={index} className={`container-fluid ${phStyles}`.trimEnd()}> | ||
<div key={index}> | ||
<div key={index} className="row"> | ||
<Placeholder key={index} name={phKey} rendering={props.rendering} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
}; |