-
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.
feature/add StepGuide component (#31)
* wd * add StepsGuide component to storyblok, update types, presets and components * add steps guide to sanity * add StepGuide to sanity * enhance sanity sections preview, add StepGuide to both richtexts * fix lock * change cursor * fix
- Loading branch information
1 parent
9206f81
commit 72315a9
Showing
33 changed files
with
1,172 additions
and
499 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.mjs |
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,28 @@ | ||
import EmptyBlock from "@shared/ui/components/EmptyBlock"; | ||
|
||
import { StepGuide as StepGuideUI } from "@shared/ui"; | ||
|
||
import { prepareImageProps } from "@/lib/adapters/prepareImageProps"; | ||
import { prepareLinkProps } from "@/lib/adapters/prepareLinkProps"; | ||
import SectionContainer from "@/components/SectionContainer"; | ||
|
||
import type { IStepsGuideProps } from "./types"; | ||
|
||
export default function StepGuide({ data }: IStepsGuideProps) { | ||
const { items, link } = data; | ||
|
||
if (!items || items.length === 0) { | ||
return <EmptyBlock name="Step Guide Section" />; | ||
} | ||
|
||
const formattedItems = items.map((item) => ({ | ||
...item, | ||
image: prepareImageProps(item?.image), | ||
})); | ||
|
||
return ( | ||
<SectionContainer sectionData={data}> | ||
<StepGuideUI items={formattedItems} link={prepareLinkProps(link)} /> | ||
</SectionContainer> | ||
); | ||
} |
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,71 @@ | ||
import { | ||
CommonGroup, | ||
commonGroups, | ||
sectionMarginFields, | ||
} from "@/contentSections/commonFields"; | ||
import { defineField, defineType } from "sanity"; | ||
|
||
import customImage from "@/lib/schemas/customImage"; | ||
import customLink from "@/lib/schemas/customLink"; | ||
|
||
export const stepGuideItem = defineType({ | ||
name: "stepGuideItem", | ||
type: "object", | ||
title: "Step Guide Item", | ||
fields: [ | ||
defineField({ | ||
name: "number", | ||
type: "string", | ||
validation: (Rule) => Rule.required(), | ||
initialValue: "01", | ||
}), | ||
defineField({ | ||
name: "text", | ||
type: "string", | ||
validation: (Rule) => Rule.required(), | ||
initialValue: "Some text", | ||
}), | ||
defineField({ | ||
name: "image", | ||
type: customImage.name, | ||
validation: (Rule) => Rule.required(), | ||
}), | ||
], | ||
}); | ||
|
||
export default { | ||
name: "section.stepGuide", | ||
title: "Step Guide", | ||
type: "object", | ||
groups: commonGroups, | ||
fields: [ | ||
defineField({ | ||
name: "items", | ||
type: "array", | ||
of: [{ type: stepGuideItem.name }], | ||
validation: (Rule) => Rule.required().min(1), | ||
group: CommonGroup.Content, | ||
}), | ||
defineField({ | ||
name: "link", | ||
type: customLink.name, | ||
validation: (Rule) => Rule.required(), | ||
group: CommonGroup.Content, | ||
}), | ||
...sectionMarginFields, | ||
], | ||
preview: { | ||
select: { | ||
number: "items.0.number", | ||
text: "items.0.text", | ||
image: "items.0.image.image", | ||
}, | ||
prepare(value: any) { | ||
return { | ||
media: value.image, | ||
subtitle: "Step Guide", | ||
title: `${value.number} ${value.text}`, | ||
}; | ||
}, | ||
}, | ||
}; |
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,7 @@ | ||
import { type SectionStepGuide } from "@/generated/extracted-types"; | ||
|
||
export interface IStepsGuideProps { | ||
data: SectionStepGuide & { | ||
_key: string; | ||
}; | ||
} |
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
Oops, something went wrong.