Giter Site home page Giter Site logo

uttesh / ngu-utility Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 6.0 133 KB

The utility components,service,directives and pipes for Angular.

Home Page: https://github.com/uttesh/ngu-utility

License: MIT License

JavaScript 15.11% TypeScript 84.89%
angular angular2 angular4 angular-components angular-directives

ngu-utility's Introduction

Utility for Angular

The utility components,service,directives and pipes for Angular.

Quick Start

npm install ngu-utility --save

Angular Version

This module library is built to work with Angular 2.3.0+, and support ahead-of-time compilation.

Module Format

This library ships as a "flat ES module" (FESM). This means that all the JavaScript code is located in a single ES5-compatible file, but makes use of ES2015 import and export statements.

Webpack, Systemjs and Rollup all support this format and should work without problems.

A UMD bundle is also provided for systems which do not support FESM.

Simple Example

// app.module.ts
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {NguUtilityModule} from "ngu-utility/dist"; // <-- import the module

@NgModule({
  declarations: [
  
  ],
  imports: [
  
   NguUtilityModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})

1. Letter Avatar Component

letter avatar component, letter avatar for the given string. Like gmail or google inbox text avatar i.e. First letter of the given data will be the avatar

<ngu-letter-avatar avatar-data='{{title}}' ></ngu-letter-avatar> </h4>

Option attirbutes

You can affect how letteravatar operates with the following settings:

attribute name default description
avatar-custom-bg-color No default value Using this attribute set the custom color for avatar background.
avatar-dynamic false Set this attribute to true if dynamically avatar needs to be generated on data change.
avatar-rotate-degree 0 Set this attribute required degrees of rotation of the avatar.
avatar-alphabet-colors default color set Using this attribute set the custom colors for the alphabets only.
avatar-char-count 1 Specifies the number of letters to displayed. to generate combined letter avatar of first name and last name which are separated by space then set the value to '2'
avatar-data Input data i.e. email, names...etc -OR- If image already exists for item, set image URL or image data
avatar-height 50px set the height for the avatar
avatar-width 50px set the width for the avatar
avatar-font-weight 400 set the font weight for the avatar
avatar-font-size 30px set the font size for the letter
avatar-shape square set the shape for the avatar. set 'round' for rounded avatars
avatar-font-family HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica, Arial,Lucida Grande, sans-serif set the font Family of the avatar.
avatar-border false set the avatarborder to 'true' for the white border to avatar.
avatar-custom-border no default value using this attribute set the custom style to avatar borders i.e "border:5px solid black".

preview snaps :

demo demo demo demo demo demo demo demo demo demo

Building from source

Requires globally-installed node (tested with v5.x) & npm.

npm install
npm run build 

Contributions

For problems/suggestions please create an issue on Github.

Contributors

License

The MIT License

Copyright (c) 2017 Uttesh Kumar T.H. http://www.uttesh.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ngu-utility's People

Contributors

uttesh avatar uttesh-rivet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ngu-utility's Issues

Unexpected value 'NguUtilityModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

I'm pretty new to Angular so I may be doing something stupid. I have an existing working project that uses Materials and I'm now trying to add Letter Avatars to a component. I have imported NguUtilityModule in app.module.ts but getting the following error. I got few warning when I installed this component.

Error in browser:
Uncaught Error: Unexpected value 'NguUtilityModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

Compile Warnings:
WARNING in ./node_modules/ngu-utility/node_modules/@angular/core/esm5/core.js
6581:15-36 Critical dependency: the request of a dependency is an expression
at ImportLazyContextDependency.getWarnings (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/dependencies/ContextDependency.js:39:18)
at Compilation.reportDependencyErrorsAndWarnings (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/Compilation.js:701:24)
at Compilation.finish (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/Compilation.js:559:9)
at applyPluginsParallel.err (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/Compiler.js:506:17)
at /Users/aravind/Projects/ang-material/node_modules/tapable/lib/Tapable.js:289:11
at /Users/aravind/Projects/ang-material/node_modules/html-webpack-plugin/index.js:60:9
at tryCatcher (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)

WARNING in ./node_modules/ngu-utility/node_modules/@angular/core/esm5/core.js
6601:15-102 Critical dependency: the request of a dependency is an expression
at ImportLazyContextDependency.getWarnings (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/dependencies/ContextDependency.js:39:18)
at Compilation.reportDependencyErrorsAndWarnings (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/Compilation.js:701:24)
at Compilation.finish (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/Compilation.js:559:9)
at applyPluginsParallel.err (/Users/aravind/Projects/ang-material/node_modules/webpack/lib/Compiler.js:506:17)
at /Users/aravind/Projects/ang-material/node_modules/tapable/lib/Tapable.js:289:11
at /Users/aravind/Projects/ang-material/node_modules/html-webpack-plugin/index.js:60:9
at tryCatcher (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Users/aravind/Projects/ang-material/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)

Warnings in command prompt when I installed:
npm WARN @schematics/[email protected] requires a peer of @angular-devkit/[email protected] but none was installed.
npm WARN @angular/[email protected] requires a peer of typescript@>=2.4.2 <2.6 but none was installed.
npm WARN [email protected] requires a peer of typescript@>=2.4.2 <2.6 but none was installed.

Error during template compile of 'NguUtilityModule'

I'm getting this error when running ng build --prod

ERROR in ../ngu-utility/dist/ngu-utility.module.ts(6,2): Error during template compile of 'NguUtilityModule'
Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'NgModule'
'NgModule' calls 'ɵmakeDecorator'.

Can't build in Angular 5

ERROR in ./node_modules/ngu-utility/ngu-utility.module.ts
Module build failed: Error: D:\project\app-ng5\node_modules\ngu-utility\ngu-utility.module.ts is not part of the compilation output. Please check the other error messages for detail

AOT build does not include metadata or type definitions

I tried to use your lib in my project and I noticed a few issues in your build process.

In your documentation, you suggest that people import the typescript module file directly, which defeats the point of AOT compilation. For instance, we happen to have more severe compilation options in our project so importing the typescript module will cause our build to fail. Instead, people should always import your compiled files. Unfortunately, you are missing typescript definitions (*.d.ts) and ngc metadata files in your dist folder for this to work.

As far as I know, this should be an easy fix; simply changing a few configs in the build process.

Dynamic parameter not working

I'm trying to dynamically update the user profile image but even with the avatar-dynamic="true" parameter it does not work.

My code looks something like this:

<a id="avatar" *ngIf="userProfile$ | async as profile">
    <ngu-letter-avatar [avatar-dynamic]="true" [avatar-data]="profile.image || profile.name || profile.email" [avatar-custom-bg-color]="avatarColor" [avatar-font-family]="'sans-serif'" [avatar-font-size]="25" avatar-shape="round" avatar-width="35" avatar-height="35" [matMenuTriggerFor]="profilePanel"></ngu-letter-avatar>
</a>

Tried with only one parameter as data, but got the same result.

Error on --prod build.

I'm using the latest version of ngu-utility and the latest angular and angular-cli. But I'm getting the following error even on a vanilla generated project...

ng build --aot
or
ng build --prod

ERROR in ..\ngu-utility\dist\ngu-utility.module.ts(8,20): Error during template compile of 'NguUtilityModule'
Could not resolve ./letter-avatar/ngu-letter-avatar.component relative to C:/Projects/myfolders/node_modules/ngu-utility/dist/ngu-utility.module.d.ts..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.