Ref: changed file and folder organization

This commit is contained in:
lorenzo 2020-03-12 21:43:21 +01:00
parent dcca18224b
commit d8fafd9e94
49 changed files with 874 additions and 14455 deletions

180
.idea/workspace.xml generated
View file

@ -2,9 +2,55 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="6d9e6998-eced-4f47-8fb4-3257db3e18e7" name="Default" comment="Version upgrade 1.2.8">
<change afterPath="$PROJECT_DIR$/src/lib/.gitignore" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/lib/tsconfig.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.npmignore" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/.npmignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/.editorconfig" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/.gitignore" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/README.md" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/angular.json" beforeDir="false" afterPath="$PROJECT_DIR$/angular.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/browserslist" beforeDir="false" afterPath="$PROJECT_DIR$/browserslist" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/e2e/protractor.conf.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/e2e/src/app.e2e-spec.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/e2e/src/app.po.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/e2e/tsconfig.e2e.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/package-lock.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/package.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/app/app.component.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/app.component.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/app/app.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/app.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/app/app.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/app.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/app/app.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/app/app.module.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/app/ng2-fittext.directive.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/assets/.gitkeep" beforeDir="false" afterPath="$PROJECT_DIR$/src/assets/.gitkeep" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/browserslist" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/environments/environment.prod.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/environments/environment.prod.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/environments/environment.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/environments/environment.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/favicon.ico" beforeDir="false" afterPath="$PROJECT_DIR$/src/favicon.ico" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/src/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/karma.conf.js" beforeDir="false" afterPath="$PROJECT_DIR$/karma.conf.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/main.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/polyfills.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/polyfills.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/styles.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/styles.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/test.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/tsconfig.app.json" beforeDir="false" afterPath="$PROJECT_DIR$/tsconfig.app.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/tsconfig.spec.json" beforeDir="false" afterPath="$PROJECT_DIR$/tsconfig.spec.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/src/tslint.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/tsconfig.app.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/tsconfig.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/tsconfig.spec.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/examples/dev/tslint.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/index.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/directives/ng2-fittext.directive.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/directives/ng2-fittext.directive.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/index.ts" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/ng2-fittext.module.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/ng2-fittext.module.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/package-lock.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/lib/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tsconfig.json" beforeDir="false" afterPath="$PROJECT_DIR$/tsconfig.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/tslint.json" beforeDir="false" afterPath="$PROJECT_DIR$/tslint.json" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -14,10 +60,10 @@
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="PackageJsonUpdateNotifier">
<dismissed value="$PROJECT_DIR$/package.json" />
</component>
<component name="ProjectId" id="1SBukDi2PHkdi0mBUWyiXe8YIvk" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
@ -27,60 +73,54 @@
<property name="HbShouldOpenHtmlAsHb" value="" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/examples/dev" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.tslint" value="C:/Users/Lorenzo/work/ngx-fittext/examples/dev/node_modules/tslint" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="nodejs_interpreter_path" value="node" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="prettierjs.PrettierConfiguration.Package" value="$PROJECT_DIR$/node_modules/prettier" />
<property name="settings.editor.selected.configurable" value="configurable.group.appearance" />
<property name="ts.external.directory.path" value="$PROJECT_DIR$/examples/dev/node_modules/typescript/lib" />
<property name="ts.external.directory.path" value="$PROJECT_DIR$/node_modules/typescript/lib" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/examples/dev" />
<recent name="$PROJECT_DIR$/examples/dev/src" />
<recent name="C:\Users\Lorenzo\work\ng2-fittext" />
<recent name="C:\Users\Lorenzo\work\ngx-fittext" />
<recent name="C:\Users\Lorenzo\work\ngx-fittext\examples\dev\src\app" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/src" />
<recent name="$PROJECT_DIR$" />
<recent name="$PROJECT_DIR$/examples/dev/lib" />
<recent name="$PROJECT_DIR$/examples/dev" />
</key>
</component>
<component name="RunManager" selected="npm.build (1)">
<configuration name="build (1)" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/examples/dev/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="build (2)" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/src/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<component name="RunManager" selected="npm.pack">
<configuration name="build" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/src/lib/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="pack" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="build" />
<script value="pack" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<configuration name="publish" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/src/package.json" />
<package-json value="$PROJECT_DIR$/src/lib/package.json" />
<command value="run" />
<scripts>
<script value="publish" />
@ -89,8 +129,8 @@
<envs />
<method v="2" />
</configuration>
<configuration name="start" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/examples/dev/package.json" />
<configuration name="start (1)" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start" />
@ -99,20 +139,30 @@
<envs />
<method v="2" />
</configuration>
<configuration name="test (1)" type="js.build_tools.npm" temporary="true" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="test" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
<list>
<item itemvalue="npm.start" />
<item itemvalue="npm.start (1)" />
<item itemvalue="npm.test (1)" />
<item itemvalue="npm.build" />
<item itemvalue="npm.build (2)" />
<item itemvalue="npm.publish" />
<item itemvalue="npm.build (1)" />
<item itemvalue="npm.pack" />
</list>
<recent_temporary>
<list>
<item itemvalue="npm.build (1)" />
<item itemvalue="npm.start" />
<item itemvalue="npm.pack" />
<item itemvalue="npm.publish" />
<item itemvalue="npm.build (2)" />
<item itemvalue="npm.build" />
<item itemvalue="npm.test (1)" />
<item itemvalue="npm.start (1)" />
</list>
</recent_temporary>
</component>
@ -150,6 +200,7 @@
<workItem from="1572945589004" duration="252000" />
<workItem from="1581498853844" duration="6408000" />
<workItem from="1581516389687" duration="1254000" />
<workItem from="1584040192080" duration="5336000" />
</task>
<task id="LOCAL-00001" summary="Ref: clean code&#10;Ref: update examples">
<created>1557130876740</created>
@ -205,29 +256,54 @@
<option name="LAST_COMMIT_MESSAGE" value="Version upgrade 1.2.8" />
</component>
<component name="WindowStateProjectService">
<state x="2475" y="1161" width="800" height="684" key="#TSLint" timestamp="1584041395355">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state x="2475" y="1161" width="800" height="684" key="#TSLint/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584041395355" />
<state x="642" y="341" width="615" height="397" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1581499657241">
<screen x="0" y="27" width="1920" height="1011" />
</state>
<state x="642" y="341" width="615" height="397" key="#com.intellij.fileTypes.FileTypeChooser/0.27.1920.1011/1920.0.1920.1080@0.27.1920.1011" timestamp="1581499657241" />
<state width="1897" height="242" key="GridCell.Tab.0.bottom" timestamp="1581516934990">
<screen x="0" y="27" width="1920" height="1011" />
<state x="2613" y="1249" width="524" height="509" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1584044666474">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state x="2613" y="1249" width="524" height="509" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584044666474" />
<state width="1897" height="242" key="GridCell.Tab.0.bottom" timestamp="1584045609089">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state width="1897" height="242" key="GridCell.Tab.0.bottom/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@0.219.1920.1080" timestamp="1584040732589" />
<state width="1897" height="242" key="GridCell.Tab.0.bottom/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584045609089" />
<state width="1897" height="242" key="GridCell.Tab.0.bottom/0.27.1920.1011/1920.0.1920.1080@0.27.1920.1011" timestamp="1581516934990" />
<state width="1897" height="242" key="GridCell.Tab.0.center" timestamp="1581516934990">
<screen x="0" y="27" width="1920" height="1011" />
<state width="1897" height="242" key="GridCell.Tab.0.center" timestamp="1584045609089">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state width="1897" height="242" key="GridCell.Tab.0.center/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@0.219.1920.1080" timestamp="1584040732589" />
<state width="1897" height="242" key="GridCell.Tab.0.center/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584045609089" />
<state width="1897" height="242" key="GridCell.Tab.0.center/0.27.1920.1011/1920.0.1920.1080@0.27.1920.1011" timestamp="1581516934990" />
<state width="1897" height="242" key="GridCell.Tab.0.left" timestamp="1581516934990">
<screen x="0" y="27" width="1920" height="1011" />
<state width="1897" height="242" key="GridCell.Tab.0.left" timestamp="1584045609088">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state width="1897" height="242" key="GridCell.Tab.0.left/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@0.219.1920.1080" timestamp="1584040732588" />
<state width="1897" height="242" key="GridCell.Tab.0.left/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584045609088" />
<state width="1897" height="242" key="GridCell.Tab.0.left/0.27.1920.1011/1920.0.1920.1080@0.27.1920.1011" timestamp="1581516934990" />
<state width="1897" height="242" key="GridCell.Tab.0.right" timestamp="1581516934990">
<screen x="0" y="27" width="1920" height="1011" />
<state width="1897" height="242" key="GridCell.Tab.0.right" timestamp="1584045609089">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state width="1897" height="242" key="GridCell.Tab.0.right/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@0.219.1920.1080" timestamp="1584040732589" />
<state width="1897" height="242" key="GridCell.Tab.0.right/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584045609089" />
<state width="1897" height="242" key="GridCell.Tab.0.right/0.27.1920.1011/1920.0.1920.1080@0.27.1920.1011" timestamp="1581516934990" />
<state x="595" y="263" width="730" height="538" key="find.popup" timestamp="1581517068558">
<screen x="0" y="27" width="1920" height="1011" />
<state x="2100" y="1057" width="1536" height="901" key="MergeDialog" timestamp="1584041943170">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state x="2100" y="1057" width="1536" height="901" key="MergeDialog/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584041943170" />
<state x="2585" y="1218" width="580" height="571" key="MultipleFileMergeDialog" timestamp="1584041950044">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state x="2585" y="1218" width="580" height="571" key="MultipleFileMergeDialog/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584041950044" />
<state x="2515" y="1212" width="886" height="578" key="find.popup" timestamp="1584044814605">
<screen x="1920" y="960" width="1920" height="1080" />
</state>
<state x="2515" y="1212" width="886" height="578" key="find.popup/0.219.1920.1080/1920.0.1280.960/1920.960.1920.1080@1920.960.1920.1080" timestamp="1584044814605" />
<state x="595" y="263" width="730" height="538" key="find.popup/0.27.1920.1011/1920.0.1920.1080@0.27.1920.1011" timestamp="1581517068558" />
<state x="685" y="364" width="540" height="343" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1581516396481">
<screen x="0" y="27" width="1920" height="1011" />

