Skip to content

New: Add button icon option (fix #217) #222

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**.
Expand Down
2 changes: 2 additions & 0 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"src": "course/en/images/origami-menu-one.jpg"
},
"linkText": "View",
"_linkIconClass": "icon-controls-right",
"_linkIconPosition": "left",
"duration": "2 mins"
}

Expand Down
9 changes: 9 additions & 0 deletions less/boxMenuItem.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
11 changes: 11 additions & 0 deletions templates/boxMenuItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default function BoxMenuItem (props) {
body,
duration,
linkText,
_linkIconClass,
_linkIconPosition,
_isVisited,
_isLocked,
_isComplete,
Expand Down Expand Up @@ -100,13 +102,22 @@ export default function BoxMenuItem (props) {
'menu-item__button',
'boxmenu-item__button',
'js-btn-click',
_linkIconPosition && `has-icon-${_linkIconPosition}`,
_isVisited && 'is-visited',
_isLocked && 'is-locked'
])}
aria-label={ariaLabel}
aria-disabled={_isLocked ? true : null}
role="link"
>
{_linkIconClass &&
<span className="menu-item__button-icon boxmenu-item__button-icon" aria-hidden="true">
<span className={classes([
'icon',
_linkIconClass
])} />
</span>
}
{linkText &&
<span
className="menu-item__button-text boxmenu-item__button-text"
Expand Down