11import { ComponentConfig , PuckContext , SlotComponent } from "@puckeditor/core"
2- import { gapSettingsField } from "../../lib/settings-fields" ;
2+ import { backgroundColorSettingField , gapSettingsField } from "../../lib/settings-fields" ;
33
44export 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
1314export interface SplitPanePropsForRender extends SplitPaneProps {
@@ -17,43 +18,35 @@ export interface SplitPanePropsForRender extends SplitPaneProps {
1718export 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}
4638export 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 } ,
0 commit comments