From 2f0b5a9629ff8f40aa0ff7377889b87fe679aa88 Mon Sep 17 00:00:00 2001 From: Brad Simpson Date: Wed, 19 Jul 2023 15:14:13 -0600 Subject: [PATCH 01/12] example.json --- example.json | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/example.json b/example.json index 5162019..834089e 100644 --- a/example.json +++ b/example.json @@ -1,24 +1,37 @@ - // Configuration options must be added and amended for all json files where required +// Configuration options must be added and amended for all JSON files where required - // config.json - to disable globally - "_homeButton": { - "_isEnabled": false - } +// config.json - to disable globally +"_homeButton": { + "_isEnabled": false +} - // course.json +// course.json +"_extensions": { "_homeButton": { - "_isEnabled": true, - "_hideHomeButton": false, - "_comment": "Amend co-00 to match the ID of the start / landing page", - "_redirectToId": "co-00", - "alt": "Introduction" + "_navOrder": 1, + "navLabel": "Home", + "_navTooltip": { + "_isEnabled": false, + "text": "Home" + } } +} - // contentObjects.json - "_homeButton": { - "_isEnabled": true, - "_hideHomeButton": false, - "_hideBackButton": true, - "_redirectToId": "", - "alt": "Home" - } + +// course.json +"_homeButton": { + "_isEnabled": true, + "_hideHomeButton": false, + "_comment": "Amend co-00 to match the ID of the start / landing page", + "_redirectToId": "co-00", + "alt": "Introduction" +} + +// contentObjects.json +"_homeButton": { + "_isEnabled": true, + "_hideHomeButton": false, + "_hideBackButton": true, + "_redirectToId": "", + "alt": "Home" +} From cf4ebb17966a94a08910a3e90c68b7d550256799 Mon Sep 17 00:00:00 2001 From: Brad Simpson Date: Thu, 20 Jul 2023 13:39:14 -0600 Subject: [PATCH 02/12] Schema updates - add tooltip, nav button, nav order props --- properties.schema | 46 +++++++++++++++++++++++++++++++ schema/course.schema.json | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/properties.schema b/properties.schema index 3de7a03..f94292d 100644 --- a/properties.schema +++ b/properties.schema @@ -3,6 +3,52 @@ "$schema": "http://json-schema.org/draft-04/schema", "id": "http://jsonschema.net", "required": false, + "globals": { + "_navOrder": { + "type": "number", + "required": true, + "title": "Navigation bar order", + "help": "Determines the order in which the button is displayed in the navigation bar. Negative numbers (e.g. -100) are left-aligned. Positive numbers (e.g. 100) are right-aligned.", + "default": 0, + "inputType": "Text", + "validators": [] + }, + "_showLabel": { + "type": "boolean", + "required": true, + "default": true, + "title": "Enable navigation bar button label", + "inputType": "Checkbox", + "validators": [], + "help": "Controls whether a label is shown on the navigation bar button." + }, + "navLabel": { + "type": "string", + "required": true, + "default": "Home", + "title": "Navigation bar button label", + "inputType": "Text", + "validators": [], + "translatable": true + }, + "_navTooltip": { + "type": "object", + "title": "Navigation tooltip", + "properties": { + "_isEnabled": { + "type": "boolean", + "title": "Enable tooltip for navigation button", + "default": true + }, + "text": { + "type": "string", + "title": "", + "default": "Home", + "translatable": true + } + } + } + }, "properties": { "pluginLocations": { "type": "object", diff --git a/schema/course.schema.json b/schema/course.schema.json index 6f1176e..791fdba 100644 --- a/schema/course.schema.json +++ b/schema/course.schema.json @@ -8,6 +8,63 @@ }, "with": { "properties": { + "_globals": { + "type": "object", + "default": {}, + "properties": { + "_extensions": { + "type": "object", + "default": {}, + "properties": { + "_homeButton": { + "type": "object", + "title": "Home Button", + "default": {}, + "properties": { + "_navOrder": { + "type": "number", + "title": "Navigation bar order", + "description": "Determines the order in which the button is displayed in the navigation bar. Negative numbers (e.g. -100) are left-aligned. Positive numbers (e.g. 100) are right-aligned.", + "default": 0 + }, + "_showLabel": { + "type": "boolean", + "title": "Enable navigation bar button label", + "default": true + }, + "navLabel": { + "type": "string", + "title": "Navigation bar button label", + "default": "Home", + "_adapt": { + "translatable": true + } + }, + "_navTooltip": { + "type": "object", + "title": "Navigation tooltip", + "properties": { + "_isEnabled": { + "type": "boolean", + "title": "Enable tooltip for navigation button", + "default": true + }, + "text": { + "type": "string", + "title": "", + "default": "Home", + "_adapt": { + "translatable": true + } + } + } + } + } + } + } + } + } + }, "_homeButton": { "type": "object", "title": "Home Button", From f2af96f616e4255519f806e05bc51774ee7654de Mon Sep 17 00:00:00 2001 From: Brad Simpson Date: Thu, 20 Jul 2023 13:47:30 -0600 Subject: [PATCH 03/12] Less optimizations for readability --- less/homeButton.less | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/less/homeButton.less b/less/homeButton.less index bf0e341..71e6c2b 100644 --- a/less/homeButton.less +++ b/less/homeButton.less @@ -1,20 +1,18 @@ -.nav { - // replicate navigation back button float - &__homebutton-btn { - .u-float-left; - } +.nav__homebutton-btn { + // Replicate navigation back button float + .u-float-left; - // hide home button class - .hide-nav-home-btn &__homebutton-btn { + // Hide home button class + .hide-nav-home-btn & { .u-display-none; } // Change the home button icon to use the back arrow on the menu - .location-menu &__homebutton-btn .icon { + .location-menu & .icon { .icon-controls-small-left; } - .location-page &__homebutton-btn .icon { + .location-page & .icon { .icon-home; } } From 20b9a80b30f7f8660fda050638207c8e6875c34b Mon Sep 17 00:00:00 2001 From: Brad Simpson Date: Thu, 20 Jul 2023 13:49:16 -0600 Subject: [PATCH 04/12] Add JSX template --- templates/HomeNavigationButton.jsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 templates/HomeNavigationButton.jsx diff --git a/templates/HomeNavigationButton.jsx b/templates/HomeNavigationButton.jsx new file mode 100644 index 0000000..5bacda2 --- /dev/null +++ b/templates/HomeNavigationButton.jsx @@ -0,0 +1,25 @@ +import React from 'react'; +import { classes, compile } from 'core/js/reactHelpers'; + +export default function HomeNavigationButton(props) { + const { + text, + _iconClasses + } = props; + return ( + <> +