Skip to content

Commit 3ea62da

Browse files
committed
refactor: extract shared section fields
1 parent 1454e59 commit 3ea62da

15 files changed

Lines changed: 131 additions & 618 deletions

src/blocks/ActionEventsBlock.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
1+
import { sectionFields } from "@/fields/sectionFields"
12
import type { Block } from "payload"
23

34
export const ActionEventsBlock: Block = {
45
slug: "actionEvents",
56
labels: { singular: "Action Events", plural: "Action Events Blocks" },
67
fields: [
7-
{
8-
type: "collapsible",
9-
label: "Section",
10-
fields: [
11-
{ name: "sectionHeading", label: "Section Heading", type: "text", required: false, localized: true },
12-
{
13-
name: "sectionLayout",
14-
label: "Section Layout",
15-
type: "select",
16-
required: true,
17-
defaultValue: "left",
18-
options: [
19-
{ label: "Center", value: "center" },
20-
{ label: "Left", value: "left" },
21-
],
22-
},
23-
{ name: "sectionDescription", label: "Section Description", type: "textarea", required: false, localized: true },
24-
{
25-
name: "sectionLinkButton",
26-
label: "Section Link Button",
27-
type: "group",
28-
fields: [
29-
{ name: "label", type: "text", required: false, localized: true },
30-
{ name: "url", type: "text", required: false },
31-
],
32-
},
33-
],
34-
},
8+
sectionFields({ layoutDefaultValue: "left" }),
359
{ name: "flowTypeLabel", type: "text", required: true, localized: true, defaultValue: "FlowType" },
3610
{ name: "settingsLabel", type: "text", required: true, localized: true, defaultValue: "Settings" },
3711
],

src/blocks/ActionFunctionsBlock.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
1+
import { sectionFields } from "@/fields/sectionFields"
12
import type { Block } from "payload"
23

34
export const ActionFunctionsBlock: Block = {
45
slug: "actionFunctions",
56
labels: { singular: "Action Functions", plural: "Action Functions Blocks" },
67
fields: [
7-
{
8-
type: "collapsible",
9-
label: "Section",
10-
fields: [
11-
{ name: "sectionHeading", label: "Section Heading", type: "text", required: false, localized: true },
12-
{
13-
name: "sectionLayout",
14-
label: "Section Layout",
15-
type: "select",
16-
required: true,
17-
defaultValue: "left",
18-
options: [
19-
{ label: "Center", value: "center" },
20-
{ label: "Left", value: "left" },
21-
],
22-
},
23-
{ name: "sectionDescription", label: "Section Description", type: "textarea", required: false, localized: true },
24-
{
25-
name: "sectionLinkButton",
26-
label: "Section Link Button",
27-
type: "group",
28-
fields: [
29-
{ name: "label", type: "text", required: false, localized: true },
30-
{ name: "url", type: "text", required: false },
31-
],
32-
},
33-
],
34-
},
8+
sectionFields({ layoutDefaultValue: "left" }),
359
{ name: "functionDefinitionLabel", type: "text", required: true, localized: true, defaultValue: "FunctionDefinition" },
3610
{ name: "parametersLabel", type: "text", required: true, localized: true, defaultValue: "Parameters" },
3711
],

src/blocks/ActionListBlock.ts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
1+
import { sectionFields } from "@/fields/sectionFields"
12
import type { Block } from "payload"
23

34
export const ActionListBlock: Block = {
45
slug: "actionList",
56
labels: { singular: "Action List", plural: "Action List Blocks" },
67
fields: [
7-
{
8-
type: "collapsible",
9-
label: "Section",
10-
fields: [
11-
{ name: "sectionHeading", label: "Section Heading", type: "text", required: false, localized: true, defaultValue: "Actions" },
12-
{
13-
name: "sectionLayout",
14-
label: "Section Layout",
15-
type: "select",
16-
required: true,
17-
defaultValue: "left",
18-
options: [
19-
{ label: "Center", value: "center" },
20-
{ label: "Left", value: "left" },
21-
],
22-
},
23-
{ name: "sectionDescription", label: "Section Description", type: "textarea", required: false, localized: true, defaultValue: "Browse available actions and integrations." },
24-
{
25-
name: "sectionLinkButton",
26-
label: "Section Link Button",
27-
type: "group",
28-
fields: [
29-
{ name: "label", type: "text", required: false, localized: true },
30-
{ name: "url", type: "text", required: false },
31-
],
32-
},
33-
],
34-
},
8+
sectionFields({
9+
headingDefaultValue: "Actions",
10+
descriptionDefaultValue: "Browse available actions and integrations.",
11+
layoutDefaultValue: "left",
12+
}),
3513
{ name: "searchPlaceholder", type: "text", required: true, localized: true, defaultValue: "Search actions" },
3614
{ name: "sortNewestLabel", type: "text", required: true, localized: true, defaultValue: "Newest" },
3715
{ name: "sortOldestLabel", type: "text", required: true, localized: true, defaultValue: "Oldest" },
Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
1+
import { sectionFields } from "@/fields/sectionFields"
12
import type { Block } from "payload"
23

34
export const ActionReferencesBlock: Block = {
45
slug: "actionReferences",
56
labels: { singular: "Action References", plural: "Action Reference Blocks" },
67
fields: [
7-
{
8-
type: "collapsible",
9-
label: "Section",
10-
fields: [
11-
{ name: "sectionHeading", label: "Section Heading", type: "text", required: false, localized: true, defaultValue: "References" },
12-
{
13-
name: "sectionLayout",
14-
label: "Section Layout",
15-
type: "select",
16-
required: true,
17-
defaultValue: "left",
18-
options: [
19-
{ label: "Center", value: "center" },
20-
{ label: "Left", value: "left" },
21-
],
22-
},
23-
{ name: "sectionDescription", label: "Section Description", type: "textarea", required: false, localized: true },
24-
{
25-
name: "sectionLinkButton",
26-
label: "Section Link Button",
27-
type: "group",
28-
fields: [
29-
{ name: "label", type: "text", required: false, localized: true },
30-
{ name: "url", type: "text", required: false },
31-
],
32-
},
33-
],
34-
},
8+
sectionFields({ headingDefaultValue: "References", layoutDefaultValue: "left" }),
359
],
3610
}

src/blocks/BentoBlock.ts

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { sectionFields } from "@/fields/sectionFields"
12
import type { Block } from "payload"
23

34
export const BentoBlock: Block = {
@@ -7,61 +8,7 @@ export const BentoBlock: Block = {
78
plural: "Bento Blocks",
89
},
910
fields: [
10-
{
11-
type: "collapsible",
12-
label: "Section",
13-
fields: [
14-
{
15-
name: "sectionHeading",
16-
label: "Section Heading",
17-
type: "text",
18-
required: false,
19-
localized: true,
20-
},
21-
{
22-
name: "sectionLayout",
23-
label: "Section Layout",
24-
type: "select",
25-
required: true,
26-
defaultValue: "center",
27-
options: [
28-
{
29-
label: "Center",
30-
value: "center",
31-
},
32-
{
33-
label: "Left",
34-
value: "left",
35-
},
36-
],
37-
},
38-
{
39-
name: "sectionDescription",
40-
label: "Section Description",
41-
type: "textarea",
42-
required: false,
43-
localized: true,
44-
},
45-
{
46-
name: "sectionLinkButton",
47-
label: "Section Link Button",
48-
type: "group",
49-
fields: [
50-
{
51-
name: "label",
52-
type: "text",
53-
required: false,
54-
localized: true,
55-
},
56-
{
57-
name: "url",
58-
type: "text",
59-
required: false,
60-
},
61-
],
62-
},
63-
],
64-
},
11+
sectionFields(),
6512
{
6613
name: "variant",
6714
label: "Variant",

src/blocks/BlogPreviewBlock.ts

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { sectionFields } from "@/fields/sectionFields"
12
import type { Block } from "payload"
23

34
export const BlogPreviewBlock: Block = {
@@ -7,47 +8,15 @@ export const BlogPreviewBlock: Block = {
78
plural: "Blog Previews",
89
},
910
fields: [
10-
{
11-
type: "collapsible",
12-
label: "Section",
13-
fields: [
14-
{
15-
name: "sectionHeading",
16-
label: "Section Heading",
17-
type: "text",
18-
required: false,
19-
localized: true,
20-
},
21-
{
22-
name: "sectionLayout",
23-
label: "Section Layout",
24-
type: "select",
25-
required: true,
26-
defaultValue: "imageCenter",
27-
options: [
28-
{
29-
label: "Image center",
30-
value: "imageCenter",
31-
},
32-
{
33-
label: "Image left",
34-
value: "imageLeft",
35-
},
36-
{
37-
label: "Image right",
38-
value: "imageRight",
39-
},
40-
],
41-
},
42-
{
43-
name: "sectionDescription",
44-
label: "Section Description",
45-
type: "textarea",
46-
required: false,
47-
localized: true,
48-
},
11+
sectionFields({
12+
includeLinkButton: false,
13+
layoutDefaultValue: "imageCenter",
14+
layoutOptions: [
15+
{ label: "Image center", value: "imageCenter" },
16+
{ label: "Image left", value: "imageLeft" },
17+
{ label: "Image right", value: "imageRight" },
4918
],
50-
},
19+
}),
5120
{
5221
name: "blog",
5322
label: "Blog",

src/blocks/CardRowBlock.ts

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { sectionFields } from "@/fields/sectionFields"
12
import type { Block } from "payload"
23

34
export const CardRowBlock: Block = {
@@ -7,61 +8,7 @@ export const CardRowBlock: Block = {
78
plural: "Card Rows",
89
},
910
fields: [
10-
{
11-
type: "collapsible",
12-
label: "Section",
13-
fields: [
14-
{
15-
name: "sectionHeading",
16-
label: "Section Heading",
17-
type: "text",
18-
required: false,
19-
localized: true,
20-
},
21-
{
22-
name: "sectionLayout",
23-
label: "Section Layout",
24-
type: "select",
25-
required: true,
26-
defaultValue: "center",
27-
options: [
28-
{
29-
label: "Center",
30-
value: "center",
31-
},
32-
{
33-
label: "Left",
34-
value: "left",
35-
},
36-
],
37-
},
38-
{
39-
name: "sectionDescription",
40-
label: "Section Description",
41-
type: "textarea",
42-
required: false,
43-
localized: true,
44-
},
45-
{
46-
name: "sectionLinkButton",
47-
label: "Section Link Button",
48-
type: "group",
49-
fields: [
50-
{
51-
name: "label",
52-
type: "text",
53-
required: false,
54-
localized: true,
55-
},
56-
{
57-
name: "url",
58-
type: "text",
59-
required: false,
60-
},
61-
],
62-
},
63-
],
64-
},
11+
sectionFields(),
6512
{
6613
name: "cards",
6714
label: "Cards",

0 commit comments

Comments
 (0)