Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions src/blocks/Image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { Block } from "payload";

export const ImageBlock: Block = {
slug: 'image',
labels: { singular: 'Image', plural: 'Images' },
fields: [
{
name: 'image',
type: 'upload',
label: 'Image',
relationTo: 'media',
required: true,
admin: {
description: 'Select an image to display',
},
},
{
name: 'altText',
type: 'text',
label: 'Alt Text',
admin: {
description: 'Image description for accessibility',
},
},
{
name: 'width',
type: 'select',
label: 'Image Width',
defaultValue: 'tablet',
options: [
{ label: 'Full Width', value: 'full' },
{ label: 'Desktop (1024px)', value: 'desktop' },
{ label: 'Tablet (640px)', value: 'tablet' },
{ label: 'Mobile (480px)', value: 'mobile' },
{ label: 'Mobile Small (320px)', value: 'mobile-sm' },
{ label: 'Custom', value: 'custom' },
],
admin: {
description: 'Select the maximum width for this image',
},
},
{
name: 'customWidth',
type: 'text',
label: 'Custom Width',
admin: {
condition: (data, siblingData) => siblingData?.width === 'custom' || data?.width === 'custom',
description: 'Enter a custom width (e.g., "600px", "50%", "40rem")',
},
},
{
name: 'align',
type: 'select',
label: 'Alignment',
defaultValue: 'left',
options: [
{ label: 'Left', value: 'left' },
{ label: 'Center', value: 'center' },
{ label: 'Right', value: 'right' },
],
admin: {
description: 'Align the image horizontally',
},
},
],
}
66 changes: 19 additions & 47 deletions src/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export interface Config {
'form-submissions': FormSubmission;
search: Search;
users: User;
'payload-kv': PayloadKv;
'payload-locked-documents': PayloadLockedDocument;
'payload-preferences': PayloadPreference;
'payload-migrations': PayloadMigration;
Expand Down Expand Up @@ -130,15 +129,13 @@ export interface Config {
'form-submissions': FormSubmissionsSelect<false> | FormSubmissionsSelect<true>;
search: SearchSelect<false> | SearchSelect<true>;
users: UsersSelect<false> | UsersSelect<true>;
'payload-kv': PayloadKvSelect<false> | PayloadKvSelect<true>;
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
};
db: {
defaultIDType: number;
};
fallbackLocale: null;
globals: {
'site-config': SiteConfig;
menu: Menu;
Expand Down Expand Up @@ -195,7 +192,7 @@ export interface Alert {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -287,7 +284,7 @@ export interface Post {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -426,7 +423,7 @@ export interface Event {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -514,7 +511,7 @@ export interface News {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -596,7 +593,7 @@ export interface Report {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -676,7 +673,7 @@ export interface Resource {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -757,7 +754,7 @@ export interface Leadership {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -852,7 +849,7 @@ export interface CustomCollectionPage {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -921,7 +918,7 @@ export interface Page {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -1048,7 +1045,7 @@ export interface Policy {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -1322,7 +1319,7 @@ export interface HomePageSiteCollection {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -1361,7 +1358,7 @@ export interface FooterSiteCollection {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -1754,7 +1751,7 @@ export interface NotFoundPageSiteCollection {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -1834,7 +1831,7 @@ export interface Form {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -1917,7 +1914,7 @@ export interface Form {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -1949,7 +1946,7 @@ export interface Form {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -2013,23 +2010,6 @@ export interface Search {
updatedAt: string;
createdAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv".
*/
export interface PayloadKv {
id: number;
key: string;
data:
| {
[k: string]: unknown;
}
| unknown[]
| string
| number
| boolean
| null;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents".
Expand Down Expand Up @@ -3258,14 +3238,6 @@ export interface UsersSelect<T extends boolean = true> {
apiKey?: T;
apiKeyIndex?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-kv_select".
*/
export interface PayloadKvSelect<T extends boolean = true> {
key?: T;
data?: T;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "payload-locked-documents_select".
Expand Down Expand Up @@ -3553,7 +3525,7 @@ export interface HomePage {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -3591,7 +3563,7 @@ export interface Footer {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down Expand Up @@ -3982,7 +3954,7 @@ export interface NotFoundPage {
root: {
type: string;
children: {
type: any;
type: string;
version: number;
[k: string]: unknown;
}[];
Expand Down
3 changes: 2 additions & 1 deletion src/utilities/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { AccordionBlock } from '@/blocks/Accordion'
import { CardGridBlock } from '@/blocks/CardGrid'
import { ProcessListBlock } from '@/blocks/ProcessList'
import { ImageBlock } from '@/blocks/Image'
import {
lexicalEditor,
FixedToolbarFeature,
Expand All @@ -15,7 +16,7 @@ export const editor = lexicalEditor({
FixedToolbarFeature(),
EXPERIMENTAL_TableFeature(),
BlocksFeature({
blocks: [ProcessListBlock, AccordionBlock, CardGridBlock],
blocks: [ProcessListBlock, AccordionBlock, CardGridBlock, ImageBlock],
}),
],
})