uttesh / ngletteravatar

directive for the letter avatar for the given string like gmail, first letter of the given data will be the avatar .
http://uttesh.github.io/ngletteravatar/
MIT License
136 stars 36 forks source link

Added box-color and color-func for specifying colors #15

Closed richardfriedman closed 8 years ago

richardfriedman commented 8 years ago

Great plugin for angular. I needed to further customize the color of the surrounding area. Added two new options

box-color - this is just a hard specification of the color. For example for stripe type coloring in a list.

<ng-letter-avatar box-color="{{::myColor($index)}}" 

color-func - To support customizing the color based on my applications color theme

<ng-letter-avatar box-color="myColor" 

and in my controller

$scope.myColor = function( text ) { 
   // text is the string that letter avatar would use to decide color.  can use any logic here to return string.
   return '#231212';
}

I understand alphabet colors supports this but in my case it here were numbers or cases where the first two or three letters defined the color selection.

richardfriedman commented 8 years ago

Also I created a package.json for dev dependencies to build (ie the gulp requirements). As well as .gitignore

sebfie commented 8 years ago

Hello, I also need this feature to specify a color, any update?

uttesh commented 8 years ago

@sebfie Thanks for the input, directive is already having custom color for alphabets, use "alphabetcolors" attribute to provide the custom color set according to required themes of application.

sebfie commented 8 years ago

In my app i manage teams (developer, sales...). Each team has a color.

Sébastien fieloux 0698458781 sebastien.fieloux@gmail.com http://www.sebfie.com

Le 14 avr. 2016 à 16:55, uttesh notifications@github.com a écrit :

@sebfie Thanks for the input, directive is already having custom color for alphabets, use "alphabetcolors" attribute to provide the custom color set according to required themes of application.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

uttesh commented 8 years ago

@sebfie could you please elaborate, that will help me understand the requirement. are you referring the square/circle border color?

sebfie commented 8 years ago

On my left navigation bar, I list all teams of my company :

I want an ng-letter-avatar for each of this team with always the same color. I also use this directive for my users. So :

uttesh commented 8 years ago

@sebfie

Ok I guess 'alphabetcolors' attribute will do that. i.e.

Create a custom colors list, it's for only alphabets colors i.e. a-z list should have 26 colors

Sample:

In Controller: $scope.customAlphabetColors = ["#D93A37", "#5A8770", .....];

In Html: <ng-letter-avatar data="Development" alphabetcolors="customAlphabetColors" ></ng-letter-avatar>

hope this will help.

sebfie commented 8 years ago

So, I have to specify 26 times the same color? Because my team name can change but not its color.

uttesh commented 8 years ago

Custom list is for the full alphabet set colors i.e. starts from a to z 26 letters, each index in a list will represent a color for that alphabet.

$scope.customAlphabetColors = ["#D93A37", "#5A8770", .....];

'a' will get '#D93A37' color, b -> #5A8770....continues

there are two colors in letter avatar background color and border color. which color are you referring?

sebfie commented 8 years ago

Why are you so opposed to add this feature? If I want a color for a specific user, why not? In my case, I want colors depending of items in my database and not alphabet.

uttesh commented 8 years ago

@sebfie Sorry i'm not getting what exactly your trying to say. @richardfriedman suggestion for the custom background color of letter avatar which already exist in the library but for the specific user level it's in todo list and it is open source library open for any changes/add new features and suggestions

uttesh commented 8 years ago

@richardfriedman thanks for the suggestion and support.