Browse Source

Make sure badge always defaults to @username

greenkeeper/initial
Luke Childs 6 years ago
parent
commit
342e352e77
  1. 2
      index.html
  2. 3
      script.js

2
index.html

@ -13,7 +13,7 @@
<div class="container"> <div class="container">
<h1>⚡️ tippin.me Badge Generator</h1> <h1>⚡️ tippin.me Badge Generator</h1>
<p class="description">Enter your Twitter username</p> <p class="description">Enter your Twitter username</p>
<input type="text" name="username"> <input type="text" name="username" placeholder="username" autofocus>
<div class="badge-preview"></div> <div class="badge-preview"></div>
</div> </div>

3
script.js

@ -13,7 +13,8 @@ const username = document.querySelector('input[name="username"]');
const badgePreview = document.querySelector('.badge-preview'); const badgePreview = document.querySelector('.badge-preview');
const generateBadge = () => { const generateBadge = () => {
badgePreview.innerHTML = badgeHtml(escape(username.value)); badgePreview.innerHTML = badgeHtml(escape(username.value) || 'username');
}; };
generateBadge();
username.addEventListener('input', generateBadge); username.addEventListener('input', generateBadge);

Loading…
Cancel
Save