Compare commits

..

5 commits

Author SHA1 Message Date
f925d39e74 ci: add bidirectional sync with Forgejo
All checks were successful
Mirror to Forgejo / mirror (push) Successful in 3s
Publish to NPM / build (21.x, ubuntu-latest) (push) Successful in 46s
2026-02-07 18:29:21 +01:00
Lorenzo Iovino
b8de85a4f9
Update README.md 2024-07-10 14:10:50 +02:00
Lorenzo Iovino
f1519e2dc9 release(ng2-fittext): 2.0.0 2024-07-10 06:07:13 +02:00
Lorenzo Iovino
20be9e90f8 docs(readme.md): correct typo 2024-07-10 06:03:41 +02:00
Lorenzo Iovino
da502ed7f5
Support angular >=18 (#107)
* fix peerDependencies to handle angular >=18
* build(package.json): upgrade angular 18
* refactor(lib): removed renderer2 not used
* docs(readme): add table installation dependencies
2024-07-10 05:59:58 +02:00
8 changed files with 3426 additions and 3965 deletions

21
.github/workflows/mirror-to-forgejo.yml vendored Normal file
View file

@ -0,0 +1,21 @@
name: Mirror to Forgejo
on:
push:
branches: ["**"]
tags: ["**"]
delete:
jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push to Forgejo
run: |
git remote add forgejo https://loke:${{ secrets.FORGEJO_TOKEN }}@git.lorenzoiovino.com/loke/ng2-fittext.git
git push forgejo --all --force
git push forgejo --tags --force

View file

@ -5,7 +5,7 @@
<p align="center">An Angular 2+ directive, written in pure TypeScript (without jQuery!), to automatically scale the font size of an element so that it fits within its parent container.</p> <p align="center">An Angular 2+ directive, written in pure TypeScript (without jQuery!), to automatically scale the font size of an element so that it fits within its parent container.</p>
[![Download via NPM](https://img.shields.io/npm/v/ng2-fittext.svg)](https://www.npmjs.com/package/ng2-fittext) [![Download via NPM](https://img.shields.io/npm/v/ng2-fittext.svg)](https://www.npmjs.com/package/ng2-fittext)
![Angular](https://img.shields.io/badge/Angular-17-green.svg) ![Angular](https://img.shields.io/badge/Angular-18-green.svg)
![Build Status](https://github.com/thisloke/ng2-fittext/actions/workflows/tests.yml/badge.svg) ![Build Status](https://github.com/thisloke/ng2-fittext/actions/workflows/tests.yml/badge.svg)
![Contributions welcome](https://img.shields.io/badge/contributions-welcome-green.svg) ![Contributions welcome](https://img.shields.io/badge/contributions-welcome-green.svg)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
@ -18,11 +18,13 @@ Check out the live demo: [ng2-fittext Demo](https://stackblitz.com/edit/stackbli
## Installation ## Installation
Install the library using npm: Install the library using npm according to your angular version (see table below):
| Angular | ng2-fittext | command |
|---------|-------------|-------------------------------|
| <= v17 | 1.4.3 | ```npm i ng2-fittext@1.4.3``` |
| >= v18 | 2.0.0 | ```npm i ng2-fittext@2.0.0``` |
```bash
npm install --save ng2-fittext
```
### Usage ### Usage

7310
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
"ng": "./node_modules/.bin/ng", "ng": "./node_modules/.bin/ng",
"start": "node node_modules/@angular/cli/bin/ng serve", "start": "node node_modules/@angular/cli/bin/ng serve",
"build": "node node_modules/@angular/cli/bin/ng build --configuration production", "build": "node node_modules/@angular/cli/bin/ng build --configuration production",
"test": "node node_modules/@angular/cli/bin/ng test", "test": "node node_modules/@angular/cli/bin/ng test lib",
"test:headless": "node node_modules/@angular/cli/bin/ng test --browsers=ChromeHeadless", "test:headless": "node node_modules/@angular/cli/bin/ng test --browsers=ChromeHeadless",
"test:headless:singleRun": "node node_modules/@angular/cli/bin/ng test --no-watch --no-progress --browsers=ChromeHeadless lib", "test:headless:singleRun": "node node_modules/@angular/cli/bin/ng test --no-watch --no-progress --browsers=ChromeHeadless lib",
"release:minor": "cd ./projects/lib/ && npm version minor", "release:minor": "cd ./projects/lib/ && npm version minor",
@ -15,22 +15,22 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^17.0.8", "@angular/animations": "^18.0.6",
"@angular/common": "^17.0.8", "@angular/common": "^18.0.6",
"@angular/compiler": "^17.0.8", "@angular/compiler": "^18.0.6",
"@angular/core": "^17.0.8", "@angular/core": "^18.0.6",
"@angular/forms": "^17.0.8", "@angular/forms": "^18.0.6",
"@angular/platform-browser": "^17.0.8", "@angular/platform-browser": "^18.0.6",
"@angular/platform-browser-dynamic": "^17.0.8", "@angular/platform-browser-dynamic": "^18.0.6",
"@angular/router": "^17.0.8", "@angular/router": "^18.0.6",
"rxjs": "~7.8.0", "rxjs": "~7.8.0",
"tslib": "^2.3.0", "tslib": "^2.3.0",
"zone.js": "~0.14.2" "zone.js": "~0.14.2"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^17.0.8", "@angular-devkit/build-angular": "^18.0.7",
"@angular/cli": "^17.0.8", "@angular/cli": "^18.0.7",
"@angular/compiler-cli": "^17.0.8", "@angular/compiler-cli": "^18.0.6",
"@types/jasmine": "~5.1.0", "@types/jasmine": "~5.1.0",
"@types/jasminewd2": "~2.0.3", "@types/jasminewd2": "~2.0.3",
"@types/node": "^18.18.0", "@types/node": "^18.18.0",
@ -40,7 +40,7 @@
"karma-coverage": "~2.2.0", "karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0", "karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0", "karma-jasmine-html-reporter": "~2.1.0",
"ng-packagr": "^17.0.0", "ng-packagr": "^18.0.0",
"typescript": "5.2.2" "typescript": "5.4.5"
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "ng2-fittext", "name": "ng2-fittext",
"version": "1.4.3", "version": "2.0.0",
"description": "Ng2-fittext: An Angular2+ directive that change the font size until it fit the upper level container dimension.", "description": "Ng2-fittext: An Angular2+ directive that change the font size until it fit the upper level container dimension.",
"keywords": [ "keywords": [
"ng2-fittext", "ng2-fittext",
@ -21,6 +21,7 @@
"angular 15", "angular 15",
"angular 16", "angular 16",
"angular 17", "angular 17",
"angular 18",
"fit text", "fit text",
"responsive text", "responsive text",
"responsive font size", "responsive font size",
@ -29,8 +30,8 @@
"author": "Lorenzo Iovino", "author": "Lorenzo Iovino",
"license": "MIT", "license": "MIT",
"peerDependencies": { "peerDependencies": {
"@angular/common": "^17.0.0", "@angular/common": ">=18.0.0",
"@angular/core": "^17.0.0" "@angular/core": ">=18.0.0"
}, },
"dependencies": { "dependencies": {
"tslib": "^2.3.0" "tslib": "^2.3.0"

View file

@ -1,15 +1,13 @@
import { Ng2FittextDirective } from '../../ng2-fittext.directive'; import { Ng2FittextDirective } from './ng2-fittext.directive';
import { Renderer2, ElementRef } from '@angular/core'; import { Renderer2, ElementRef } from '@angular/core';
describe('Class: Ng2FittextDirective', () => { describe('Class: Ng2FittextDirective', () => {
let ng2FittextDirective: Ng2FittextDirective; let ng2FittextDirective: Ng2FittextDirective;
let elMock: ElementRef; let elMock: ElementRef;
let rendererMock: Renderer2;
beforeEach(() => { beforeEach(() => {
elMock = {} as ElementRef; elMock = {} as ElementRef;
rendererMock = {} as Renderer2; ng2FittextDirective = new Ng2FittextDirective(elMock);
ng2FittextDirective = new Ng2FittextDirective(elMock, rendererMock);
}); });
describe('Method: setFontSize', () => { describe('Method: setFontSize', () => {

View file

@ -9,7 +9,6 @@ import {
EventEmitter, EventEmitter,
OnChanges, OnChanges,
OnInit, OnInit,
Renderer2,
} from '@angular/core'; } from '@angular/core';
@Directive({ @Directive({
@ -35,7 +34,7 @@ export class Ng2FittextDirective
private speed = 1.05; private speed = 1.05;
private done = false; private done = false;
constructor(public el: ElementRef<HTMLElement>, public renderer: Renderer2) {} constructor(public el: ElementRef<HTMLElement>) {}
setFontSize(fontSize: number): void { setFontSize(fontSize: number): void {
if (this.isVisible() && !this.isDone()) { if (this.isVisible() && !this.isDone()) {