Skip to content

Commit

Permalink
github-button doc & reafactoring api #47
Browse files Browse the repository at this point in the history
  • Loading branch information
voischev committed Nov 19, 2014
1 parent f1e155b commit 550a19c
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ block('github-button').mod('type', 'download')(
var mods = this.ctx.mods;
var user = this.ctx.user;
var repo = this.ctx.repo;
var isLarge = mods.size === 'l';

return this.extend(applyNext(), {
href : 'https://github.com/' + user + '/' + repo + '/archive/master.zip',
'data-style' : mods.large && 'mega',
'data-style' : isLarge && 'mega',
'data-icon' : 'octicon-cloud-download'
});
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ block('github-button').mod('type', 'follow')(
attrs()(function() {
var mods = this.ctx.mods;
var user = this.ctx.user;
var isLarge = mods.size === 'l';

return this.extend(applyNext(), {
href : 'https://github.com/' + user,
'data-style' : mods.large && 'mega',
'data-style' : isLarge && 'mega',
'data-count-href' : mods.count && ('/' + user + '/followers'),
'data-count-api' : mods.count && ('/users/' + user + '#followers')
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ block('github-button').mod('type', 'fork')(
var mods = this.ctx.mods;
var user = this.ctx.user;
var repo = this.ctx.repo;
var isLarge = mods.size === 'l';

return this.extend(applyNext(), {
href : 'https://github.com/' + user + '/' + repo,
'data-style' : mods.large && 'mega',
'data-style' : isLarge && 'mega',
'data-count-href' : mods.count && ('/' + user + '/' + repo + '/network'),
'data-count-api' : mods.count && ('/repos/' + user + '/' + repo + '#forks_count'),
'data-icon' : 'octicon-git-branch'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ block('github-button').mod('type', 'issue')(
var mods = this.ctx.mods;
var user = this.ctx.user;
var repo = this.ctx.repo;
var isLarge = mods.size === 'l';

return this.extend(applyNext(), {
href : 'https://github.com/' + user + '/' + repo + '/issues',
'data-style' : mods.large && 'mega',
'data-style' : isLarge && 'mega',
'data-count-api' : mods.count && ('/repos/' + user + '/' + repo + '#open_issues_count'),
'data-icon' : 'octicon-issue-opened'
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ block('github-button').mod('type', 'star')(
var mods = this.ctx.mods;
var user = this.ctx.user;
var repo = this.ctx.repo;
var isLarge = mods.size === 'l';

return this.extend(applyNext(), {
href : 'https://github.com/' + user + '/' + repo,
'data-style' : mods.large && 'mega',
'data-style' : isLarge && 'mega',
'data-count-href' : mods.count && ('/' + user + '/' + repo + '/stargazers'),
'data-count-api' : mods.count && ('/repos/' + user + '/' + repo + '#stargazers_count'),
'data-icon' : 'octicon-star'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ block('github-button').mod('type', 'watch')(
var mods = this.ctx.mods;
var user = this.ctx.user;
var repo = this.ctx.repo;
var isLarge = mods.size === 'l';

return this.extend(applyNext(), {
href : 'https://github.com/' + user + '/' + repo,
'data-style' : mods.large && 'mega',
'data-style' : isLarge && 'mega',
'data-count-href' : mods.count && ('/' + user + '/' + repo + '/watchers'),
'data-count-api' : mods.count && ('/repos/' + user + '/' + repo + '#subscribers_count'),
'data-icon' : 'octicon-eye'
Expand Down
65 changes: 65 additions & 0 deletions common.blocks/github-button/github-button.ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# github-button

Блок `github-button` используется для подключения GitHub:Buttons на страницы.
Не работает без модификаторов.

## Использование
```js
{
block : 'github-button',
mods : { type : 'star', size : 'l', count : true },
user : 'voischev',
repo : 'bem-social'
}
```

## Модификаторы `type`

- `download`
- `follow`
- `fork`
- `issue`
- `star`
- `watch`

## Модификатор `size`

- Большая кнопка со значением 'l'

## Модификатор `count`

Что бы отобразить счетчик нужно установть в значение `true`.
Доступен для типов кнопоу к кроторых возможен счетчик.

- `follow`
- `fork`
- `issue`
- `star`
- `watch`


## Специализированные поля блока

Список зарезервированных полей входного BEMJSON:

<table>
<tr>
<th>Поле</th>
<th>Тип</th>
<th>Описание</th>
</tr>
<tr>
<td>user</td>
<td>
<code>String</code>
</td>
<td>Пользователь на GitHub</td>
</tr>
<tr>
<td>repo</td>
<td>
<code>String</code>
</td>
<td>Репозиторий на GitHub. Для типа `follow` неуказывается</td>
</tr>
</table>
12 changes: 6 additions & 6 deletions desktop.bundles/index/index.bemjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
content : [
{
block : 'github-button',
mods : { type : 'star', large : true, count : true },
mods : { type : 'star', size : 'l', count : true },
user : 'voischev',
repo : 'bem-social'
}
Expand All @@ -58,7 +58,7 @@
content : [
{
block : 'github-button',
mods : { type : 'follow', large : true, count : true },
mods : { type : 'follow', size : 'l', count : true },
user : 'voischev'
}
]
Expand All @@ -79,7 +79,7 @@
content : [
{
block : 'github-button',
mods : { type : 'watch', large : true, count : true },
mods : { type : 'watch', size : 'l', count : true },
user : 'voischev',
repo : 'bem-social'
}
Expand All @@ -91,7 +91,7 @@
content : [
{
block : 'github-button',
mods : { type : 'issue', large : true, count : true },
mods : { type : 'issue', size : 'l', count : true },
user : 'voischev',
repo : 'bem-social'
}
Expand All @@ -103,7 +103,7 @@
content : [
{
block : 'github-button',
mods : { type : 'fork', large : true, count : true },
mods : { type : 'fork', size : 'l', count : true },
user : 'voischev',
repo : 'bem-social'
}
Expand All @@ -115,7 +115,7 @@
content : [
{
block : 'github-button',
mods : { type : 'download', large : true },
mods : { type : 'download', size : 'l' },
user : 'voischev',
repo : 'bem-social'
}
Expand Down

0 comments on commit 550a19c

Please sign in to comment.