-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V3-list-block-for-customer-cases (#790)
* Added block for list component * removed console.log * Update studioShared/schemas/objects/listBlock.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * Update studioShared/schemas/objects/listBlock.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * Update studioShared/schemas/objects/listBlock.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * Update studioShared/schemas/objects/listBlock.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * Update studioShared/lib/queries/customerCases.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * Update studioShared/schemas/objects/listBlock.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * Update studioShared/schemas/objects/listBlock.ts Co-authored-by: Mathias Oterhals Myklebust <[email protected]> * resolve conflicts --------- Co-authored-by: Mathias Oterhals Myklebust <[email protected]>
- Loading branch information
Showing
3 changed files
with
81 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { defineField } from "sanity"; | ||
|
||
import { isInternationalizedString } from "studio/lib/interfaces/global"; | ||
import { firstTranslation } from "studio/utils/i18n"; | ||
const listBlock = defineField({ | ||
name: "listBlock", | ||
title: "List Block", | ||
description: | ||
"This block could be used to add a list of skills, tools, methods etc. used for this project.", | ||
type: "object", | ||
fields: [ | ||
{ | ||
name: "description", | ||
title: "Description", | ||
description: | ||
"Please provide a brief sentence describing the list. For example: The following skills were applied in this project:", | ||
type: "internationalizedArrayString", | ||
}, | ||
{ | ||
name: "list", | ||
title: "List", | ||
description: | ||
"Add the items to be included in this list (e.g., skills, tools, methods).", | ||
type: "array", | ||
of: [ | ||
{ | ||
type: "object", // You need to define it as an object since it's a custom field | ||
title: "List Item", | ||
name: "listItem", | ||
fields: [ | ||
{ | ||
name: "text", | ||
title: "Text", | ||
type: "internationalizedArrayString", | ||
}, | ||
], | ||
preview: { | ||
select: { | ||
item: "text", | ||
}, | ||
prepare({ item }) { | ||
if (!isInternationalizedString(item)) { | ||
throw new TypeError( | ||
`Expected 'item' to be InternationalizedString, was ${typeof item}`, | ||
); | ||
} | ||
return { | ||
title: firstTranslation(item) ?? undefined, | ||
}; | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
preview: { | ||
select: { | ||
description: "description", | ||
}, | ||
prepare({ description }) { | ||
if (!isInternationalizedString(description)) { | ||
throw new TypeError( | ||
`Expected 'description' to be InternationalizedString, was ${typeof description}`, | ||
); | ||
} | ||
return { | ||
title: firstTranslation(description) ?? undefined, | ||
}; | ||
}, | ||
}, | ||
}); | ||
|
||
export default listBlock; |