diff --git a/README.md b/README.md index 5290488..9aa8d17 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,10 @@ The following attributes, set within *contentObjects.json*, configure the defaul **linkText** (string): This text is displayed on the menu item's link/button. +**_linkIconClass** (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. See the list of all available [*vanilla* icons](https://github.com/adaptlearning/adapt-contrib-vanilla/wiki/Icons) to choose from. + +**_linkIconPosition** (string): Determines how the icon is aligned to the text. Options include `left` and `right`. Defaults to `left` if left blank. + **duration** (string): Optional text which follows **durationLabel** (e.g., `"2 mins"`). **\_boxMenu** (object): The boxMenu object that contains value for **\_renderAsGroup**. diff --git a/example.json b/example.json index 6bd8e4c..fad9904 100644 --- a/example.json +++ b/example.json @@ -56,6 +56,8 @@ "src": "course/en/images/origami-menu-one.jpg" }, "linkText": "View", + "_linkIconClass": "icon-controls-right", + "_linkIconPosition": "left", "duration": "2 mins" } diff --git a/less/boxMenuItem.less b/less/boxMenuItem.less index bede220..627fee2 100644 --- a/less/boxMenuItem.less +++ b/less/boxMenuItem.less @@ -12,4 +12,13 @@ @media (min-width: @device-width-medium) { width: 50%; } + + &__button { + display: flex; + column-gap: (@icon-padding / 4); + + &.has-icon-right { + flex-direction: row-reverse; + } + } } diff --git a/templates/boxMenuItem.jsx b/templates/boxMenuItem.jsx index 1af381c..4fb88cc 100644 --- a/templates/boxMenuItem.jsx +++ b/templates/boxMenuItem.jsx @@ -10,6 +10,8 @@ export default function BoxMenuItem (props) { body, duration, linkText, + _linkIconClass, + _linkIconPosition, _isVisited, _isLocked, _isComplete, @@ -100,6 +102,7 @@ export default function BoxMenuItem (props) { 'menu-item__button', 'boxmenu-item__button', 'js-btn-click', + _linkIconPosition && `has-icon-${_linkIconPosition}`, _isVisited && 'is-visited', _isLocked && 'is-locked' ])} @@ -107,6 +110,14 @@ export default function BoxMenuItem (props) { aria-disabled={_isLocked ? true : null} role="link" > + {_linkIconClass && +