-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathpredefinedColors.html
162 lines (152 loc) · 6.99 KB
/
predefinedColors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>jQuery LetterPic plugin</title>
<meta property="og:type" content="website" />
<meta property="og:title" content="jQuery LetterPic plugin" />
<meta property="og:description" content="LetterPic converts usernames into canvas based avatar pictures. " />
<meta property="og:url" content="https://goo.gl/tJAevN" />
<meta property="article:author" content="George Yakovlev" />
<meta property="og:image" content="https://raw.githubusercontent.com/yakovlevga/letterpic/master/resources/letterpic.png" />
<meta property="og:image:type" content="image/jpeg" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<style>
.letterpic {
width: 40px;
height: 40px;
border-radius: 20px;
}
main .letterpic {
width: 60px;
height: 60px;
border-radius: 30px;
}
</style>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/jquery.letterpic.js"></script>
<script>
$(function() {
$(".letterpic").letterpic({
fill: 'color',
initial: {
color: {
"A" : "red",
"B" : "blue",
"M" : "green",
}
}
});
});
</script>
</head>
<body>
<nav class="navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Letterpic</a>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<div title="Mike Green" data-letterpic-key="M" class="letterpic"></div>
</form>
</div>
</nav>
<main class="container" style="margin-top: 100px;">
<div class="jumbotron">
<div class="row">
<div class="col-md-12">
<pre><code>
JS:
$(".letterpic").letterpic({
fill: 'color',
initial: {
color: {
"A" : "red",
"B" : "blue",
"M" : "green",
}
}
});
HTML:
<div class="letterpic" title="Mike Green" data-letterpic-key="M"></div>
</code></pre>
Now you can define attribute <code>data-letterpic-key</code> to manualy set color dictionary value of user.<br/>
By default this key is equals to users initials from <code>title</code> attribute.<br/>
Also you can pass <code>maxInitialsLength</code> as parameter of $.letterpic, to define max length of initals string on avatar,<br/>
by default it's value is 2.
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="media">
<div class="letterpic mr-2" title="Mike Green" data-letterpic-key="M"></div>
<div class="media-body">
<h5 class="mt-0">Mike Green</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
</div>
</div>
</div>
<div class="col-md-4">
<div class="media">
<div class="letterpic mr-2" title="Mike Green" data-letterpic-key="M"></div>
<div class="media-body">
<h5 class="mt-0">Mike Patton</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
</div>
</div>
</div>
<div class="col-md-4">
<div class="media">
<div class="letterpic mr-2" title="Andrew Red" data-letterpic-key="A"></div>
<div class="media-body">
<h5 class="mt-0">Andrew Red</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
</div>
</div>
</div>
</div>
<div class="row mt-4 mb-4">
<div class="col-md-4">
<div class="media">
<div class="letterpic mr-2" title="Andy" data-letterpic-key="A"></div>
<div class="media-body">
<h5 class="mt-0">Andy</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
</div>
</div>
</div>
<div class="col-md-4">
<div class="media">
<div class="letterpic mr-2" title="Bob" data-letterpic-key="B"></div>
<div class="media-body">
<h5 class="mt-0">Bob</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin.
</div>
</div>
</div>
<div class="col-md-4">
<div class="media">
<div class="letterpic mr-2" title="Jhon Doe"></div>
<div class="media-body">
<h5 class="mt-0">Jhon Doe</h5>
This letterpic doesn't have <code>data-letterpic-key</code>.
It's key generated from title => JD. We didn't pass 'JD' to initial colors,<br/>
it will get it from default colors or from colors array passed on $.letterpic.
</div>
</div>
</div>
</div>
</main>
</body>
</html>