├── .gitignore
├── README.md
├── babel.config.js
├── package.json
├── public
├── boringavatars.png
├── favicon.ico
└── index.html
├── rollup.config.js
├── src
├── assets
│ └── logo.png
├── components
│ ├── Avatar.vue
│ ├── AvatarBauhaus.vue
│ ├── AvatarBeam.vue
│ ├── AvatarMarble.vue
│ ├── AvatarPixels.vue
│ ├── AvatarRing.vue
│ └── AvatarSunset.vue
├── demo
│ ├── button.vue
│ ├── colorDot.vue
│ ├── global.css
│ └── playground.vue
├── index.js
├── main.js
└── utils.js
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue2-boring-avatars
2 |
3 | Vue port of [Boring Avatars](https://github.com/boringdesigners/boring-avatars)
4 |
5 | ## Install
6 |
7 | ```
8 | yarn add vue2-boring-avatars
9 | ```
10 | ```
11 | npm i vue2-boring-avatars
12 | ```
13 |
14 | ## Usage
15 | ```
16 | import Avatar from 'vue2-boring-avatars'
17 | ```
18 | ```
19 |
20 | ```
21 |
22 | ## Demo
23 | ```
24 | yarn serve
25 | ```
26 |
27 | ## Props
28 |
29 | | Prop | Type |
30 | | ------- | ------------------------------------------------------------ |
31 | | size | number or string |
32 | | name | string |
33 | | variant | oneOf: `marble`, `beam`, `pixels`,`sunset`, `ring`, `bauhaus` |
34 | | colors | array of colors |
35 | | square | bool |
36 |
37 | Credit to original [Boring Avatars](https://github.com/boringdesigners/boring-avatars) library.
38 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue2-boring-avatars",
3 | "description": "Vue2 port of boring avatars",
4 | "version": "0.3.6",
5 | "homepage": "https://github.com/stonega/vue2-boring-avatars",
6 | "license": "GPL v3",
7 | "scripts": {
8 | "serve": "vue-cli-service serve",
9 | "build": "vue-cli-service build",
10 | "build:lib": "rollup --config",
11 | "lint": "vue-cli-service lint"
12 | },
13 | "files": [
14 | "dist",
15 | "src"
16 | ],
17 | "main": "./dist/vue-2-boring-avatars.umd.js",
18 | "module": "./dist/vue-2-boring-avatars.es.js",
19 | "exports": {
20 | ".": {
21 | "import": "./dist/vue-2-boring-avatars.es.js",
22 | "require": "./dist/vue-2-boring-avatars.umd.js"
23 | }
24 | },
25 | "dependencies": {
26 | "core-js": "^3.6.5",
27 | "vue": "^2.6.11",
28 | "vue-color": "^2.8.1"
29 | },
30 | "devDependencies": {
31 | "@rollup/plugin-alias": "^3.1.9",
32 | "@rollup/plugin-commonjs": "^22.0.1",
33 | "@rollup/plugin-node-resolve": "^13.3.0",
34 | "@vue/cli-plugin-babel": "~4.5.0",
35 | "@vue/cli-plugin-eslint": "~4.5.0",
36 | "@vue/cli-service": "~4.5.0",
37 | "babel-eslint": "^10.1.0",
38 | "esbuild": "^0.14.47",
39 | "eslint": "^6.7.2",
40 | "eslint-plugin-vue": "^6.2.2",
41 | "rollup": "^2.75.7",
42 | "rollup-plugin-delete": "^2.0.0",
43 | "rollup-plugin-esbuild": "^4.9.1",
44 | "rollup-plugin-vue": "^5.0.0",
45 | "vue-template-compiler": "^2.6.11"
46 | },
47 | "eslintConfig": {
48 | "root": true,
49 | "env": {
50 | "node": true
51 | },
52 | "extends": [
53 | "plugin:vue/essential",
54 | "eslint:recommended"
55 | ],
56 | "parserOptions": {
57 | "parser": "babel-eslint"
58 | },
59 | "rules": {}
60 | },
61 | "browserslist": [
62 | "> 1%",
63 | "last 2 versions",
64 | "not dead"
65 | ],
66 | "repository": {
67 | "type": "git",
68 | "url": "git+https://github.com/stonega/vue2-boring-avatars.git"
69 | },
70 | "author": "",
71 | "bugs": {
72 | "url": "https://github.com/stonega/vue2-boring-avatars/issues"
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/public/boringavatars.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stonega/vue2-boring-avatars/26f2ed63e61504ae761d941da7db7a444442fa97/public/boringavatars.png
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stonega/vue2-boring-avatars/26f2ed63e61504ae761d941da7db7a444442fa97/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import vue from 'rollup-plugin-vue';
2 | import alias from '@rollup/plugin-alias';
3 | import del from 'rollup-plugin-delete';
4 | import commonjs from '@rollup/plugin-commonjs';
5 | import esbuild from 'rollup-plugin-esbuild';
6 | import resolve from '@rollup/plugin-node-resolve';
7 | import path from 'path';
8 |
9 | const plugins = [
10 | del({ targets: 'dist/*' }),
11 | alias({
12 | entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
13 | }),
14 | resolve(),
15 | commonjs(),
16 | vue(),
17 | esbuild({
18 | target: 'es2017',
19 | minify: true,
20 | }),
21 | ];
22 |
23 | export default [
24 | {
25 | input: 'src/index.js',
26 | output: [
27 | {
28 | name: 'vue-2-boring-avatars',
29 | file: 'dist/vue-2-boring-avatars.es.js',
30 | format: 'esm',
31 | globals: { vue: 'Vue' },
32 | sourcemap: true,
33 | },
34 | {
35 | name: 'vue-2-boring-avatars',
36 | file: 'dist/vue-2-boring-avatars.common.js',
37 | format: 'cjs',
38 | exports: 'auto',
39 | globals: { vue: 'Vue' },
40 | sourcemap: true,
41 | },
42 | {
43 | name: 'vue-2-boring-avatars',
44 | file: 'dist/vue-2-boring-avatars.umd.js',
45 | format: 'umd',
46 | globals: { vue: 'Vue' },
47 | sourcemap: true,
48 | },
49 | ],
50 | plugins,
51 | external: ['vue'],
52 | },
53 | ];
54 |
--------------------------------------------------------------------------------
/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stonega/vue2-boring-avatars/26f2ed63e61504ae761d941da7db7a444442fa97/src/assets/logo.png
--------------------------------------------------------------------------------
/src/components/Avatar.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
50 |
--------------------------------------------------------------------------------
/src/components/AvatarBauhaus.vue:
--------------------------------------------------------------------------------
1 |
2 |
64 |
65 |
--------------------------------------------------------------------------------
/src/components/AvatarBeam.vue:
--------------------------------------------------------------------------------
1 |
2 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/src/components/AvatarMarble.vue:
--------------------------------------------------------------------------------
1 |
2 |
65 |
66 |
67 |
101 |
--------------------------------------------------------------------------------
/src/components/AvatarPixels.vue:
--------------------------------------------------------------------------------
1 |
2 |
386 |
387 |
388 |
--------------------------------------------------------------------------------
/src/components/AvatarRing.vue:
--------------------------------------------------------------------------------
1 |
2 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/src/components/AvatarSunset.vue:
--------------------------------------------------------------------------------
1 |
2 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/demo/button.vue:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stonega/vue2-boring-avatars/26f2ed63e61504ae761d941da7db7a444442fa97/src/demo/button.vue
--------------------------------------------------------------------------------
/src/demo/colorDot.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | (showPicker = !showPicker)"
5 | class="color-dot"
6 | :style="{ backgroundColor: color }"
7 | >
8 |
9 | updateColor(value)"
13 | class="chrome-picker"
14 | />
15 |
16 |
17 |
18 |
19 |
41 |
42 |
--------------------------------------------------------------------------------
/src/demo/global.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/stonega/vue2-boring-avatars/26f2ed63e61504ae761d941da7db7a444442fa97/src/demo/global.css
--------------------------------------------------------------------------------
/src/demo/playground.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
28 |
29 |
30 |
31 |
{{ name }}
32 |
33 |
34 |
35 |
36 |
37 |
64 |
65 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import Avatar from "./components/Avatar.vue";
2 |
3 | export default Avatar;
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Playground from './demo/playground.vue'
3 |
4 | Vue.config.productionTip = false
5 |
6 | new Vue({
7 | render: h => h(Playground),
8 | }).$mount('#app')
9 |
--------------------------------------------------------------------------------
/src/utils.js:
--------------------------------------------------------------------------------
1 | export const getNumber = (name) => {
2 | const charactersArray = Array.from(name)
3 | return charactersArray.reduce((accu, curr) =>
4 | accu + curr.charCodeAt(0)
5 | , 0)
6 | }
7 |
8 | export const getModules = (num, max) => {
9 | return num * max
10 | }
11 |
12 | export const getDigit = (num, ntn) => {
13 | return Math.floor((num / Math.pow(10, ntn)) % 10)
14 | }
15 |
16 | export const getBoolean = (num, ntn) => {
17 | return (!(getDigit(num, ntn) % 2))
18 | }
19 |
20 | export const getAngle = (x, y) => {
21 | return Math.atan2(x, y) * 180 / Math.PI
22 | }
23 |
24 | export const getUnit = (num, range, index) => {
25 | let value = num % range
26 |
27 | if (index && ((getDigit(num, index) % 2) === 0)) {
28 | return -value
29 | }
30 | return value
31 | }
32 |
33 | export const getRandomColor = (num, colors, range) => {
34 | return colors[num % range]
35 | }
36 |
37 | export const getContrast = (hexColor) => {
38 | if (hexColor.slice(0, 1) === '#') {
39 | hexColor = hexColor.slice(1)
40 | }
41 |
42 | let r = parseInt(hexColor.substr(0, 2), 16)
43 | let g = parseInt(hexColor.substr(2, 2), 16)
44 | let b = parseInt(hexColor.substr(4, 2), 16)
45 |
46 | let yiq = ((r * 299) + (g * 587) + (b * 144)) / 1000
47 |
48 | return (yiq >= 128) ? 'black' : 'white'
49 | }
--------------------------------------------------------------------------------