Skip to content

Commit

Permalink
[TASK] add CTA fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dmh committed Apr 11, 2024
1 parent 9df9d9f commit 700ffe5
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 18 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
richtext,
url,
video,
embed
embed,
cta
} from './lib/content-tab-fields.js'

/**
Expand All @@ -50,7 +51,8 @@ const moduleFields = {
border,
textalignment,
video,
embed
embed,
cta
}
/**
* #### Theme fields entry point
Expand Down
25 changes: 24 additions & 1 deletion lib/content-tab-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,27 @@ function embed (label, name, fields) {
return { ...contentOptions, ...otherOptions }
}

export { text, link, richtext, url, video, embed }
/**
* #### CTA fields allow the user to select a call-to-action from the HubSpot CTA tool.
* `only_content_tab`
*
* Some parameters have `default` values, `OMIT` such parameters if you don't want to override them.
* @example
* fi.cta('label', 'name', {...options if needed})
* @memberof Fields
* @param {string} label The text the content creator sees describing the field. May contain spaces.
* @param {string} name Field/HubL variable name, which you'll reference when incorporating the field and its values in the module or theme. `Cannot contain spaces or special characters!`
* @param {Object} [fields]
* @param {EDITOR_OPTIONS} [fields.editor_options] Editor options group.
* @param {DISPLAY_CONDITIONS} [fields.display_conditions] Display conditions group.
* @param {REPEATER_OPTIONS} [fields.repeater_options] Repeater options. Keep `occurrence` object empty to just enable a feature. `repeater_options: {occurrence: {}}`
* @param {REPEATER_OPTIONS_DEFAULT} [fields.repeater_options_default] Repeater options with predefined repeated fields and `default` values for each field.
* @returns {COMMON_FIELDS}
*/
function cta (label, name, fields) {
const contentOptions = {}
const otherOptions = initField(label, name, 'cta', fields)
return { ...contentOptions, ...otherOptions }
}

export { text, link, richtext, url, video, embed, cta }
4 changes: 2 additions & 2 deletions lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function image (label, name, fields) {
* @param {string} label The text the content creator sees describing the field. May contain spaces.
* @param {string} name Field/HubL variable name, which you'll reference when incorporating the field and its values in the module or theme. `Cannot contain spaces or special characters!`
* @param {Object} [fields]
* @param {'fontawesome-5.14.0'|'fontawesome-5.0.10'} [fields.icon_set='fontawesome-5.14.0'] `fontawesome-5.14.0` The FontAwesome icon set to use.
* @param {'fontawesome-5.14.0'|'fontawesome-5.0.10'|'fontawesome-6.4.2'} [fields.icon_set='fontawesome-6.4.2'] `fontawesome-6.4.2` The FontAwesome icon set to use.
* @param {Object} [fields.default] Defaout icon object --> It's generally a good idea to skip setting the `default` object, as it should be configured by the editor, not the developer
* @param {string} [fields.default.name] The name of the icon
* @param {string} [fields.default.unicode] The unicode of the icon
Expand All @@ -146,7 +146,7 @@ function image (label, name, fields) {
*/
function icon (label, name, fields) {
const contentOptions = {}
contentOptions.icon_set = fields?.icon_set ?? 'fontawesome-5.14.0'
contentOptions.icon_set = fields?.icon_set ?? 'fontawesome-6.4.2'
contentOptions.default = fields?.default ?? {}

const otherOptions = initField(label, name, 'icon', fields)
Expand Down
2 changes: 1 addition & 1 deletion test/1content-js-simple.module/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"inherited_value": null
},
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon_field",
Expand Down
2 changes: 1 addition & 1 deletion test/1content-js.module/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"inherited_value": null
},
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon_field",
Expand Down
18 changes: 9 additions & 9 deletions test/1partials-js.module/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down Expand Up @@ -269,7 +269,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down Expand Up @@ -540,7 +540,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down Expand Up @@ -915,7 +915,7 @@
}
},
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand All @@ -933,7 +933,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down Expand Up @@ -1523,7 +1523,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down Expand Up @@ -1747,7 +1747,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down Expand Up @@ -1879,7 +1879,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down Expand Up @@ -2150,7 +2150,7 @@
"label": "Icon",
"children": [
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon",
Expand Down
2 changes: 1 addition & 1 deletion test/1style-js-simple.module/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"inherited_value": null
},
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon_field",
Expand Down
2 changes: 1 addition & 1 deletion test/1style-js.module/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"inherited_value": null
},
{
"icon_set": "fontawesome-5.14.0",
"icon_set": "fontawesome-6.4.2",
"default": {},
"id": "",
"name": "icon_field",
Expand Down

0 comments on commit 700ffe5

Please sign in to comment.