├── .bowerrc ├── .gitignore ├── README.md ├── bower.json ├── build ├── repo-card.js └── themes │ └── doodle │ ├── index.html │ └── style.css ├── examples └── index.html ├── gulpfile.js ├── package.json ├── repo-card.js └── repo-card.min.js /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "lib/" 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .DS_Store 3 | node_modules 4 | lib/ 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Repo Card 2 | =========================================================================== 3 | 4 | Give your repos some freshness with a Repo Card. 5 | 6 | I often get lazy adding a profile to my repositories, especially when I'd like for them to get forked, starred, etc. 7 | If you've been there, then Repo Cards are for you. 8 | 9 | ## Demo 10 | 11 | Here's one of my own repos with one: 2048 Cube 12 | 13 | 2048 Cube 14 | 15 | ## Usage 16 | 17 | You can add a repo card in many different ways. Choose one that's easiest for you: 18 | 19 | Reference the script file via the CDN (not fast, yet) 20 | ```javascript 21 | 22 | ``` 23 | 24 | Install via Bower 25 | ```bash 26 | $ bower install repo-card --save 27 | ``` 28 | 29 | Install via NPM 30 | ```bash 31 | $ npm install repo-card --save 32 | ``` 33 | 34 | Then, you simply configure the Repo card with your info 35 | ```javascript 36 | // Once sourced from either a CDN or locally, you use the data-attributes to configure the repo card 37 | 42 | ``` 43 | 44 | Or, you configure it within your app as seen in the `script` tag below 45 | ```javascript 46 | 47 | 61 | ``` 62 | 63 | ## Options 64 | 65 | Here are some options that you can set within the `data-attrbutes` (e.g. `data-info="some information`) or in your app. 66 | 67 | - `repo`: The name of the repo 68 | - `theme`: There's only one theme right now (`doodle`), however, I'd love more themes. Check out the `themes` folder or reach out if you'd like assistance in contributing 69 | - `username`: Your Github username 70 | - `title`: A title for the repo card 71 | - `subtitle`: A subtitle for the repo card 72 | - `info`: Some information you'd like to include about your project 73 | - `background`: Set the background (it accepts CSS, so HEX, RGB or even an image, `url(...)`, works 74 | - `thumb`: Set the thumbnail (it accepts CSS, so HEX, RGB or even an image, `url(...)`, works 75 | - `position`: The card is currently set to `fixed` position, so you can change its position (e.g. `position: { bottom: 15, left: 15 }` 76 | 77 | 78 | ## Coming 79 | 80 | - More themes (would love your help on this) 81 | - GUI dashboard for configuring the Repo Card 82 | - Animations to have the repo card hide away with interactions (e.g. `scroll`) 83 | - NPM, Browserify, Webpack, etc. builds? 84 | 85 | 86 | ## Questions 87 | 88 | Please use the issues page with any questions/concerns. If you like this idea and find it useful, please share the project as I'd love the help :) -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "repo-card", 3 | "description": "Give your projects a fresh look with a Repo Card", 4 | "version": "0.0.9", 5 | "main": "repo-card.min.js", 6 | "authors": [ 7 | "Farhad Ghayour " 8 | ], 9 | "license": "MIT", 10 | "keywords": [ 11 | "id", 12 | "repo", 13 | "repo card", 14 | "profile", 15 | "github stars", 16 | "github followers", 17 | "github forks", 18 | "github buttons", 19 | "github ribbon" 20 | ], 21 | "moduleType": [], 22 | "homepage": "https://www.github.com/farhadg/repo-card", 23 | "ignore": [ 24 | "**/.*", 25 | "node_modules", 26 | "bower_components", 27 | "lib", 28 | "test", 29 | "tests", 30 | "examples" 31 | ], 32 | "dependencies": { 33 | "script-tag-data": "~0.0.6" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /build/repo-card.js: -------------------------------------------------------------------------------- 1 | var ScriptTagData = require('exports?ScriptTagData!../lib/script-tag-data/script-tag-data.min.js'); 2 | 3 | /** 4 | * RepoCard constructor 5 | * 6 | * @returns {*} 7 | * @constructor 8 | */ 9 | 10 | function RepoCard() { 11 | if (!(this instanceof RepoCard)) { 12 | return new RepoCard(); 13 | } 14 | var params = ScriptTagData.getData('repo-card-lib', true); 15 | if (params && Object.keys(params).length > 2) { 16 | this.configure(params); 17 | } 18 | } 19 | 20 | // various themes 21 | 22 | RepoCard.themes = { 23 | doodle: { 24 | template: '@@import doodle/index.html', 25 | style: '@@import doodle/style.css', 26 | selectors: { 27 | background: 'repo-card__image-wrap', 28 | thumb: 'repo-card__thumb' 29 | } 30 | } 31 | }; 32 | 33 | // Helper for setting a dom element's content 34 | 35 | function _setContent(selector, data) { 36 | document.getElementById(selector).innerText = data; 37 | } 38 | 39 | // Helper for setting a dom element's style 40 | 41 | function _setBackground(selector, value) { 42 | var el = document.getElementById(selector); 43 | el.style.background = value; 44 | } 45 | 46 | // Helper for setting the repo card's position 47 | 48 | function _setPosition(values) { 49 | var el = document.getElementById('repo-card-container').style; 50 | el.position = 'fixed'; 51 | el.top = el.right = el.bottom = el.left = 'initial'; 52 | for (var position in values) { 53 | el[position] = values[position]+'px'; 54 | } 55 | } 56 | 57 | // generates the github star button for a given user and repo 58 | 59 | function _generateGithubButton(username, repo, type) { 60 | return [ 61 | '
  • ' 64 | ].join(''); 65 | } 66 | 67 | // generates the github follow button for a given user 68 | 69 | function _generateFollowButton(username) { 70 | return [ 71 | '
  • ' 74 | ].join(''); 75 | } 76 | 77 | // generates and adds the desired buttons into the dom 78 | 79 | function _generateSocialButtons(params) { 80 | var buttons = []; 81 | if (params.stars !== false) { 82 | buttons.push(_generateGithubButton(params.username, params.repo, 'star')); 83 | } 84 | if (params.fork !== false) { 85 | buttons.push(_generateGithubButton(params.username, params.repo, 'fork')); 86 | } 87 | if (params.follow !== false) { 88 | buttons.push(_generateFollowButton(params.username)); 89 | } 90 | return buttons.join(''); 91 | } 92 | 93 | // generates the styling within a