View file

@ -2,11 +2,7 @@
An Angular2 directive written in pure typescript (and without jquery!), for autoscale the font size of an element to fit an upper level container.
How many times your font doesn't scale automatically to fit the size of the container? Always, if you don't say it to do that!
How you can say it? ng2-fittext!
### Demo
http://plnkr.co/edit/v0TQaYepV4E2Heur02j5?p=preview
### Installation
@ -17,9 +13,6 @@ $ npm install --save ng2-fittext
```
### Usage
Import it in your Angular2 project like a module
1) Declare it in your module
```sh
import {Ng2FittextModule} from "ng2-fittext";
@ -28,73 +21,58 @@ Import it in your Angular2 project like a module
Ng2FittextModule
]
})
```
```
2) Use it in your components
Fit with specified container (can be the parent or a deeper ancestor)
```sh
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 with the parent element (this works if you have a variable number of element between element and parent)
Fit with the parent element (this works if you have a variable number of element between element and parent)
```sh
import {Component} from '@angular/core';
```sh
import {Component} from '@angular/core';
@Component({
selector: 'label',
template: `<div>
<div [fittext]="true" [activateOnResize]="true">Bla bla bla...</div>
</div>`
})
export class LabelComponent {}
```
@Component({
selector: 'label',
template: `<div>
<div [fittext]="true" [activateOnResize]="true">Bla bla bla...</div>
</div>`
})
**NEW! Support for autoresize input box!**
export class LabelComponent {}
```
```sh
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!**
**NEW! Support for autoresize input box!**
```sh
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!**
```sh
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 {}
```
```sh
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:
@ -138,3 +116,4 @@ MIT
**Lorenzo I.**

