Skip to content

Commit

Permalink
v 1.0.2 / update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
sollenne committed Jun 5, 2017
1 parent a1ca2da commit e2d983d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 3 deletions.
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ng4-fittext

Angular4 directive (typescript) to do what fittext.js did when jquery was cool.

Basically, This auto-scales the font size to fit the width of it's container.


### Demo

coming soon

### Installation

Install the library
```sh
$ npm install --save ng4-fittext
```

### Usage

Import it in your Angular4 project like a module

1) Declare it in your module
```sh
import {Ng4FittextModule} from "ng4-fittext/ng4fittext";
@NgModule({
imports: [
Ng4FittextModule
]
})

```

2) Use it in your components
```sh
import {Component} from '@angular/core';
@Component({
selector: 'hero',
template: `<div #container class="hero">
<h1 [fittext]="true" [activateOnResize]="true" [container]="container">RESIZES THIS TEXT</h1>
</div>`
})
export class HeroComponent {}
```

Parameters:

| Parameter | Description | Values |
| --- | --- | --- |
| fittext | is the selector of the directive | true/false
| container | the container to fit | ElementRef
| activateOnResize | enable/disable the auto-scale in case of window resize | true or false (default false)
| compression | compression rate. How fast should the text resize | number (default 1)
| minFontSize | enable/disable the autofit in case of window resize | number (default -infinity)
| MaxFontSize | enable/disable the autofit in case of window resize | number (default bitSize limit)


### Development

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

fittext.js was pretty useful up until nobody liked jquery anymore. There was an existing ng-1 lib and a sketchy ng-2 directive. This should take care of ng-4+.

### Todos

- Write tests
- default max font size
- default min font size

License
----

ISC


**- Rich**

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng4-fittext",
"version": "1.0.1",
"version": "1.0.2",
"description": "An Angular4.* directive to auto-scale the font-size of an element to fit it's parent element.",
"main": "index.ts",
"scripts": {
Expand Down
3 changes: 1 addition & 2 deletions src/ng4fittext.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {Directive, ElementRef, Input, AfterViewInit, HostListener} from '@angula
})
export class Ng4FittextDirective implements AfterViewInit {

@Input('appFitTextDirective') fittext: boolean;
@Input('fittext') fittext: boolean;
@Input('container') container: HTMLDivElement;
@Input('activateOnResize') activateOnResize = true;
@Input('activateOnInputEvents') activateOnInputEvents: boolean;
@Input('maxFontSize') maxFontSize: number;
@Input('minFontSize') minFontSize: number;
@Input('compression') compression: number;
Expand Down

0 comments on commit e2d983d

Please sign in to comment.