Polymer-based web components for D2L image-actions
[ This description is mirrored from README.md at github.com/BrightspaceUI/image-action on 2019-05-22 ]
Looking for SASS-based
d2l-image-action? It's over here.
Polymer-based web component for D2L image actions, which are buttons or links associated with an image that perform an action when clicked.
For further information on this and other Brightspace UI components, see the docs at ui.developers.brightspace.com.
d2l-image-action can be installed from Bower:
bower install d2l-image-action
Include the webcomponents.js "lite" polyfill (for browsers who don't natively support web components), then import
d2l-image-action.html to get all three image-action web components:
<head> <script src="../webcomponentsjs/webcomponents-lite.js"></script> <link rel="import" href="../d2l-image-action/d2l-image-action.html"> </head>
<d2l-image-action-button> in cases where an action is being performed, and not a navigation. Actions are typically done using a
click event handler. Think about times you'd use a native
<button> element instead of an
Alternatively, if you wish to perform a browser navigation when the action is clicked, use
<d2l-image-action-link>. Think of places you'd use a native
<a> element instead of a
<d2l-image-action-link href="settings.html" icon="d2l-tier1:gear"> Settings </d2l-image-action-link>
As their name suggests, image-actions are intended to be used with an icon, specifically one which is
18px in size. To set the icon, use the
icon attribute, which takes a reference to a Polymer iron-iconset-svg source.
The d2l-icons component exposes all of the D2L icons as
iron-iconset-svg sources -- simply import them using the
tier1 category (for 18x18 icons) and reference them by key:
<link rel="import" href="../d2l-icons/tier1-icons.html"> <button is="d2l-image-action" icon="d2l-tier1:print">Print</button>
You can also create your own custom icon set -- simply follow Polymer's documentation.
Groups of image-actions
Often, multiple image-actions will appear together as a group. In order to properly space the actions out, wrap them in a
<d2l-image-action-group> custom element:
<d2l-image-action-group> <d2l-image-action-button icon="d2l-tier1:print">Print</d2l-image-action-button> <d2l-image-action-link icon="d2l-tier1:gear" href="http://www.google.ca"> Settings </d2l-image-action-link> <d2l-image-action-button icon="d2l-tier1:help">Help</d2l-image-action-button> </d2l-image-action-group>
Developing, Testing and Contributing
After cloning the repo, run
npm install to install dependencies.
If you don't have it already, install the Polymer CLI globally:
npm install -g polymer-cli
To start a local web server that hosts the demo page and tests:
npm run lint
- polymer#1.9 - 2