Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: Update and modernize, simplify configuration (fixes #41 #48) #49

Merged
merged 62 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
a3f1b31
Bump required FW version
swashbuck Aug 30, 2023
5c04cfc
WIP - added new templates, view, model
swashbuck Aug 30, 2023
54cdae9
Get buttons to actually display
swashbuck Aug 31, 2023
4dfe655
onClick functionality
swashbuck Aug 31, 2023
525b798
Show button icons
swashbuck Aug 31, 2023
b284d37
aria label, locked
swashbuck Aug 31, 2023
7accc2a
Code optimizations
swashbuck Aug 31, 2023
ff82431
Remove custom inview logic
swashbuck Aug 31, 2023
f5776dc
Added tooltip
swashbuck Aug 31, 2023
8fa1b8c
Delete tooltip.js and tooltip.less
swashbuck Aug 31, 2023
dabf53a
Fix tooltips
swashbuck Sep 5, 2023
29f4a76
Simplify click handler
swashbuck Sep 5, 2023
79e87e9
Fix current sibling page
swashbuck Sep 5, 2023
0601108
Rename ambiguous data variables
swashbuck Sep 5, 2023
cf24918
Replace _.each and _.filter with native functions
swashbuck Sep 5, 2023
5a7b401
Replace _.extends
swashbuck Sep 5, 2023
2955c1e
Fix sibling tooltip labels and aria-labels
swashbuck Sep 5, 2023
034a9d1
Disable tooltips on hidden buttons
swashbuck Sep 5, 2023
ce12e5c
Optimize getCurrentMenu()
swashbuck Sep 5, 2023
6c0ff0c
Code optimizations, fix isSelected in onButtonClick
swashbuck Sep 5, 2023
d73b3b6
Simplify returns
swashbuck Sep 6, 2023
2cafa28
getCurrentPage operator fix
swashbuck Sep 6, 2023
8dba281
getNavigationData return optimization
swashbuck Sep 6, 2023
4bcef2c
getReturnToPreviousLocation return style fix
swashbuck Sep 6, 2023
803368a
Simplify getCurrentMenu()
swashbuck Sep 6, 2023
ffd6e9e
Fix _lockUntilPageComplete
swashbuck Sep 6, 2023
dc354a6
Fix getCurrentPage() by having it always return a model
swashbuck Sep 6, 2023
7b387b3
Remove _customRouteId from sibling
swashbuck Sep 6, 2023
f995d73
Update tooltip schema props
swashbuck Sep 6, 2023
719bfed
properties.schema - Add missing _iconClass help text
swashbuck Sep 6, 2023
bd0eac2
Readme updates
swashbuck Sep 6, 2023
6046c26
Delete demo.fw.png
swashbuck Sep 6, 2023
3a2104d
Add docblock to getNavigationData
swashbuck Sep 6, 2023
83ae32a
Add template() to view
swashbuck Sep 6, 2023
a3cb053
onButtonClick: Lookup model props instead of checking for CSS classes
swashbuck Sep 7, 2023
df8bcaa
Move close behavior to view
swashbuck Sep 7, 2023
a2a0e4c
Remove _sibling and _returnToPreviousLocation from schemas and exampl…
swashbuck Sep 11, 2023
30eee78
Remove _sibling and _returnToPreviousLocation from README
swashbuck Sep 11, 2023
7b61218
Remove _sibling and _returnToPreviousLocation from component.schema.j…
swashbuck Sep 11, 2023
7c8d863
Remove _sibling and _returnToPreviousLocation from JS
swashbuck Sep 11, 2023
75812cf
Skip undefined button types
swashbuck Sep 11, 2023
5e15a5b
Add default icon values to schemas so that they are pre-populated in …
swashbuck Sep 12, 2023
719c0d0
Schema and documentation updates for _iconAlignment
swashbuck Sep 12, 2023
cd0fb39
Remove IE CSS workaround for old tooltip implementation
swashbuck Sep 12, 2023
5fdc56f
Add _iconAlignment to template, update alignment styles
swashbuck Sep 12, 2023
21f91d7
RTL alignment fix
swashbuck Sep 12, 2023
35b174f
Alignment for Next button when using auto
swashbuck Sep 12, 2023
72e304c
Update README with new _iconAlignment property
swashbuck Sep 12, 2023
75f51da
Remove pagenav__tooltip-container from template
swashbuck Sep 12, 2023
afde6ee
Use _tooltipId in setupTooltips
swashbuck Sep 12, 2023
bd69197
Comments, readme
swashbuck Sep 12, 2023
722b29f
Bump framework version to 5.30.2
swashbuck Sep 12, 2023
999f772
Remove aria-current, associated styles
swashbuck Sep 12, 2023
8f43ee9
Fix RTL styles when using explicit left or right
swashbuck Sep 12, 2023
29b0aab
Fix Next icon alignment
swashbuck Sep 12, 2023
b3b3307
Sort props in pageNavItem.jsx
swashbuck Sep 12, 2023
a380c85
Remove button from data if not enabled, update template
swashbuck Sep 12, 2023
47c42b1
Ensure tooltip is removed before navigating away by forcing the butto…
swashbuck Oct 24, 2023
ceee8d3
Remove tooltip workaround
swashbuck Oct 31, 2023
d19409d
Remove IE11 and Safari (version) from README
swashbuck Nov 1, 2023
d4e568e
Merge branch 'master' into issue/41
swashbuck Feb 26, 2024
d4745ab
Bump FW version
swashbuck Feb 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# adapt-pageNav

**PageNav** is a *presentation component* that adds basic navigation controls to a page
**PageNav** is a *presentation component* that adds basic navigation controls to a page.

<img src="demo.gif" alt="the page nav extension in action" align="right">

Expand All @@ -13,65 +13,68 @@ The attributes listed below are used in *components.json* to configure **PageNav

Navigation bar component which can contain some or all of the following buttons:

- _returnToPreviousLocation (takes you back to the previous location - not back in history, just the last routed location)
- _root (takes you back to top level menu)
- _up (takes you to the menu the next level up in the hierarchy)
- _previous (navigates directly to the previous page, if exists, without having to navigate via the menu)
- _next (navigates directly to the next page, if exists, without having to navigate via the menu)
- _sibling (1,2,3,4 etc buttons representing each sibling page)
- _close (closes the course window - only possible if the course was launched in a popup window)
- `_root`: Navigates to the top level menu
- `_up`: Navigates to the menu that is the next level up in the hierarchy. For instance, a sub menu.
- `_previous`: Navigates to the previous page if it exists and is unlocked
- `_next`: Navigates to the next page if it exists and is unlocked
- `_close`: Closes the course window. Only possible if the course was launched in a popup window

The pageNav buttons will respect any [locking](https://github.com/adaptlearning/adapt_framework/wiki/Locking-objects-with-'_isLocked'-and-'_lockType'#using-locking-with-menus) that has been configured in Adapt. In cases not covered by Adapt's locking system - such as a [start page](https://github.com/adaptlearning/adapt_framework/wiki/Content-starts-with-course.json#example-1) that appears immediately before the main menu - the setting `_lockUntilPageComplete` can be used to disable the button until the current page has been completed.
The **PageNav** buttons will respect any [locking](https://github.com/adaptlearning/adapt_framework/wiki/Locking-objects-with-'_isLocked'-and-'_lockType'#using-locking-with-menus) that has been configured in Adapt. In cases not covered by Adapt's locking system - such as a [start page](https://github.com/adaptlearning/adapt_framework/wiki/Content-starts-with-course.json#example-1) that appears immediately before the main menu - the setting `_lockUntilPageComplete` can be used to disable the button until the current page has been completed.

### Attributes

[**core model attributes**](https://github.com/adaptlearning/adapt_framework/wiki/Core-model-attributes): These are inherited by every Adapt component. [Read more](https://github.com/adaptlearning/adapt_framework/wiki/Core-model-attributes).
[**core model attributes**](https://github.com/adaptlearning/adapt_framework/wiki/Core-model-attributes): These are inherited by every Adapt component. [Read more](https://github.com/adaptlearning/adapt_framework/wiki/Core-model-attributes)

**\_component** (string): This value must be: `pageNav`. (One word.)
**\_component** (string): This value must be `pageNav` (one word)

**\_classes** (string): CSS class name to be applied to **PageNav**’s containing `div`. The class must be predefined in one of the Less files. Separate multiple classes with a space.

**\_layout** (string): This defines the horizontal position of the component in the block. Acceptable values are `full`, `left` or `right`.

**instruction** (string): This optional text appears above the component. It is frequently used to guide the learner’s interaction with the component.

**\_loopStyle** (string): Acceptable values are `allPages`, `siblings`, and `none`. `allPages` = loop sequentially through all pages in course. `siblings` = loop sequentially through all pages in current parent object. `none` = disable previous and next buttons at start and end of the pages in the current parent object.
**\_loopStyle** (string): Acceptable values are `allPages`, `siblings`, and `none`. Defaults to `none`.
- `allPages`: Loop sequentially through all pages in course
- `siblings`: Loop sequentially through all pages in current parent object
- `none`: Disable previous and next buttons at start and end of the pages in the current parent object.

**\_shouldSkipOptionalPages** (boolean): Skip pages that are set to `"_isOptional": true`. Default is `false`.

**\_buttons** (object): The following attributes configure the defaults for the **Quickanv** buttons. These attributes are available on all of the following buttons **\_returnToPreviousLocation**, **\_previous**, **\_root**, **\_up**, **\_next**, **\_sibling**, and **\_close**.
**\_buttons** (object): The following attributes configure the defaults for the **Quickanv** buttons. These attributes are available on all of the following buttons **\_previous**, **\_root**, **\_up**, **\_next**, and **\_close**.

#### Global button configurations

>**\_isEnabled** (boolean): Turns the button on and off. Acceptable values are `true` and `false`.

>**\_lockUntilPageComplete** (boolean): For use when the standard Adapt locking system doesn't apply, such as in a start page before the main menu. Acceptable values are `true` and `false`.
>**\_lockUntilPageComplete** (boolean): For use when the standard Adapt locking system doesn't apply, such as in a start page before the main menu. Locks a button until the current page is complete. Acceptable values are `true` and `false`. Defaults to `false`

>**\_order** (number): Defines the display order of the button. Numerical order with 0 rendering first.

>**\_classes** (string): CSS class name to be applied to the `button`. The class must be predefined in one of the Less files. Separate multiple classes with a space.

>**\_iconClass** (string): CSS class name to be applied to the `button` icon. The class must be predefined in one of the Less files with the corresponding icon be added as part of a font. Suggested icons for each button detailed in the [_example.json_](https://github.com/cgkineo/adapt-pageNav/blob/master/example.json). List of all available [_vanilla_ icons](https://github.com/adaptlearning/adapt-contrib-vanilla/wiki/Icons) to choose from.
>**\_iconClass** (string): CSS class name to be applied to the `button` icon. The class must be predefined in one of the Less files with the corresponding icon included as part of a font. To have _no_ icon, leave this field blank. Suggested icons for each button are detailed in the [_example.json_](https://github.com/cgkineo/adapt-pageNav/blob/master/example.json). See the list of all available [_vanilla_ icons](https://github.com/adaptlearning/adapt-contrib-vanilla/wiki/Icons) to choose from.

>**\_alignIconright** (boolean): Defines whether the icon is aligned to the left or right of the text. Default is `false` which aligns the icon to the left of the text.
>**\_iconAlignment** (string): Determines how the icon is aligned to the text. Options include `auto`, `left`, `right`, `top`, and `bottom`. When using `auto`, the position will automatically adjust based on whether the user is using an LTR or RTL lanaguage. The `_next` button will also be adjusted accordingly when using `auto` (i.e. the icon will be right-aligned for LTR and left-aligned for RTL). Defaults to `auto`.

>**text** (string): Defines the text that renders in the `button`.

>**ariaLabel** (string): This text is associated with the button. It renders as part of the aria label to give screen readers more information.

>**\_showTooltip** (boolean): Defines whether the tooltip renders on hover. Default is `false`.
> **\_tooltip** (object): The tooltip object. Used when tooltips are enabled globally

>**tooltip** (string): Defines the text that renders in the tooltip.
>> **\_isEnabled** (boolean): Enables tooltips on the button

#### **\_previous** / **\_root** / **\_up** / **\_next** / **\_sibling**
>> **text** (string): The text of the tooltip

#### **\_previous**, **\_root**, **\_up**, and **\_next** properties

>**\_customRouteId** (string): Overrides the route ID. For use when non standard route navigation is required.

----------------------------

**Framework versions:** 5.2+<br>
**Framework versions:** 5.30.2+<br>
**Vanilla versions:** 5.1.1+<br>
**Author / maintainer:** Kineo<br>
**Accessibility support:** WAI AA<br>
**RTL support:** Yes<br>
**Cross-platform coverage:** Chrome, Chrome for Android, Firefox (ESR + latest version), Edge, IE11, Safari 12+13 for macOS/iOS/iPadOS, Opera<br>
**Cross-platform coverage:** Chrome, Chrome for Android, Firefox (ESR + latest version), Edge, Safari for macOS/iOS/iPadOS, Opera<br>
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "git://github.com/cgkineo/adapt-pageNav.git"
},
"version": "2.4.0",
"framework": ">=5.2",
"framework": ">=5.30.2",
"homepage": "https://github.com/cgkineo/adapt-pageNav",
"issues": "https://github.com/cgkineo/adapt-pageNav/issues/",
"component": "pageNav",
Expand Down
Binary file removed demo.fw.png
Binary file not shown.
195 changes: 87 additions & 108 deletions example.json
Original file line number Diff line number Diff line change
@@ -1,118 +1,97 @@
// To go in the component.json file for each page
// --------------------------------------------------
{
"_id": "c-05",
"_parentId": "b-05",
"_type": "component",
"_component": "pageNav",
"_classes": "",
"_layout": "full",
"title": "",
"displayTitle": "",
"body": "",
"instruction": "",
"_loopStyleComment": {
"allPages": "loop sequentially through all pages in course",
"siblings": "loop sequentially through all pages in current parent object",
"none": "disable previous and next buttons at start and end of the pages in the current parent object"
},
"_loopStyle": "none",
"_shouldSkipOptionalPages": false,
"_buttons": {
"_returnToPreviousLocation": {
"_isEnabled": false,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClassComment": "Suggested icon = 'icon-controls-left'",
"_iconClass": "",
"_alignIconRight": false,
"text": "Return",
"ariaLabel": "Return to previous location",
"_showTooltip": false,
"tooltip": "{{displayTitle}}"
},
"_previous": {
// To go in the component.json file for each page
// --------------------------------------------------
{
"_id": "c-05",
"_parentId": "b-05",
"_type": "component",
"_component": "pageNav",
"_classes": "",
"_layout": "full",
"title": "",
"displayTitle": "",
"body": "",
"instruction": "",
"_loopStyleComment": {
"allPages": "loop sequentially through all pages in course",
"siblings": "loop sequentially through all pages in current parent object",
"none": "disable previous and next buttons at start and end of the pages in the current parent object"
},
"_loopStyle": "none",
"_shouldSkipOptionalPages": false,
"_buttons": {
"_root": {
"_isEnabled": true,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClass": "icon-home",
"_iconAlignment": "auto",
"text": "Go to main menu",
"ariaLabel": "Go to main menu",
"_tooltip": {
"_isEnabled": true,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClassComment": "Suggested icon = 'icon-controls-left'",
"_iconClass": "",
"_alignIconRight": false,
"text": "Previous",
"ariaLabel": "Previous Page",
"_showTooltip": false,
"tooltip": "{{displayTitle}}",
"_customRouteId": ""
"text": "{{displayTitle}}"
},
"_root": {
"_customRouteId": ""
},
"_up": {
"_isEnabled": false,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClass": "icon-controls-up",
"_iconAlignment": "auto",
"text": "Back to menu",
"ariaLabel": "Back to menu",
"_tooltip": {
"_isEnabled": true,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClassComment": "Suggested icon = 'icon-home'",
"_iconClass": "",
"_alignIconRight": false,
"text": "Go to main menu",
"ariaLabel": "Go to main menu",
"_showTooltip": false,
"tooltip": "{{displayTitle}}",
"_customRouteId": ""
"text": "{{displayTitle}}"
},
"_up": {
"_isEnabled": false,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClassComment": "Suggested icon = 'icon-controls-up'",
"_iconClass": "",
"_alignIconRight": false,
"text": "Back to menu",
"ariaLabel": "Back to menu",
"_showTooltip": false,
"tooltip": "{{displayTitle}}",
"_customRouteId": ""
},
"_next": {
"_customRouteId": ""
},
"_previous": {
"_isEnabled": true,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClass": "icon-controls-left",
"_iconAlignment": "auto",
"text": "Previous",
"ariaLabel": "Previous Page",
"_tooltip": {
"_isEnabled": true,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClassComment": "Suggested icon = 'icon-controls-right'",
"_iconClass": "",
"_alignIconRight": true,
"text": "Next",
"ariaLabel": "Next Page",
"_showTooltip": false,
"tooltip": "{{displayTitle}}",
"_customRouteId": ""
"text": "{{displayTitle}}"
},
"_sibling": {
"_isEnabled": false,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClass": "",
"_alignIconRight": false,
"text": "{{inc index}}",
"ariaLabel": "Page {{inc index}}",
"_showTooltip": false,
"tooltip": "{{displayTitle}}",
"_customRouteId": ""
"_customRouteId": ""
},
"_next": {
"_isEnabled": true,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClass": "icon-controls-right",
"_iconAlignment": "auto",
"text": "Next",
"ariaLabel": "Next Page",
"_tooltip": {
"_isEnabled": true,
"text": "{{displayTitle}}"
},
"_close": {
"_isEnabled": false,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClassComment": "Suggested icon = 'icon-cross'",
"_iconClass": "",
"_alignIconRight": false,
"text": "Close",
"ariaLabel": "Close window",
"_showTooltip": false,
"tooltip": "Close window"
"_customRouteId": ""
},
"_close": {
"_isEnabled": false,
"_lockUntilPageComplete": false,
"_order": 1,
"_classes": "",
"_iconClass": "icon-cross",
"_iconAlignment": "auto",
"text": "Close",
"ariaLabel": "Close window",
"_tooltip": {
"_isEnabled": true,
"text": "Close window"
}
}
}
}
Loading