-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathplugins.tsx
195 lines (170 loc) · 5.3 KB
/
plugins.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import React from "react";
import { GroupListField, BlocksFieldPlugin } from 'tinacms'
import AlignmentControl from './components/tina/AlignmentControl'
import BorderControl from './components/tina/BorderControl'
import ButtonControl from './components/tina/ButtonControl'
import ButtonsLayoutControl from './components/tina/ButtonsLayoutControl'
import ButtonTypographyControl from './components/tina/ButtonTypographyControl'
import CardAlignmentControl from './components/tina/CardAlignmentControl'
import ColorControl from './components/tina/ColorControl'
import FeatureContentControl from './components/tina/FeatureContentControl'
import FeatureImageControl from './components/tina/FeatureImageControl'
import FillControl from './components/tina/FillControl'
import GridControl from './components/tina/GridControl'
import ImageControl from './components/tina/ImageControl'
import PaddingControl from './components/tina/PaddingControl'
import OrnamentControl from './components/tina/OrnamentControl'
import RuledTitle from './components/tina/RuledTitle'
import SelectField from './components/tina/SelectField'
import TransformControl from './components/tina/TransformControl'
import TransformDesktopControl from './components/tina/TransformDesktopControl'
import TypeControl from './components/tina/TypeControl'
import TypographyControl from './components/tina/TypographyControl'
export const SectionListItemsPlugin = {
...BlocksFieldPlugin,
Component: (props) => {
const itemProps = (item) => {
const templateNames = {
accordion: 'Accordion',
banner: 'Banner',
cards: 'Cards',
carousel: 'Carousel',
embed: 'Embed',
eventSchedule: 'Event Schedule',
eventTimeline: 'Event Timeline',
feature: 'Feature',
tailwindCards: 'Cards TW',
tailwindFeature: 'Feature TW',
video: 'Video',
}
const sectionName = item.headline || item.subhead || item.label || item.title || item.video || ''
const sectionNameShort = sectionName.match(/^.{24}\w*/)
const sectionLabel = sectionNameShort || sectionName || ''
const label = sectionLabel ? `${sectionLabel} (${templateNames[item._template]})` : `${templateNames[item._template]}`
return { ...item, label: label }
}
const templates = {}
Object.keys(props.field.templates).forEach((key) => {
templates[key] = {
...props.field.templates[key],
itemProps,
}
})
return <BlocksFieldPlugin.Component {...props} field={{ ...props.field, templates }} />
},
__type: 'field',
name: "sectionListItems",
}
export const itemListFieldPlugin = {
Component: (props) => {
const field = {
...props.field,
itemProps: (item) => {
return { label: item.headline || item.subhead || item.label || item.name }
},
}
return <GroupListField {...props} field={field} />
},
__type: 'field',
name: 'itemListField'
}
export const alignmentControlFieldPlugin = {
Component: AlignmentControl,
__type: 'field',
name: 'alignmentControl',
}
export const borderControlFieldPlugin = {
Component: BorderControl,
__type: 'field',
name: 'borderControl',
}
export const buttonTypographyControlFieldPlugin = {
Component: ButtonTypographyControl,
__type: 'field',
name: 'buttonTypographyControl',
}
export const cardAlignmentControlFieldPlugin = {
Component: CardAlignmentControl,
__type: 'field',
name: 'cardAlignmentControl',
}
export const colorControlFieldPlugin = {
Component: ColorControl,
__type: 'field',
name: 'colorControl',
}
export const buttonControlFieldPlugin = {
Component: ButtonControl,
__type: 'field',
name: 'buttonControl',
}
export const buttonsLayoutControlFieldPlugin = {
Component: ButtonsLayoutControl,
__type: 'field',
name: 'buttonsLayoutControl',
}
export const featureContentControlPlugin = {
Component: FeatureContentControl,
__type: 'field',
name: 'featureContentControl',
}
export const featureImageControlPlugin = {
Component: FeatureImageControl,
__type: 'field',
name: 'featureImageControl',
}
export const fillControlFieldPlugin = {
Component: FillControl,
__type: 'field',
name: 'fillControl',
}
export const gridControlFieldPlugin = {
Component: GridControl,
__type: 'field',
name: 'gridControl',
}
export const imageControlFieldPlugin = {
Component: ImageControl,
__type: 'field',
name: 'imageControl',
}
export const paddingControlFieldPlugin = {
Component: PaddingControl,
__type: 'field',
name: 'paddingControl',
}
export const ornamentControlFieldPlugin = {
Component: OrnamentControl,
__type: 'field',
name: 'ornamentControl',
}
export const ruledTitlePlugin = {
Component: RuledTitle,
__type: 'field',
name: 'ruledTitle',
}
export const selectFieldPlugin = {
Component: SelectField,
__type: 'field',
name: 'selectField',
}
export const transformControlFieldPlugin = {
Component: TransformControl,
__type: 'field',
name: 'transformControl',
}
export const transformDesktopControlFieldPlugin = {
Component: TransformDesktopControl,
__type: 'field',
name: 'transformDesktopControl',
}
export const typeControlFieldPlugin = {
Component: TypeControl,
__type: 'field',
name: 'typeControl',
}
export const typographyControlFieldPlugin = {
Component: TypographyControl,
__type: 'field',
name: 'typographyControl',
}