-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(slice-machine-ui): update Slice Builder layout
- Loading branch information
Showing
18 changed files
with
125 additions
and
270 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
64 changes: 0 additions & 64 deletions
64
packages/slice-machine/lib/builders/SliceBuilder/Header/index.tsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
12 changes: 0 additions & 12 deletions
12
packages/slice-machine/lib/builders/SliceBuilder/SideBar/icons/prismic.svg
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-23.1 KB
packages/slice-machine/lib/builders/SliceBuilder/SideBar/icons/sb-logo.png
Binary file not shown.
13 changes: 0 additions & 13 deletions
13
packages/slice-machine/lib/builders/SliceBuilder/SideBar/icons/storybook.svg
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
packages/slice-machine/lib/builders/SliceBuilder/SideBar/icons/storybookGrey.svg
This file was deleted.
Oops, something went wrong.
File renamed without changes.
68 changes: 68 additions & 0 deletions
68
packages/slice-machine/lib/builders/SliceBuilder/Sidebar/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,68 @@ | ||
import { Button, ScrollArea, tokens } from "@prismicio/editor-ui"; | ||
import { useRouter } from "next/router"; | ||
import { type FC, useState } from "react"; | ||
|
||
import VariationModal from "@builders/SliceBuilder/Sidebar/VariationModal"; | ||
import type { ComponentUI } from "@lib/models/common/ComponentUI"; | ||
import type { VariationSM } from "@lib/models/common/Slice"; | ||
import { SharedSliceCard } from "@src/features/slices/sliceCards/SharedSliceCard"; | ||
import { SLICES_CONFIG } from "@src/features/slices/slicesConfig"; | ||
import useSliceMachineActions from "@src/modules/useSliceMachineActions"; | ||
|
||
type SidebarProps = { | ||
slice: ComponentUI; | ||
variation: VariationSM; | ||
}; | ||
|
||
export const Sidebar: FC<SidebarProps> = ({ slice, variation }) => { | ||
const router = useRouter(); | ||
const [showVariationModal, setShowVariationModal] = useState(false); | ||
const { copyVariationSlice } = useSliceMachineActions(); | ||
return ( | ||
<> | ||
<ScrollArea style={{ gap: tokens.space[16] }}> | ||
{slice.model.variations.map((v) => ( | ||
<SharedSliceCard | ||
action={{ type: "menu" }} | ||
key={v.id} | ||
mode="navigation" | ||
onUpdateScreenshot={() => { | ||
// TODO | ||
}} | ||
replace | ||
selected={v.id === variation.id} | ||
slice={slice} | ||
variant="outlined" | ||
variationId={v.id} | ||
/> | ||
))} | ||
<Button | ||
onClick={() => { | ||
setShowVariationModal(true); | ||
}} | ||
startIcon="add" | ||
variant="secondary" | ||
> | ||
Add a new variation | ||
</Button> | ||
</ScrollArea> | ||
<VariationModal | ||
initialVariation={variation} | ||
isOpen={showVariationModal} | ||
onClose={() => { | ||
setShowVariationModal(false); | ||
}} | ||
onSubmit={(id, name, copiedVariation) => { | ||
copyVariationSlice(id, name, copiedVariation); | ||
const url = SLICES_CONFIG.getBuilderPagePathname({ | ||
libraryName: slice.href, | ||
sliceName: slice.model.name, | ||
variationId: variation.id, | ||
}); | ||
void router.replace(url); | ||
}} | ||
variations={slice.model.variations} | ||
/> | ||
</> | ||
); | ||
}; |
File renamed without changes.
Oops, something went wrong.