-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dd531b
commit 3eed0f4
Showing
7 changed files
with
91 additions
and
11 deletions.
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
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,38 @@ | ||
import { ExoticComponent } from 'react'; | ||
import { Typography } from '@signalco/ui-primitives/Typography'; | ||
import { IconButton } from '@signalco/ui-primitives/IconButton'; | ||
import { MoreHorizontal } from '@signalco/ui-icons'; | ||
import { SectionData } from '../SectionData'; | ||
|
||
export function SectionsEditor({ sectionsData, componentsRegistry }: { sectionsData: SectionData[]; componentsRegistry: { [key: string]: ExoticComponent<SectionData>; }; }) { | ||
const handleSectionEdit = (sectionData: SectionData) => { | ||
console.log('Edit', sectionData); | ||
}; | ||
|
||
return ( | ||
<div> | ||
{sectionsData.map((sectionData, index) => { | ||
const Section = sectionData.component ? componentsRegistry[sectionData.component] : null; | ||
if (!Section) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="group relative" key={index}> | ||
<div className="pointer-events-none absolute inset-0 rounded-md border opacity-0 transition-opacity group-hover:opacity-100" /> | ||
<IconButton | ||
onClick={() => handleSectionEdit(sectionData)} | ||
variant="soft" | ||
className="absolute left-0 top-0 rounded-r-none rounded-bl-none opacity-0 transition-opacity group-hover:opacity-100"> | ||
<MoreHorizontal /> | ||
</IconButton> | ||
<Typography level="body2" className="absolute left-12 top-2 text-center opacity-0 transition-opacity group-hover:opacity-100"> | ||
{sectionData.component} | ||
</Typography> | ||
<Section {...sectionData} /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
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,30 @@ | ||
import { ExoticComponent } from 'react'; | ||
import { SectionData } from '../SectionData'; | ||
|
||
export type CmsComponentRegistry = { | ||
[key: string]: ExoticComponent<SectionData>; | ||
}; | ||
|
||
export type CmsSectionsViewProps = { | ||
sectionsData: SectionData[]; | ||
componentsRegistry: CmsComponentRegistry; | ||
}; | ||
|
||
export function SectionsView({ sectionsData, componentsRegistry }: CmsSectionsViewProps) { | ||
return ( | ||
<div> | ||
{sectionsData.map((sectionData, index) => { | ||
const Section = sectionData.component ? componentsRegistry[sectionData.component] : null; | ||
if (!Section) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Section key={index} {...sectionData} /> | ||
); | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
|
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 * from './SectionsView'; | ||
export * from './SectionsEditor'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.