Skip to content

Commit 50947af

Browse files
committed
Add background color and change to flex instead of grid
1 parent c51da1c commit 50947af

3 files changed

Lines changed: 29 additions & 33 deletions

File tree

sga-puck/components/puck/Content.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentConfig } from '@puckeditor/core';
22
import React from 'react';
3-
import { paddingSettingsField } from '../../lib/settings-fields';
3+
import { paddingSettingsField, backgroundColorSettingField } from '../../lib/settings-fields';
44

55
export type ContentProps = {
66
backgroundColor?: string;
@@ -29,16 +29,7 @@ export const Content: React.FC<ContentProps> = ({
2929

3030
export const ContentConfig: ComponentConfig<ContentProps> = {
3131
fields: {
32-
backgroundColor: {
33-
type: "select",
34-
options: [
35-
{ label: "White", value: "#ffffff" },
36-
{ label: "Light Gray", value: "#f5f5f5" },
37-
{ label: "SGA Red", value: "#dc2626" },
38-
{ label: "Black", value: "#000000" },
39-
{ label: "Transparent", value: "transparent" },
40-
]
41-
},
32+
backgroundColor: backgroundColorSettingField,
4233
padding: paddingSettingsField,
4334
minHeight: {
4435
type: "select",

sga-puck/components/puck/SplitPane.tsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { ComponentConfig, PuckContext, SlotComponent} from "@puckeditor/core"
2-
import { gapSettingsField } from "../../lib/settings-fields";
2+
import { backgroundColorSettingField, gapSettingsField } from "../../lib/settings-fields";
33

44
export interface SplitPaneProps {
55
paneOneContent: SlotComponent,
66
paneTwoContent: SlotComponent,
77
direction?: string,
88
paneOneRatio?: number,
99
paneTwoRatio?: number,
10-
gap?: string;
10+
gap?: string
11+
backgroundColor?: string;
1112
}
1213

1314
export interface SplitPanePropsForRender extends SplitPaneProps {
@@ -17,43 +18,35 @@ export interface SplitPanePropsForRender extends SplitPaneProps {
1718
export const SplitPane: React.FC<SplitPanePropsForRender> = ({
1819
paneOneContent: ContentOne,
1920
paneTwoContent: ContentTwo,
20-
direction = "horizontal",
21+
direction = "md:flex-row",
2122
paneOneRatio = 1,
2223
paneTwoRatio = 4,
2324
gap = "gap-4",
25+
backgroundColor = "#ffffff",
2426
puck
2527
}) => {
2628

27-
if (direction === "vertical") {
28-
return <div ref={puck.dragRef} className={`grid grid-cols-1 ${gap}`}>
29-
<ContentOne />
30-
<ContentTwo />
29+
return <div ref={puck.dragRef} className={`${gap} flex flex-col ${direction}`} style={{backgroundColor}}>
30+
<div style={{flex: paneOneRatio}}>
31+
<ContentOne />
3132
</div>
32-
}
33-
34-
// DO NOT DELETE. The below comments are required for the design to work properly.
35-
// Tailwind doesn't support dynamic class names, so we need to predefine all possible classes for the split pane.
36-
// "md:grid-cols-1 md:grid-cols-2 md:grid-cols-3 md:grid-cols-4 md:grid-cols-5 md:grid-cols-6 md:grid-cols-7 md:grid-cols-8 md:grid-cols-9 md:grid-cols-10 md:grid-cols-11 md:grid-cols-12 " +
37-
// "md:col-start-1 md:col-start-2 md:col-start-3 md:col-start-4 md:col-start-5 md:col-start-6 md:col-start-7 md:col-start-8 md:col-start-9 md:col-start-10 md:col-start-11 md:col-start-12 " +
38-
// "md:col-end-1 md:col-end-2 md:col-end-3 md:col-end-4 md:col-end-5 md:col-end-6 md:col-end-7 md:col-end-8 md:col-end-9 md:col-end-10 md:col-end-11 md:col-end-12 "
39-
40-
const totalSize = paneOneRatio + paneTwoRatio
41-
return <div ref={puck.dragRef} className={`grid ${gap} grid-cols-1 md:grid-cols-${totalSize}`}>
42-
<ContentOne className={`md:col-start-1 md:col-end-${paneOneRatio + 1}`}/>
43-
<ContentTwo className={`md:col-start-${paneOneRatio + 1} md:col-end-${totalSize + 1}`} />
33+
<div style={{flex: paneTwoRatio}}>
34+
<ContentTwo />
4435
</div>
36+
</div>
4537
}
4638
export const SplitPaneConfig: ComponentConfig<SplitPaneProps> = {
4739
inline: true,
4840
fields: {
4941
paneOneContent: { type: "slot" },
5042
paneTwoContent: { type: "slot" },
5143
gap: gapSettingsField,
44+
backgroundColor: backgroundColorSettingField,
5245
direction: {
5346
type: "radio",
5447
options: [
55-
{ label: "horizontal", value: "horizontal" },
56-
{ label: "vertical", value: "vertical" }
48+
{ label: "horizontal", value: "md:flex-row" },
49+
{ label: "vertical", value: "md:flex-col" }
5750
]
5851
},
5952
paneOneRatio: {
@@ -69,7 +62,8 @@ export const SplitPaneConfig: ComponentConfig<SplitPaneProps> = {
6962
paneOneContent: null,
7063
paneTwoContent: null,
7164
gap: "gap-4",
72-
direction: "horizontal",
65+
backgroundColor: "#ffffff",
66+
direction: "md:flex-row",
7367
paneOneRatio: 1,
7468
paneTwoRatio: 4
7569
},

sga-puck/lib/settings-fields.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ export const booleanSettingsField: Field<boolean> = {
88
]
99
} as const
1010

11+
export const backgroundColorSettingField: Field<string> = {
12+
type: "select",
13+
options: [
14+
{ label: "White", value: "#ffffff" },
15+
{ label: "Light Gray", value: "#f5f5f5" },
16+
{ label: "SGA Red", value: "#dc2626" },
17+
{ label: "Black", value: "#000000" },
18+
{ label: "Transparent", value: "transparent" },
19+
]
20+
}
21+
1122
export const gapSettingsField: Field<string> = {
1223
type: "select",
1324
options: [

0 commit comments

Comments
 (0)