View file

@ -13,9 +13,9 @@
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/dev",
"index": "src/index.html",
"main": "src/main.ts",
"outputPath": "dist",
"index": "./src/index.html",
"main": "./src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,

View file

@ -1,13 +0,0 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

View file

@ -1,39 +0,0 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db

View file

@ -1,27 +0,0 @@
# Ved
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.0.1.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View file

@ -1,28 +0,0 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};

View file

@ -1,14 +0,0 @@
import { AppPage } from './app.po';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getParagraphText()).toEqual('Welcome to app!');
});
});

View file

@ -1,11 +0,0 @@
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get('/');
}
getParagraphText() {
return element(by.css('app-root h1')).getText();
}
}

View file

@ -1,13 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,48 +0,0 @@
{
"name": "dev",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --aot --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.0.0",
"@angular/common": "~9.0.0",
"@angular/compiler": "~9.0.0",
"@angular/core": "~9.0.0",
"@angular/forms": "~9.0.0",
"@angular/platform-browser": "~9.0.0",
"@angular/platform-browser-dynamic": "~9.0.0",
"@angular/router": "~9.0.0",
"ng2-fittext": "^1.2.9",
"rxjs": "~6.5.4",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.1",
"@angular/cli": "~9.0.1",
"@angular/compiler-cli": "~9.0.0",
"@angular/language-service": "~9.0.0",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.1.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "~3.7.5"
}
}

