Giter VIP home page Giter VIP logo

ngletteravatar's Introduction

For the latest Angular, added ngletteravatar component to the ngu-utility, use ngu-utility for the latest angular2 or above versions

ng-letter-avatar Build Status

Gitter

AngularJS directive for simple data avatar like gmail/inbox. demo preview snaps :

demo demo demo demo demo demo demo demo demo demo

Quick start

bower install ngletteravatar or npm install ngletteravatar

or alternatively download and include ngletteravatar.js after angular.min.js. minified version ngletteravatar.min.js is under dist folder.

Add the ngLetterAvatar module as a dependency when creating your app, e.g.

var app = angular.module('myApp', ['ngLetterAvatar']);`

NO NEED TO INJECT in controller directly use in html.

Rendering

<p>
  <small>
     <ng-letter-avatar data="uttesh"></ng-letter-avatar>
  </small>
</p>

Option attirbutes

You can affect how letteravatar operates with the following settings:

name default description
avatarcustombgcolor No default value Using this attribute set the custom color for avatar background.
dynamic false Set this attribute to true if dynamically avatar needs to be generated on data change.
rotatedeg 0 Set this attribute required degrees of rotation of the avatar.
alphabetcolors default color set Using this attribute set the custom colors for the alphabets only.
charCount 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'
data Input data i.e. email, names...etc -OR- If image already exists for item, set image URL or image data
height 50px set the height for the avatar
width 50px set the width for the avatar
fontWeight 400 set the font weight for the avatar
fontSize 30px set the font size for the letter
shape square set the shape for the avatar. set 'round' for rounded avatars
fontFamily HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica, Arial,Lucida Grande, sans-serif set the font Family of the avatar.
avatarborder false set the avatarborder to 'true' for the white border to avatar.
avatarcustomborder no default value using this attribute set the custom style to avatar borders i.e "border:5px solid black".

Contributions

For problems/suggestions please create an issue on Github.

Contributors

License

The MIT License

Copyright (c) 2015 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.

ngletteravatar's People

Contributors

gitter-badger avatar uttesh avatar uttesh-rivet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ngletteravatar's Issues

First Name and last name...

Hi i made a change in the library....
/**

var l=r.data.replace(/[^A-Z]/g, '').toUpperCase()

**/

to get first name and last name its working fine for me..please let me know its fine to use like this.

Requirements for Ionic

Hi, this module is a perfect fit for Ionic. After small changes I'm using it in one my project and it works like a charm. But there are two small complains that can be solved in about 5 LOCs.

  • First obvious change is the use of jQuery. I know you are using this with Bootstrap but once you change all the $ for angular.element all the code is no more dependent on jQuery.
  • Ionic uses avatars, but expects just plain <img>'s without all the wrappers. Thus the very end of the link function to be changed to mimic the deprecated (?) replace:true directive behavior. Simply

    <ng-letter-avatar data="Zimbra"></ng-letter-avatar>
    should compile just into

    <img src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDo..." style="">

Any of those changes should not harm your project, but Im not aware of the whole context. Do you want me to PR my changes or I should just fork into a ngletteravatar for Ionic?

Option when we have an picture

Hi!

Your library is really great! But do you have a option when the user, for example, has a profile pricture?

Like Gmail, when don't have picture, put the LETTER, but when have, put the PICTURE.

The idea is use the same configuration for both cases, and don't generate a new code when we have a picture.

Colors are not being applied to alphabets

I am using the below code to have the colors for the alphabets.

<ng-letter-avatar class="pic" height="45" width="45" alphabetcolors="customColors" data="{{rangoli.userId.displayname}}" charCount="2" shape="round"></ng-letter-avatar>

But the colors are always the default one. Anything wrong here?

The color codes are below:

  $scope.customColors = ["#D93A37", "#5A8770", "#5A8770", "#5A8770", "#5A8770", "#5A8770", "#5A8770", "#5A8770", "#5C9BBC", "#F5888D",
    "#9A89B5", "#407887", "#9A89B5", "#5A8770", "#D33F33", "#A2B01F", "#F0B126", "#0087BF", "#F18636", "#0087BF", "#B2B7BB", "#72ACAE",
    "#9C8AB4", "#5A8770", "#EEB424", "#407887"
  ];

Additional naming cases

Hi I think your directive is really helpful.
However, I had some requirements in terms of how it would behave for example I wanted different display for different naming type:

  • uttesh Ranjit UR
  • Aidan Vandier Sat ==> AV
  • Gael Magma Do Borneo ==> GM
  • Adrian Di Bisumbio ==> AB
  • Antoine ==> AN
  • Antoine Kouroki ==> AK
  • Adrien Kou ==> AK
    for that I built and tested this function:
function determineCharacterNumbers(isMultiple, avatarData, charCount){
            var words = [],
                valReturn = null;
            if(!isMultiple){
                valReturn = avatarData.substr(0, charCount).toUpperCase();
            }
            else{
                words = avatarData.split(" ");
                for (var i = 0; i < words.length; i++) {
                    if(words.length >= 2){
                        // we pop particle names "De", "Of", "The", "Van" etc...
                        if((i != 0) && ( words[i].length === 2 || words[i].length === 3)){
                            if(i != words.length - 1){
                                words.splice(i,1);
                            }
                        }
                        words[i] = words[i].substr(0,1).toUpperCase();
                    }
                };
                // we add something like ['A', 'V'] that becomes AV
                valReturn = words.join('').substr(0, charCount).toUpperCase();
            }
            return valReturn;
        }

// and in the link function
var c = determineCharacterNumbers(params.multiWord, params.data, params.charCount);

The code might not be the most efficient but it does the job, if you are okay with it I was wondering if it could be added to your directive?

Adding Border

Hey,

I'm trying to add border, but it shows only top and left
Can you assist, please?

}).css({
                                        'background-color': color,
                                        'width': width+'px',
                                        'height': height+'px',
                                        'border' : 'solid 5px',
                                        'border-bottom-style': 'dotted'
 });

screen shot 2015-06-23 at 19 57 16

couldn't change font family

Am using rooney sans font from the adobe typekit ,when i tried to give that in the fontFamily attribute it doesn't took it.

Convert to pictures

Hello,

Is there easy way to convert to pictures those nice generated letters?
I'm thinking about print-screening square ones, but that's too bad approach..

Thanks!

upd: Basically a can do save as letters as svg vector image with transparent background, and then add appropriate background in image editor, which sounds like better approach. Not sure saving can be done with background image color..

New version JS

Hi,

Could you create a version JS only? Like foe people who dont use angular. Please :)

Change textColor

Right now its not possible to change the color of the text but I found the solution, the line 51 in the ngletteravatar.js should be replaced by:
textColor: attrs.textcolor || defaultSettings.textcolor,
so it takes the color we send correctly.

ng data binding

Hi Uttesh,

The following line works fine, where post.name is a $scope variable.

However, if I replace the $scope variable with a $scope function, it doesn't work.

Is it a bug or limitation? Anyway I can tweak to achieve the second method?

Thank you,
Sem

Missing letter

You seem to have left out the letter "G" (at least in the demo images).

Border radius should be in percent?

I suggest changing the default setting for the border-radius to: 'border-radius:50%;'. This way it will always be a completly round shape.

The way it is now, it renders as squares with rounded corners when the size gets bigger (ie 120x120).

v4.0.4 is missing dist/ngletteravatar.min.js file

Hello,

The title says it all. While using the following in a package.json: ~4.0.1

the last time I did a bower install (today 13/07/2016) our application was broken since the min.js script couldn't be found since there is no dist directory.

Hopefully you can correct this before our client does their bower install :o/

Update NPM version

Hello,

Could you publish the latest version (4.0.2) on npm repo?
I'm getting the version 4.0.0 as the most recent.

Thank you!

Custom css like padding, margin won't work and dynamic="true" break everything

If i apply custom simple css, its not work.

<ng-letter-avatar data="uttesh" style="margin-left: 48%"></ng-letter-avatar>

Width property don't take % only px

<ng-letter-avatar data="uttesh" width="100%"></ng-letter-avatar>

dynamic="true" works but ignore or break parent css. Some time shape round is not work when dynamic="true".

Its very nice avatar. Thaks and please update.

Avatar is disappeared when using ui-router states

I am using ui-router and in state A I have an avatar (code below). Whenever I navigate through different states I see that I lose the avatar.

<ng-letter-avatar data="{{vm.user.username}}" shape="round" dynamic="true" fontsize="60" width="100" height="100"></ng-letter-avatar>

Is there a way to reload the avatar ?

Data element not working inside a modal view

Hi,
I am trying to achieve it inside a modal view but its not working.
The data attribute is not taking the scope value.
Its working under normal view

<ion-modal-view>
     <ion-header-bar class="bar bar-header">
          <h1 class="title">Employee Details</h1>
          <button class="button button-clear button-primary" ng-click="modal.hide()">Cancel</button>
        </ion-header-bar>
    <ion-content has-header="true" padding="true">
        <div class="list card">
              <div class="item item-avatar">
                <ng-letter-avatar charCount="2" fontSize = "25px" avatarborder="true" avatarcustombgcolor="green" data={{employee.fullName}} shape="round"></ng-letter-avatar>
                <div class = "empname">{{employee.firstName}} {{employee.lastName}}</div>
                <p>{{employee.title}}</p>
            </div>
            <a class="item item-icon-left" href="#/employees/{{employee.managerId}}" ng-if="employee.managerId > -1"><i class="icon ion-ios7-person"></i>View Manager<p>{{employee.managerName}}</p></a>
            <a class="item item-icon-left" href="#/employees/{{employee.id}}/reports" ng-if="employee.reports > 0"><i class="icon ion-person-stalker"></i>View Direct Reports<p>{{employee.reports}}</p></a>
            <a class="item item-icon-left" href="tel:{{employee.officePhone}}"><i class="icon ion-ios7-telephone"></i>Call Office<p>{{employee.officePhone}}</p></a>
            <a class="item item-icon-left" href="tel:{{employee.cellPhone}}"><i class="icon ion-ios7-telephone"></i>Call Cell<p>{{employee.cellPhone}}</p></a>
            <a class="item item-icon-left" href="sms:{{employee.cellPhone}}"><i class="icon ion-chatbox-working"></i>SMS<p>{{employee.cellPhone}}</p></a>
            <a class="item item-icon-left" href="mailto:{{employee.email}}"><i class="icon ion-ios7-email"></i>Email<p>{{employee.email}}</p></a>
        </div>

    </ion-content>
</ion-modal-view>

G

Looks like G letter is missing ;-)

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.