Polymer-based web component for a D2L more-less control

[ This description is mirrored from README.md at github.com/BrightspaceUI/more-less on 2019-05-22 ]

d2l-more-less

Published on webcomponents.org Bower version Build status

Polymer-based web component for D2L's more/less control.

For further information on this and other components, refer to The Brightspace UI Guide.

Installation

bower install d2l-more-less

Usage

Include the webcomponents.js "lite" polyfill (for browsers who don't natively support web components), then import d2l-more-less.html:

<head>
  <script src="../webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="../d2l-more-less/d2l-more-less.html">
</head>

You can now wrap a d2l-more-less element around any content:

<d2l-more-less>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ultricies, ligula vulputate mattis aliquam, arcu arcu porttitor urna, ut pretium neque lorem venenatis elit. Fusce rutrum, nunc a tempor dictum, elit est lobortis libero, at lobortis nisl libero id enim. Vestibulum in lorem sed metus ornare faucibus a ac massa. Donec sodales massa vitae lacus blandit, at placerat erat blandit. Aenean consequat sapien ac viverra ornare. Nullam sem felis, ultrices nec egestas ut, mollis ac arcu. Nunc sit amet aliquam neque, fringilla lobortis justo. Sed pharetra, ipsum ut tempor tempor, sem risus tincidunt nisl, vitae feugiat lectus lorem a urna. In sit amet lobortis tellus. Sed suscipit magna et aliquam consequat. Pellentesque rhoncus ut dui at semper. Mauris vel ante euismod, tempus nunc eu, pellentesque lacus. Mauris consectetur ante eget consequat tempus.</p>
</d2l-more-less>

Attributes

height (4em)

The height attribute sets the maximum height of the content when in "less" mode. The d2l-more-less element itself will take up additional vertical space in order to provide the fading effect and the more/less controls themselves. If the content is not at least this height, d2l-more-less will become inactive and add nothing to the page.

<d2l-more-less height="10rem">
	<!-- content -->
</d2l-more-less>

expanded

The expanded attribute will be present when d2l-more-less is in "more" mode. The element can also be made expanded by default by using this attribute.

<d2l-more-less expanded>
	<!-- content -->
</d2l-more-less>

blur-color (#fff)

The blur-color attribute will control the gradient color of the blurring effect. It must be a properly formatted HEX color code, either in shorthand or longform.

<d2l-more-less blur-color="#f00">
	<!-- content -->
</d2l-more-less>

h-align

The h-align attribute controls the horizontal alignment of the more-less button, as documented in the BrightspaceUI/button component.

<d2l-more-less h-align="text">
	<!-- content -->
</d2l-more-less>

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:

polymer serve

To lint (eslint and Polymer lint):

npm run lint

Versioning

Commits and PR merges to master will automatically do a minor version bump which will:

  • Update the version in package.json
  • Add a tag matching the new version
  • Create a github release matching the new version

By using either [increment major] or [increment patch] notation inside your merge message, you can overwrite the default version upgrade of minor to the position of your choice.

Install

Link to this version
ImportedReleased 14 August 2018Apache License 2.0
Framework Support
Polymer 2.0+
Also supported:
Polymer 1 (2.2.2)
Browser Compatibility
Install with
bower install --save BrightspaceUI/more-less"#4.3.1"
Run the above Bower command in your project folder. If you have any issues installing, please contact the author.
Release notes - Version 4.3.1

Dependencies