All Projects → lokenxo → ng2-fittext

lokenxo / ng2-fittext

Licence: MIT license
An Angular2+ directive that autoscale the font size of an element until it fit the upper level container dimension.

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to ng2-fittext

Magento-2-aws-cluster-terraform
Magento 2 AWS autoscaling cluster with Terraform and Packer or ImageBuilder. Adobe Commerce Cloud alternative. The best ecommerce infrastructure. Drive more sales online. Transparent billing. Developer-friendly. No hidden bottlenecks.
Stars: ✭ 107 (+245.16%)
Mutual labels:  auto-scaling
atlassian-kubernetes
All things Atlassian and Kubernetes
Stars: ✭ 30 (-3.23%)
Mutual labels:  auto-scaling
shamash
Autoscaling for Google Cloud Dataproc
Stars: ✭ 31 (+0%)
Mutual labels:  auto-scaling
bluechatter
Deploy & Scale a chat app using Cloud Foundry, Docker Container and Kubernetes
Stars: ✭ 64 (+106.45%)
Mutual labels:  auto-scaling
eks-hpa-profile
An eksctl gitops profile for autoscaling with Prometheus metrics on Amazon EKS on AWS Fargate
Stars: ✭ 26 (-16.13%)
Mutual labels:  auto-scaling
redis
Baidu Ksarch Redis - a production solution of redis cluster
Stars: ✭ 89 (+187.1%)
Mutual labels:  auto-scaling
docker-kube-amqp-autoscale
Dynamically scale kubernetes resources using length of an AMQP queue
Stars: ✭ 29 (-6.45%)
Mutual labels:  auto-scaling
Rfs
✩ Automates responsive resizing ✩
Stars: ✭ 2,789 (+8896.77%)
Mutual labels:  font-size
Fitty
✨ Makes text fit perfectly
Stars: ✭ 3,321 (+10612.9%)
Mutual labels:  font-size
DDHTweaks
Tweak UI elements at run time to find the perfect values
Stars: ✭ 27 (-12.9%)
Mutual labels:  font-size
scss-font-lock
This is a SCSS mixin used to create CSS locks for responsive typography. To make in convenient to use it allows you to use both px and em as units and if anything goes wrong, it will let you know during the compile using scss @warn and also print an error message on top of the text in the application or website.
Stars: ✭ 18 (-41.94%)
Mutual labels:  font-size
accessibility-buttons
Buttons to add/remove contrast and increase/decrease font size.
Stars: ✭ 61 (+96.77%)
Mutual labels:  font-size
fancy-textfill
Fast implementation for resizing text to fill its container.
Stars: ✭ 17 (-45.16%)
Mutual labels:  font-size
apple-emoji-linux
Apple Color Emoji for Linux
Stars: ✭ 392 (+1164.52%)
Mutual labels:  font-size
Awesome Angular Components
Catalog of Angular 2+ Components & Libraries
Stars: ✭ 3,185 (+10174.19%)
Mutual labels:  angular2-directive
awesome-angular
💖 A list of awesome Angular (2️⃣➕) resources
Stars: ✭ 61 (+96.77%)
Mutual labels:  angular2-directive
ng2-right-click-menu
Right click context menu for Angular 2+
Stars: ✭ 51 (+64.52%)
Mutual labels:  angular2-directive

ng2-fittext

An Angular2 directive written in pure typescript (and without jquery!), to autoscale the font size of an element so that it fits an upper level container.

Demo

http://plnkr.co/edit/v0TQaYepV4E2Heur02j5?p=preview

Installation

Install the library

$ npm install --save ng2-fittext

Usage

  1. Declare it in your module
    import {Ng2FittextModule} from "ng2-fittext";
    @NgModule({
      imports: [
        Ng2FittextModule
      ]
    })
  2. Use it in your components
    import {Component} from '@angular/core';
    @Component({
      selector: 'label',
      template: `<div #container>
                    <div [fittext]="true" [activateOnResize]="true" [container]="container">Bla bla bla...</div>
                </div>`
    })
    export class LabelComponent {}

Examples

Fit to the parent element (this works if you have a variable number of elements between your element and its parent)

import {Component} from '@angular/core';
@Component({
  selector: 'label',
  template: `<div>
                <div [fittext]="true" [activateOnResize]="true">Bla bla bla...</div>
            </div>`
})
export class LabelComponent {}

NEW! Support for autoresize input box!

import {Component} from '@angular/core';
@Component({
  selector: 'inputbox',
  template: `<div #container>
                <input [fittext]="true" [activateOnResize]="true" [container]="container" [activateOnInputEvents]="true">`,
            </div>`
})

export class InputBoxComponent {}

NEW! Support for maxFontSize!

import {Component} from '@angular/core';
@Component({
  selector: 'inputbox',
  template: `<div>
                <input [fittext]="true" [activateOnResize]="true" [activateOnInputEvents]="true" [minFontSize]="40" [maxFontSize]="100">`,
            </div>`
})
export class InputBoxComponent {}

Input Parameters:

Parameter Description Values
fittext the directive selector true/false
container the container to fit (if not present it fits to the parent container by default) ElementRef
activateOnResize enable/disable the autofit in case of window resize true or false (default false)
activateOnInputEvents enable/disable the autofit in case of input box events (keydown, keyup etc..) true or false (default false)
maxFontSize maximum font size number, default is 1000
!deprecated! useMaxFontSize use max font size if is true deprecated!
minFontSize minimum font size number, default is 7
modelToWatch pass model to watch, when this model changes -> font size is automatically recalculated any type of model

Output Parameters:

Parameter Description Values
fontSizeChanged current font size string

Development

Want to contribute? Great! Simply, clone the repository!

I created this library because I always spent too much time to solve this problem and didn't find anything on the web (13/03/2017) that does this without jquery and that is also easily integrable in angular2. For sure it is not the best implementation, maybe is not the best way to do it, but, it gets the job done.

Todos

  • Write tests
  • Find a better algorithm to find the font-size who fits better the container

License

MIT

Lorenzo I.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].