View file

@ -1,135 +0,0 @@
import {
AfterViewChecked,
AfterViewInit,
Directive,
ElementRef, HostListener,
Input,
OnChanges,
OnInit,
Renderer2
} from '@angular/core';
@Directive({
selector: '[fittext]'
})
export class Ng2FittextDirective implements AfterViewInit, OnInit, OnChanges, AfterViewChecked {
@Input('fittext') fittext: any;
@Input('activateOnResize') activateOnResize: boolean;
@Input('container') container: HTMLElement;
@Input('activateOnInputEvents') activateOnInputEvents: boolean;
@Input('minFontSize') minFontSize = 7;
@Input('maxFontSize') maxFontSize = 1000;
/* Deprecated */
@Input('useMaxFontSize') useMaxFontSize = true;
@Input('modelToWatch') modelToWatch: any;
private fontSize = 1000;
private speed = 1.05;
private done = false;
constructor(public el: ElementRef,
public renderer: Renderer2) {}
setFontSize(fontSize: number) {
if (this.isVisible() && !this.done) {
if (fontSize < this.minFontSize) {
fontSize = this.minFontSize;
}
if(fontSize > this.maxFontSize){
fontSize = this.maxFontSize;
}
this.fontSize = fontSize;
return this.el.nativeElement.style.setProperty('font-size', (fontSize).toString() + 'px');
}
}
calculateFontSize(fontSize: number, speed: number) {
return Math.floor(fontSize / speed);
}
checkOverflow(parent: any, children: any) {
const overflowX = children.scrollWidth - parent.clientWidth;
const overflowY = children.clientHeight - parent.clientHeight;
return (overflowX > 1 || overflowY > 1);
}
@HostListener('window:resize', ['$event'])
onResize() {
this.done = false;
if (this.activateOnResize && this.fittext) {
if (this.activateOnInputEvents && this.fittext) {
this.setFontSize(this.getStartFontSizeFromHeight());
} else {
this.setFontSize(this.getStartFontSizeFromWeight());
}
this.ngAfterViewInit();
}
}
@HostListener('input', ['$event'])
onInputEvents() {
this.done = false;
if (this.activateOnInputEvents && this.fittext) {
this.setFontSize(this.getStartFontSizeFromHeight());
this.ngAfterViewInit();
}
}
ngOnInit() {
this.done = false;
this.el.nativeElement.style.setProperty('will-change', 'content');
this.ngAfterViewInit();
}
ngAfterViewInit() {
if (this.isVisible() && !this.done) {
if (this.fittext) {
const overflow = this.container ? this.checkOverflow(this.container, this.el.nativeElement)
: this.checkOverflow(this.el.nativeElement.parentElement, this.el.nativeElement);
if (overflow) {
if (this.fontSize > this.minFontSize) {
// iterate only until font size is bigger than minimal value
this.setFontSize(this.calculateFontSize(this.fontSize, this.speed));
this.ngAfterViewInit();
}
} else {
this.done = true;
}
}
}
}
ngOnChanges(changes: any): void {
if (changes.modelToWatch) {
// change of model to watch - call ngAfterViewInit where is implemented logic to change size
setTimeout(() => {
this.done = false;
this.setFontSize(this.maxFontSize);
this.ngAfterViewInit();
});
}
}
ngAfterViewChecked() {
if (this.fontSize > this.minFontSize) {
this.setFontSize(this.getStartFontSizeFromHeight());
this.ngAfterViewInit();
}
}
private getStartFontSizeFromHeight(): number {
return this.container ? this.container.clientHeight : this.el.nativeElement.parentElement.clientHeight;
}
private getStartFontSizeFromWeight(): number {
return this.container ? this.container.clientWidth : this.el.nativeElement.parentElement.clientWidth;
}
private isVisible(): boolean {
return this.getStartFontSizeFromHeight() > 0;
}
}

