| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { |
| 3 |
generateTypographyAttributes, |
| 4 |
generateResponsiveRangeAttributes, |
| 5 |
generateDimensionsAttributes, |
| 6 |
generateBackgroundAttributes, |
| 7 |
generateBorderShadowAttributes, |
| 8 |
} from '../../../util/helpers' |
| 9 |
|
| 10 |
import { |
| 11 |
FAQ_LIST_BACKGROUND, |
| 12 |
FAQ_BORDER, |
| 13 |
FAQ_CONTENT_BORDER, |
| 14 |
FAQ_LIST_MARGIN, |
| 15 |
FAQ_CONTENT_PADDING, |
| 16 |
FAQ_CONTENT_BACKGROUND, |
| 17 |
TITLE_MARGIN, |
| 18 |
TITLE_PADDING, |
| 19 |
TITLE_BACKGROUND, |
| 20 |
TITLE_BORDER, |
| 21 |
COLUMNS, |
| 22 |
FAQ_SPACE, |
| 23 |
COUNT_SIZE, |
| 24 |
THUMBNAIL_SIZE, |
| 25 |
COUNT_BACKGROUND, |
| 26 |
FAQ_LIST_PADDING, |
| 27 |
FAQ_CONTENT_MARGIN, |
| 28 |
COUNT_BORDER, |
| 29 |
LIST_MARGIN, |
| 30 |
LIST_PADDING, |
| 31 |
LIST_BACKGROUND, |
| 32 |
ICON_SIZE, |
| 33 |
ICON_MARGIN, |
| 34 |
BTN_MARGIN, |
| 35 |
BTN_PADDING, |
| 36 |
BTN_BACKGROUND, |
| 37 |
BTN_BORDER, |
| 38 |
WRAPPER_MARGIN, |
| 39 |
SECTION_TITLE_MARGIN, |
| 40 |
SECTION_TITLE_PADDING, |
| 41 |
GROUP_TITLE_MARGIN, |
| 42 |
GROUP_TITLE_PADDING, |
| 43 |
CONTAINER_SECTION_MARGIN, |
| 44 |
CONTAINER_SECTION_PADDING, |
| 45 |
CONTAINER_SECTION_BACKGROUND, |
| 46 |
FAQ_LIST_BACKGROUND_LAYOUT_3, |
| 47 |
FAQ_LIST_BACKGROUND_LAYOUT_4, |
| 48 |
FAQ_CONTENT_BACKGROUND_LAYOUT_4, |
| 49 |
GROUP_TITLE_PADDING_LAYOUT_4, |
| 50 |
GROUP_TITLE_MARGIN_LAYOUT_4, |
| 51 |
FAQ_LIST_PADDING_LAYOUT_4, |
| 52 |
FAQ_LIST_MARGIN_LAYOUT_4, |
| 53 |
FAQ_CONTENT_MARGIN_LAYOUT_4, |
| 54 |
FAQ_CONTENT_PADDING_LAYOUT_4, |
| 55 |
FAQ_BORDER_LAYOUT_4, |
| 56 |
FAQ_CONTENT_BORDER_LAYOUT_4, |
| 57 |
} from './constants' |
| 58 |
import * as typoPrefixs from './typographyPrefixConstants' |
| 59 |
|
| 60 |
const attributes = { |
| 61 |
// the following 4 attributes is must required for responsive options and asset generation for frontend |
| 62 |
// responsive control attributes ⬇ |
| 63 |
resOption: { |
| 64 |
type: 'string', |
| 65 |
default: 'Desktop', |
| 66 |
}, |
| 67 |
// blockId attribute for making unique className and other uniqueness ⬇ |
| 68 |
blockId: { |
| 69 |
type: 'string', |
| 70 |
}, |
| 71 |
blockRoot: { |
| 72 |
type: 'string', |
| 73 |
default: 'better_docs', |
| 74 |
}, |
| 75 |
// blockMeta is for keeping all the styles ⬇ |
| 76 |
blockMeta: { |
| 77 |
type: 'object', |
| 78 |
}, |
| 79 |
faqLayout: { |
| 80 |
type: 'string', |
| 81 |
default: 'layout-1', |
| 82 |
}, |
| 83 |
faqTaxonomy: { |
| 84 |
type: 'string', |
| 85 |
default: 'betterdocs_faq_category', |
| 86 |
}, |
| 87 |
// Per-block FAQ order. Empty string = inherit the global FAQ Builder order. |
| 88 |
faqOrder: { |
| 89 |
type: 'string', |
| 90 |
default: '', |
| 91 |
}, |
| 92 |
faqSectionText: { |
| 93 |
type: 'string', |
| 94 |
default: 'Frequently Asked Questions' |
| 95 |
}, |
| 96 |
faqSectionTitleColor: { |
| 97 |
type: 'string', |
| 98 |
}, |
| 99 |
|
| 100 |
|
| 101 |
// JSON string of `[{value: int, label: string}]`. The editor writes that |
| 102 |
// object form; a bare id array (`"[5]"`) is also accepted since 4.9.0. |
| 103 |
includeFaqGroup: { |
| 104 |
type: 'string', |
| 105 |
default: null, |
| 106 |
}, |
| 107 |
excludeFaqGroup: { |
| 108 |
type: 'string', |
| 109 |
}, |
| 110 |
faqGroupTitleColor: { |
| 111 |
type: 'string', |
| 112 |
}, |
| 113 |
faqGroupTitleLayout4Color: { |
| 114 |
type: 'string', |
| 115 |
}, |
| 116 |
faqGroupTitleHoverColor: { |
| 117 |
type: 'string', |
| 118 |
}, |
| 119 |
faqGroupTitleLayout4HoverColor: { |
| 120 |
type: 'string', |
| 121 |
}, |
| 122 |
faqListColor: { |
| 123 |
type: 'string', |
| 124 |
}, |
| 125 |
faqListLayout4Color: { |
| 126 |
type: 'string', |
| 127 |
}, |
| 128 |
faqContentColor: { |
| 129 |
type: 'string', |
| 130 |
}, |
| 131 |
faqContentLayout4Color: { |
| 132 |
type: 'string', |
| 133 |
}, |
| 134 |
faqIconColor: { |
| 135 |
type: 'string', |
| 136 |
}, |
| 137 |
|
| 138 |
faqGroupTitleTypography: { |
| 139 |
type: 'string', |
| 140 |
}, |
| 141 |
|
| 142 |
faqPerPage: { |
| 143 |
type: 'number', |
| 144 |
default: 9, |
| 145 |
}, |
| 146 |
orderBy: { |
| 147 |
type: 'string', |
| 148 |
default: 'name', |
| 149 |
}, |
| 150 |
order: { |
| 151 |
type: 'string', |
| 152 |
default: 'asc', |
| 153 |
}, |
| 154 |
postsPerPage: { |
| 155 |
type: 'number', |
| 156 |
default: 5, |
| 157 |
}, |
| 158 |
postsOrderBy: { |
| 159 |
type: 'string', |
| 160 |
default: 'date', |
| 161 |
}, |
| 162 |
postsOrder: { |
| 163 |
type: 'string', |
| 164 |
default: 'asc', |
| 165 |
}, |
| 166 |
enableNestedSubcategory: { |
| 167 |
type: 'boolean', |
| 168 |
default: false, |
| 169 |
}, |
| 170 |
postPerSubcategory: { |
| 171 |
type: 'number', |
| 172 |
default: 3, |
| 173 |
}, |
| 174 |
layout: { |
| 175 |
type: 'string', |
| 176 |
default: 'default', |
| 177 |
}, |
| 178 |
layoutMode: { |
| 179 |
type: 'string', |
| 180 |
default: 'faq', |
| 181 |
}, |
| 182 |
showIcon: { |
| 183 |
type: 'boolean', |
| 184 |
default: true, |
| 185 |
}, |
| 186 |
showThumbnail: { |
| 187 |
type: 'boolean', |
| 188 |
default: true, |
| 189 |
}, |
| 190 |
showTitle: { |
| 191 |
type: 'boolean', |
| 192 |
default: true, |
| 193 |
}, |
| 194 |
showDescription: { |
| 195 |
type: 'boolean', |
| 196 |
default: true, |
| 197 |
}, |
| 198 |
titleTag: { |
| 199 |
type: 'string', |
| 200 |
default: 'h2', |
| 201 |
}, |
| 202 |
faqSectionTitleTag: { |
| 203 |
type: 'string', |
| 204 |
default: 'h2', |
| 205 |
}, |
| 206 |
faqGroupTitleTag: { |
| 207 |
type: 'string', |
| 208 |
default: 'h3', |
| 209 |
}, |
| 210 |
showHeader: { |
| 211 |
type: 'boolean', |
| 212 |
default: true, |
| 213 |
}, |
| 214 |
showCount: { |
| 215 |
type: 'boolean', |
| 216 |
default: true, |
| 217 |
}, |
| 218 |
showList: { |
| 219 |
type: 'boolean', |
| 220 |
default: true, |
| 221 |
}, |
| 222 |
showButton: { |
| 223 |
type: 'boolean', |
| 224 |
default: true, |
| 225 |
}, |
| 226 |
buttonText: { |
| 227 |
type: 'string', |
| 228 |
default: __('Explore More', 'betterdocs'), |
| 229 |
}, |
| 230 |
titleColor: { |
| 231 |
type: 'string', |
| 232 |
default: '#eeee22', |
| 233 |
}, |
| 234 |
titleHoverColor: { |
| 235 |
type: 'string', |
| 236 |
}, |
| 237 |
countColor: { |
| 238 |
type: 'string', |
| 239 |
default: '#ffffff', |
| 240 |
}, |
| 241 |
countHoverColor: { |
| 242 |
type: 'string', |
| 243 |
}, |
| 244 |
listIcon: { |
| 245 |
type: 'string', |
| 246 |
default: 'far fa-file-alt', |
| 247 |
}, |
| 248 |
listColor: { |
| 249 |
type: 'string', |
| 250 |
default: '#566e8b', |
| 251 |
}, |
| 252 |
listHoverColor: { |
| 253 |
type: 'string', |
| 254 |
}, |
| 255 |
iconColor: { |
| 256 |
type: 'string', |
| 257 |
default: '#2f3b48' |
| 258 |
}, |
| 259 |
showButtonIcon: { |
| 260 |
type: 'boolean', |
| 261 |
default: true, |
| 262 |
}, |
| 263 |
buttonIcon: { |
| 264 |
type: 'string', |
| 265 |
default: 'fas fa-arrow-right', |
| 266 |
}, |
| 267 |
buttonColor: { |
| 268 |
type: 'string', |
| 269 |
default: '#528ffe', |
| 270 |
}, |
| 271 |
buttonColorLayout4:{ |
| 272 |
type: 'string', |
| 273 |
default: 'rgb(112, 126, 149)', |
| 274 |
}, |
| 275 |
buttonHoverColor: { |
| 276 |
type: 'string', |
| 277 |
}, |
| 278 |
buttonPosition: { |
| 279 |
type: 'string', |
| 280 |
default: 'left', |
| 281 |
}, |
| 282 |
...generateDimensionsAttributes(SECTION_TITLE_MARGIN), |
| 283 |
...generateDimensionsAttributes(SECTION_TITLE_PADDING), |
| 284 |
...generateDimensionsAttributes(GROUP_TITLE_MARGIN), |
| 285 |
...generateDimensionsAttributes(GROUP_TITLE_MARGIN_LAYOUT_4), |
| 286 |
...generateDimensionsAttributes(GROUP_TITLE_PADDING), |
| 287 |
...generateDimensionsAttributes(GROUP_TITLE_PADDING_LAYOUT_4), |
| 288 |
// typography attributes |
| 289 |
...generateTypographyAttributes(Object.values(typoPrefixs)), |
| 290 |
// responsive range |
| 291 |
...generateResponsiveRangeAttributes(COLUMNS, { |
| 292 |
defaultRange: 3, |
| 293 |
noUnits: true, |
| 294 |
}), |
| 295 |
...generateResponsiveRangeAttributes(FAQ_SPACE, { |
| 296 |
defaultRange: 10, |
| 297 |
noUnits: true, |
| 298 |
}), |
| 299 |
...generateResponsiveRangeAttributes(COUNT_SIZE, { |
| 300 |
defaultRange: 30, |
| 301 |
}), |
| 302 |
...generateResponsiveRangeAttributes(ICON_SIZE, { |
| 303 |
defaultRange: 15, |
| 304 |
}), |
| 305 |
...generateResponsiveRangeAttributes(THUMBNAIL_SIZE, { |
| 306 |
defaultRange: 300, |
| 307 |
}), |
| 308 |
// dimension |
| 309 |
...generateDimensionsAttributes(FAQ_LIST_MARGIN), |
| 310 |
...generateDimensionsAttributes(FAQ_LIST_MARGIN_LAYOUT_4), |
| 311 |
...generateDimensionsAttributes(FAQ_LIST_PADDING), |
| 312 |
...generateDimensionsAttributes(FAQ_LIST_PADDING_LAYOUT_4), |
| 313 |
...generateDimensionsAttributes(FAQ_CONTENT_MARGIN), |
| 314 |
...generateDimensionsAttributes(FAQ_CONTENT_MARGIN_LAYOUT_4), |
| 315 |
...generateDimensionsAttributes(FAQ_CONTENT_PADDING), |
| 316 |
...generateDimensionsAttributes(FAQ_CONTENT_PADDING_LAYOUT_4), |
| 317 |
...generateDimensionsAttributes(TITLE_MARGIN), |
| 318 |
...generateDimensionsAttributes(GROUP_TITLE_MARGIN_LAYOUT_4), |
| 319 |
...generateDimensionsAttributes(TITLE_PADDING, { |
| 320 |
top: 0, |
| 321 |
right: 0, |
| 322 |
bottom: 20, |
| 323 |
left: 0, |
| 324 |
isLinked: false, |
| 325 |
}), |
| 326 |
...generateDimensionsAttributes(LIST_MARGIN), |
| 327 |
...generateDimensionsAttributes(LIST_PADDING), |
| 328 |
...generateDimensionsAttributes(ICON_MARGIN), |
| 329 |
...generateDimensionsAttributes(BTN_MARGIN), |
| 330 |
...generateDimensionsAttributes(BTN_PADDING), |
| 331 |
...generateDimensionsAttributes(WRAPPER_MARGIN, { |
| 332 |
top: 28, |
| 333 |
right: 0, |
| 334 |
bottom: 28, |
| 335 |
left: 0, |
| 336 |
isLinked: false, |
| 337 |
}), |
| 338 |
...generateBackgroundAttributes(CONTAINER_SECTION_BACKGROUND, { |
| 339 |
defaultFillColor: '#ffffff00', |
| 340 |
noOverlay: true, |
| 341 |
}), |
| 342 |
...generateDimensionsAttributes(CONTAINER_SECTION_MARGIN), |
| 343 |
...generateDimensionsAttributes(CONTAINER_SECTION_PADDING), |
| 344 |
// background |
| 345 |
...generateBackgroundAttributes(FAQ_LIST_BACKGROUND, { |
| 346 |
defaultFillColor: '#f0f1f5', |
| 347 |
noOverlay: true, |
| 348 |
}), |
| 349 |
...generateBackgroundAttributes(FAQ_LIST_BACKGROUND_LAYOUT_4, { |
| 350 |
defaultFillColor: '#00000000', |
| 351 |
noOverlay: true, |
| 352 |
}), |
| 353 |
...generateBackgroundAttributes(FAQ_LIST_BACKGROUND_LAYOUT_3, { |
| 354 |
defaultFillColor: 'rgba(255,255,255,0.5)', |
| 355 |
noOverlay: true, |
| 356 |
}), |
| 357 |
...generateBackgroundAttributes(FAQ_CONTENT_BACKGROUND, { |
| 358 |
defaultFillColor: '#ffffff', |
| 359 |
noOverlay: true, |
| 360 |
}), |
| 361 |
...generateBackgroundAttributes(FAQ_CONTENT_BACKGROUND_LAYOUT_4, { |
| 362 |
defaultFillColor: '#F6FEF9', |
| 363 |
noOverlay: true, |
| 364 |
}), |
| 365 |
...generateBackgroundAttributes(TITLE_BACKGROUND, { |
| 366 |
defaultFillColor: '#ffffff', |
| 367 |
noOverlay: true, |
| 368 |
noMainBgi: true, |
| 369 |
}), |
| 370 |
...generateBackgroundAttributes(COUNT_BACKGROUND, { |
| 371 |
defaultFillColor: '#528ffe', |
| 372 |
noOverlay: true, |
| 373 |
noMainBgi: true, |
| 374 |
}), |
| 375 |
...generateBackgroundAttributes(LIST_BACKGROUND, { |
| 376 |
defaultFillColor: '#ffffff', |
| 377 |
noOverlay: true, |
| 378 |
noMainBgi: true, |
| 379 |
}), |
| 380 |
...generateBackgroundAttributes(BTN_BACKGROUND, { |
| 381 |
defaultFillColor: '#ffffff', |
| 382 |
noOverlay: true, |
| 383 |
noMainBgi: true, |
| 384 |
}), |
| 385 |
// border shadow attriubtes |
| 386 |
...generateBorderShadowAttributes(FAQ_BORDER), |
| 387 |
...generateBorderShadowAttributes(FAQ_BORDER_LAYOUT_4), |
| 388 |
...generateBorderShadowAttributes(FAQ_CONTENT_BORDER, { |
| 389 |
noShadow: true |
| 390 |
}), |
| 391 |
...generateBorderShadowAttributes(FAQ_CONTENT_BORDER_LAYOUT_4, { |
| 392 |
noShadow: true |
| 393 |
}), |
| 394 |
...generateBorderShadowAttributes(TITLE_BORDER, { |
| 395 |
noShadow: true, |
| 396 |
bdrDefaults: { |
| 397 |
top: 0, |
| 398 |
right: 0, |
| 399 |
bottom: 2, |
| 400 |
left: 0, |
| 401 |
isLinked: false, |
| 402 |
}, |
| 403 |
defaultBdrColor: '#528ffe', |
| 404 |
defaultBdrStyle: 'solid', |
| 405 |
}), |
| 406 |
...generateBorderShadowAttributes(COUNT_BORDER, { noShadow: true }), |
| 407 |
...generateBorderShadowAttributes(BTN_BORDER, { noShadow: true }), |
| 408 |
} |
| 409 |
|
| 410 |
export default attributes |
| 411 |
|