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-resize-text

v1.1.2

Published

ember addon that makes use of ember-text-measurer to efficiently resize the font of a single line of text to make it fit

Downloads

1,238

Readme

ember-resize-text

Greenkeeper badge Latest NPM release TravisCI Build Status Coverage Status Code Climate Ember Observer Score Dependencies Dev Dependencies

ember addon that makes use of ember-text-measurer to efficiently resize the font of a single line of text to make it fit.

Installation

ember install ember-resize-text

Demo

check out the demo page

Usage

Since version 1.1.0 ember-resize-text comes as a mixin to use within ember components. A component is still included for easy usage and to maintain backwards compatibility.

Mixin

Just add the mixin to a component and the components font size will be adjusted automatically.

import ResizeText from 'ember-resize-text/mixins/resize-text';

export default Component.extend(ResizeText, {

  minSize: 12,
  maxSize: 18

});

Note: the mixin makes use of this.element.innerText to get the text to display and this.element.clientWidth (unless containerElement specifies a different element) to determine the available width.

Component

Just wrap your text within the resize-text component block-style.

{{#resize-text minSize=12 maxSize=20}}
  Please resize me!
{{/resize-text}}

Note: You can customize the component by overriding attributes like tagName or standard hooks.

Notice on resizing the window

This addon automatically registers event listeners on the windows resize event to make sure text still fits after the window is resized. If you want the text to increase its font size whenever the window is resized, make sure to add the appropriate styling to the add-ons resize-text css class. For instance consider this markup:

<nav>
  <span>first</span>
  {{#resize-text}}
    second
  {{/resize-text}}
</nav>

and the following css:

nav {
  width: 100%;
  display: flex
}

.resize-text {
  flex-grow: 1; /* allow the resize-text elements to increase its size */
}

The size of the font will not be increased if the element with resize-text class will not be able to increase its width in dependency to the parent's width. This is not built into the addon as this depends on the context in which the addon is used.

Parameters

|Paramter|type|description |-|-|-| |minSize| number | minimum font size in px | |maxSize| number | maximum font size in px | |containerElement| element | The containerElement parameter allows to specify an optional dom element whichs clientWidth property will be used to determine the available space. This is particularly useful when the dom element that should be resized is not a block element. For instance the text of a link should be resized, but should not occupy the full width unless needed.

Contribute

Contributing

See the Contributing guide for details.

License