Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ As such, for today's unofficial Watch button, **you must add `v=2` to the parame
{% endcapture %}
{% include example.html content=example %}

## No text variant

{% capture example %}
<iframe src="{{ site.url }}/github-btn.html?user=twbs&repo=bootstrap&type=star&size=large&text=false" frameborder="0" scrolling="0" width="170" height="30" title="GitHub"></iframe>
{% endcapture %}
{% include example.html content=example %}

---

## Available options
Expand All @@ -85,6 +92,7 @@ The following URL parameters are **not** required. Add them as you wish.
| ------ | :---------- |
| `count` | Show the optional watchers or forks count: *none* by default or `true` |
| `size` | Optional flag for using a larger button: *none* by default or `large` |
| `text` | Optional flag for hiding the text: *none* by default or `false` |

---

Expand Down
10 changes: 9 additions & 1 deletion src/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
var count = parameters.count;
var size = parameters.size;
var v = parameters.v;
var noText = parameters.text;

// Elements
var button = document.querySelector('.gh-btn');
Expand Down Expand Up @@ -155,6 +156,13 @@
}
}

if (noText === 'false') {
button.className += ' no-text';
text.setAttribute('aria-hidden', true);
text.style.display = 'none';
text.textContent = '';
}

button.setAttribute('aria-label', title + LABEL_SUFFIX);
document.title = title + LABEL_SUFFIX;

Expand All @@ -165,7 +173,7 @@

// If count is not requested or type is sponsor,
// there's no need to make an API call
if (count !== 'true' || type === 'sponsor') {
if (count !== 'true' || type === 'sponsor' || noText === 'false') {
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,6 @@ body {
margin-top: -7px;
border-width: 7px 7px 7px 0;
}
.no-text .gh-ico {
margin-right: 0;
}