Skip to content

Commit

Permalink
feat: adds option to have several links
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Dec 2, 2024
1 parent 9898947 commit 0055bc1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/components/sections/image-split/ImageSplit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ const ImageSplitComponent = ({ section }: ImageSplitProps) => {
/>
)}

{section.link && (
{section.actions.length > 0 && (
<div className={styles.textContainer__link}>
<LinkButton isSmall link={section.link} />
{section.actions.map((action, index) => (
<LinkButton
key={action._key}
type={index === 0 ? "primary" : "secondary"}
isSmall
link={action}
/>
))}
</div>
)}
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/components/sections/image-split/image-split.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

.textContainer__link {
margin-top: 1.5rem;
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}

.image {
Expand Down
2 changes: 1 addition & 1 deletion studio/lib/interfaces/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface ImageSplitSection {
basicTitle: string;
imageExtended: ImageExtendedProps;
richText?: PortableTextBlock[];
link?: ILink;
actions: ILink[];
}

export interface GridSection {
Expand Down
2 changes: 1 addition & 1 deletion studio/lib/queries/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const SECTIONS_FRAGMENT = groq`
},
_type == "imageSplitSection" => {
...,
link {
actions[] {
...,
${TRANSLATED_LINK_FRAGMENT}
}
Expand Down
12 changes: 11 additions & 1 deletion studio/schemas/objects/sections/imagesplit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ export const imageSplitSection = defineField({
name: imageID,
title: "Image Split",
type: "object",
fields: [title, richText, imageExtended, link],
fields: [
title,
richText,
imageExtended,
{
name: "actions",
title: "Actions (links)",
type: "array",
of: [link],
},
],
preview: {
select: {
title: "basicTitle",
Expand Down

0 comments on commit 0055bc1

Please sign in to comment.