View file

@ -1,9 +0,0 @@
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For IE 9-11 support, please uncomment the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
# IE 9-11

View file

@ -1,17 +0,0 @@
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}

View file

@ -1,17 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"angularCompilerOptions": {
"enableIvy": true
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
]
}

View file

@ -1,26 +0,0 @@
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}

View file

@ -1,18 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"src/test.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

View file

@ -1,91 +0,0 @@
{
"extends": "tslint:recommended",
"rules": {
"array-type": false,
"arrow-parens": false,
"deprecation": {
"severity": "warning"
},
"component-class-suffix": true,
"contextual-lifecycle": true,
"directive-class-suffix": true,
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
],
"import-blacklist": [
true,
"rxjs/Rx"
],
"interface-name": false,
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-consecutive-blank-lines": false,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"object-literal-sort-keys": false,
"ordered-imports": false,
"quotemark": [
true,
"single"
],
"trailing-comma": false,
"no-conflicting-lifecycle": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-inputs-metadata-property": true,
"no-output-native": true,
"no-output-on-prefix": true,
"no-output-rename": true,
"no-outputs-metadata-property": true,
"template-banana-in-box": true,
"template-no-negated-async": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true
},
"rulesDirectory": [
"codelyzer"
]
}

View file

@ -1 +0,0 @@
export * from './src';

983
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,18 @@
{
"name": "ng2-fittext",
"version": "1.2.10",
"description": "Ng2 Fittext, an Angular library",
"keywords": [],
"author": "Lorenzo Iovino",
"license": "MIT",
"name": "dev",
"version": "0.0.0",
"scripts": {
"ng": "./node_modules/.bin/ng",
"start": "./node_modules/.bin/ng serve",
"build": "./node_modules/.bin/ng build --aot --prod",
"test": "./node_modules/.bin/ng test",
"lint": "./node_modules/.bin/ng lint",
"e2e": "./node_modules/.bin/ng e2e",
"pack": "./node_modules/.bin/ng-packagr -p ./src/lib/package.json",
"prepublish": "npm run test",
"publish": "npm run pack && npm publish dist --access=public"
},
"private": true,
"dependencies": {
"@angular/animations": "~9.0.0",
"@angular/common": "~9.0.0",
@ -34,13 +42,11 @@
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"ng-packagr": "^9.0.0",
"ng-packagr": "^9.0.3",
"prettier": "^1.19.1",
"protractor": "~5.4.3",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "~3.7.5"
},
"repository": {
"url": "https://github.com/lokenxo/ng2-fittext.git"
}
}

View file

@ -1,17 +1,17 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {Ng2FittextDirective} from './ng2-fittext.directive';
import {Ng2FittextModule} from '../lib/ng2-fittext.module';
@NgModule({
declarations: [
AppComponent,
Ng2FittextDirective
AppComponent
],
imports: [
BrowserModule
BrowserModule,
Ng2FittextModule
],
providers: [Ng2FittextDirective],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Before After
Before After

View file

@ -1 +0,0 @@
export * from './directives/ng2-fittext.directive';

6
src/lib/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
build
coverage
dist
debug.log
node_modules
out-tsc

View file

@ -9,7 +9,6 @@ coverage
debug.log
DEVELOPMENT.md
dist
index.ts
karma.conf.js
node_modules
out-tsc

View file

@ -1,6 +1,6 @@
{
"name": "ng2-fittext",
"version": "1.2.10",
"version": "1.2.11",
"description": "Ng2-fittext: An Angular2+ directive that change the font size until it fit the upper level container dimension.",
"keywords": [
"ng2-fittext",
@ -21,16 +21,7 @@
"entryFile": "./ng2-fittext.module.ts"
}
},
"scripts": {
"transpile": "ngc",
"build": "../node_modules/.bin/ng-packagr -p package.json",
"prepublish": "npm run test",
"publish": "npm run build && npm publish dist --access=public"
},
"repository": {
"url": "https://github.com/lokenxo/ng2-fittext.git"
},
"devDependencies": {
"prettier": "^1.19.1"
}
}

35
src/lib/tsconfig.json Normal file
View file

@ -0,0 +1,35 @@
{
"angularCompilerOptions": {
"strictMetadataEmit": true,
"skipTemplateCodegen": true
},
"compilerOptions": {
"baseUrl": "tsconfig",
"declaration": true,
"stripInternal": true,
"strictNullChecks": true,
"noImplicitAny": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom", "es5"],
"inlineSources": true,
"rootDir": "./src",
"mapRoot": "./",
"module": "es2015",
"moduleResolution": "node",
"outDir": "./dist",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"./node_modules/@types"
],
"paths": {
"@angular/core": ["./node_modules/@angular/core"]
}
},
"files": [
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true
}
}

