npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-truncate-4elements

v0.3.4

Published

A generic component used to truncate text to a specified number of lines.

Downloads

3

Readme

Ember Truncate

Build Status npm version

This addon provides a component for truncating text in an Ember application.

Installation

  • npm install ember-truncate

Usage

To get started, place the truncate-multiline component in one of your templates and provide a string to the text attribute.

{{truncate-multiline text="Long text to truncate."}}

The block form offers customization beyond that of the inline form and support for nested DOM nodes. Instead of supplying the text attribute, render text or elements into the target component. Use the button component to customize the more/less button, or exclude it to remove the button entirely. The isTruncated property provides access to the current state of truncation.

{{#truncate-multiline as |tm|~}}
  {{#tm.target~}}
    Long text to truncate with <em><strong>really</strong> important</em> formatting.
  {{~/tm.target}}
  {{#tm.button}}{{if tm.isTruncated "more" "less"}}{{/tm.button}}
{{~/truncate-multiline}}

NB: It is recommended that you use the tilde ~ character to omit extra whitespace when using the block form.

Attributes

The truncate-multiline component offers other functionality via attributes.

lines

The number of lines at which the component truncates can be changed by setting the lines attribute. The default is 3 lines.

{{truncate-multiline text="Long text to truncate." lines=5}}

truncate

Programmatically controls expanding/collapsing the text. This attribute is especially useful when the button is omitted.

{{#truncate-multiline truncate=booleanInParent as |tm|~}}
  {{#tm.target~}}
    Long text to truncate.
  {{~/tm.target}}
{{~/truncate-multiline}}

Actions

The truncate-multiline component uses actions to signal change in truncation state.

onExpand

The onExpand action is triggered whenever the text is expanded.

{{truncate-multiline text="Long text to truncate." onExpand=(action "trackImpression")}}

onCollapse

The onCollapse action is triggered whenever the text is collapsed.

{{truncate-multiline text="Long text to truncate." onCollapse=(action "doSomeCoolThing")}}

onToggle

The onToggle action is triggered whenever the text is expanded or collapsed. The new truncation state is passed to the action: true for collapsed, false for expanded.

{{truncate-multiline text="Long text to truncate." onToggle=(action "updateTableOfContents")}}

Contributing

  • fork this repository
  • git clone your fork
  • npm install
  • make changes
  • npm test to verify tests pass for supported versions of Ember
  • git push changes to your fork
  • open a pull request against this repository

Running Tests

  • ember test runs tests against the version of Ember listed in package.json
  • ember test --server livereloads tests in Chrome, making failrues easier to debug
  • npm test runs tests against all supported versions of Ember
  • ember try:each runs tests against the latest versions of Ember (in addition to the supported Ember versions)