-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from buildheadless/templates
Add collection and product templates
- Loading branch information
Showing
14 changed files
with
209 additions
and
36 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
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
40 changes: 40 additions & 0 deletions
40
templates/hydrogen-theme/studio/schemas/documents/collectionTemplate.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,40 @@ | ||
import {StringRule, ValidationContext, defineField, defineType} from 'sanity'; | ||
import {validateDefaultStatus} from '../../utils/setAsDefaultValidation'; | ||
import {LayoutTemplate} from 'lucide-react'; | ||
|
||
export default defineType({ | ||
name: 'collectionTemplate', | ||
type: 'document', | ||
__experimental_formPreviewTitle: false, | ||
fields: [ | ||
defineField({ | ||
name: 'name', | ||
title: 'Template name', | ||
type: 'string', | ||
validation: (Rule: StringRule) => Rule.required(), | ||
}), | ||
defineField({ | ||
name: 'default', | ||
title: 'Set as default template', | ||
type: 'boolean', | ||
validation: (Rule) => | ||
Rule.required().custom(async (value, context: ValidationContext) => | ||
validateDefaultStatus(value, context), | ||
), | ||
initialValue: false, | ||
}), | ||
], | ||
preview: { | ||
select: { | ||
title: 'name', | ||
subtitle: 'default', | ||
}, | ||
prepare({title, subtitle}) { | ||
return { | ||
title, | ||
subtitle: subtitle ? 'Default template' : undefined, | ||
media: LayoutTemplate, | ||
}; | ||
}, | ||
}, | ||
}); |
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
44 changes: 44 additions & 0 deletions
44
templates/hydrogen-theme/studio/schemas/documents/productTemplate.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,44 @@ | ||
import {StringRule, ValidationContext, defineField, defineType} from 'sanity'; | ||
import {LayoutTemplate} from 'lucide-react'; | ||
import {validateDefaultStatus} from '../../utils/setAsDefaultValidation'; | ||
|
||
export default defineType({ | ||
name: 'productTemplate', | ||
type: 'document', | ||
__experimental_formPreviewTitle: false, | ||
fields: [ | ||
defineField({ | ||
name: 'name', | ||
title: 'Template name', | ||
type: 'string', | ||
validation: (Rule: StringRule) => Rule.required(), | ||
}), | ||
defineField({ | ||
name: 'default', | ||
title: 'Set as default template', | ||
type: 'boolean', | ||
validation: (Rule) => | ||
Rule.required().custom(async (value, context: ValidationContext) => | ||
validateDefaultStatus(value, context), | ||
), | ||
initialValue: false, | ||
}), | ||
defineField({ | ||
name: 'sections', | ||
type: 'productSections', | ||
}), | ||
], | ||
preview: { | ||
select: { | ||
title: 'name', | ||
subtitle: 'default', | ||
}, | ||
prepare({title, subtitle}) { | ||
return { | ||
title, | ||
subtitle: subtitle ? 'Default template' : undefined, | ||
media: LayoutTemplate, | ||
}; | ||
}, | ||
}, | ||
}); |
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
Oops, something went wrong.