14
src/package-lock.json generated
View file

@ -1,14 +0,0 @@
{
"name": "ng2-fittext",
"version": "1.2.10",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"dev": true
}
}
}

View file

@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",

View file

@ -1,36 +1,30 @@
{
"angularCompilerOptions": {
"strictMetadataEmit": true,
"skipTemplateCodegen": true
},
"compilerOptions": {
"baseUrl": "",
"declaration": true,
"stripInternal": true,
"strictNullChecks": true,
"noImplicitAny": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es2015", "dom", "es5"],
"inlineSources": true,
"rootDir": "./src",
"mapRoot": "./",
"module": "es2015",
"moduleResolution": "node",
"outDir": "./dist",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"./node_modules/@types"
],
"paths": {
"@angular/core": ["./node_modules/@angular/core"]
}
},
"files": [
"./src/index.ts"
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"awesomeTypescriptLoaderOptions": {
"forkChecker": true
}
"lib": [
"es2018",
"dom"
]
},
"files": [
"./src/polyfills.ts",
"./src/main.ts"
],
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}

View file

@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
@ -9,8 +9,8 @@
]
},
"files": [
"test.ts",
"polyfills.ts"
"./src/test.ts",
"./src/polyfills.ts"
],
"include": [
"**/*.spec.ts",

View file

@ -1,25 +1,32 @@
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"extends": "tslint:recommended",
"rules": {
"callable-types": true,
"class-name": true,
"comment-format": [
"array-type": false,
"arrow-parens": false,
"deprecation": {
"severity": "warning"
},
"component-class-suffix": true,
"contextual-lifecycle": true,
"directive-class-suffix": true,
"directive-selector": [
true,
"check-space"
"attribute",
"app",
"camelCase"
],
"curly": true,
"eofline": true,
"forin": true,
"import-blacklist": [true, "rxjs"],
"import-spacing": true,
"indent": [
"component-selector": [
true,
"spaces"
"element",
"app",
"kebab-case"
],
"interface-over-type-literal": true,
"label-position": true,
"import-blacklist": [
true,
"rxjs/Rx"
],
"interface-name": false,
"max-classes-per-file": false,
"max-line-length": [
true,
140
@ -27,11 +34,16 @@
"member-access": false,
"member-ordering": [
true,
"static-before-instance",
"variables-before-functions"
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-arg": true,
"no-bitwise": true,
"no-consecutive-blank-lines": false,
"no-console": [
true,
"debug",
@ -40,77 +52,40 @@
"timeEnd",
"trace"
],
"no-construct": true,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": false,
"no-empty-interface": true,
"no-eval": true,
"no-inferrable-types": true,
"no-shadowed-variable": true,
"no-string-literal": false,
"no-string-throw": true,
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"object-literal-sort-keys": false,
"one-line": [
"no-inferrable-types": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
"ignore-params"
],
"prefer-const": true,
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"object-literal-sort-keys": false,
"ordered-imports": false,
"quotemark": [
true,
"single"
],
"radix": true,
"semicolon": [
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"typeof-compare": true,
"unified-signatures": true,
"variable-name": false,
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"directive-selector": [true, "attribute", "", "camelCase"],
"component-selector": [true, "element", "", "kebab-case"],
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"trailing-comma": false,
"no-conflicting-lifecycle": true,
"no-host-metadata-property": true,
"no-input-rename": true,
"no-inputs-metadata-property": true,
"no-output-native": true,
"no-output-on-prefix": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true,
"no-access-missing-member": true,
"templates-use-public": true,
"invoke-injectable": true
}
"no-outputs-metadata-property": true,
"template-banana-in-box": true,
"template-no-negated-async": true,
"use-lifecycle-interface": true,
"use-pipe-transform-interface": true
},
"rulesDirectory": [
"codelyzer"
]
}