Skip to content

Commit 26cf536

Browse files
committed
fix: copy button
Signed-off-by: Carlos Alexandro Becker <[email protected]>
1 parent 126d0f6 commit 26cf536

File tree

2 files changed

+38
-17
lines changed

2 files changed

+38
-17
lines changed

static/styles.css

+14-9
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,19 @@ div.main>form>input[type=text] {
108108
border-radius: 4px;
109109
box-sizing: border-box;
110110
font-family: inherit;
111-
font-size: 1rem;
111+
font-size: 1rem;
112112
color: #555;
113113
}
114114

115-
div.main>form>input[type=submit] {
115+
116+
p.error {
117+
color: #e76060;
118+
font-weight: bold;
119+
margin-top: 1em;
120+
margin-bottom: 1em;
121+
}
122+
123+
.btn {
116124
width: 100%;
117125
background-color: #3F3D56;
118126
color: white;
@@ -122,13 +130,10 @@ div.main>form>input[type=submit] {
122130
border-radius: 4px;
123131
cursor: pointer;
124132
font-family: inherit;
125-
font-size: 1rem;
126-
font-weight: 450;
133+
font-size: 1rem;
134+
font-weight: 450;
127135
}
128136

129-
p.error {
130-
color: #e76060;
131-
font-weight: bold;
132-
margin-top: 1em;
133-
margin-bottom: 1em;
137+
.btn.copy-btn {
138+
margin-top: -20px;
134139
}

static/templates/index.html

+24-8
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
<title>Star Charts</title>
1414
<meta name="description" content="StarCharts">
1515
<meta name="author" content="https://github/caarlos0">
16-
<link rel="stylesheet" href="/static/styles.css">
17-
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/styles/darcula.min.css">
16+
<link rel="stylesheet" href="/static/styles.css?v={{ .Version }}">
17+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/styles/base16/dracula.min.css"
18+
integrity="sha512-oDvVpANXrKQ6R5B25VO6DooEQWA7jUXleyD6oUWHChC0fjv8wAANSX7lKXtp5D6HbZ7EUxd0wjMibtpCQ+aCDw=="
19+
crossorigin="anonymous" referrerpolicy="no-referrer" />
1820
</head>
1921

2022
<body>
@@ -23,7 +25,7 @@
2325
<span class="title"><a href="/">starcharts</a></span>
2426
<span class="subtitle">Plot your repository stars over time.</span>
2527
</div>
26-
{{ if .FullName }}
28+
{{ with .Details }}
2729
<div class="main">
2830
<p>
2931
{{ if .StargazersCount }}
@@ -48,11 +50,14 @@
4850
You can include the chart on your repository's
4951
<code>README.md</code>
5052
as follows:
51-
<pre><code class="markdown">
53+
<pre>
54+
<code class="markdown" id="code">
5255
## Stargazers over time
5356

5457
[![Stargazers over time](https://starchart.cc/{{ .FullName }}.svg)](https://starchart.cc/{{ .FullName }})
55-
</code></pre>
58+
</code>
59+
<button class="btn copy-btn" data-clipboard-target="#code">Copy</button>
60+
</pre>
5661
</p>
5762
</div>
5863
<div class="footer">
@@ -70,14 +75,25 @@
7075
<label for="repo">Repository:</label><br>
7176
<input type="text" id="repository" name="repository" value="caarlos0/starcharts" placeholder="caarlos0/starcharts"
7277
autofocus="true"><br>
73-
<input type="submit" value="Submit">
78+
<input type="submit" value="Submit" class="btn">
7479
</form>
7580
</div>
7681
{{ end }}
77-
<script src="//cdnjs.cloudflare.com/ajax/libs/timeago.js/3.0.2/timeago.min.js"></script>
78-
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.11.0/highlight.min.js"></script>
82+
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.2/timeago.min.js"
83+
integrity="sha512-SVDh1zH5N9ChofSlNAK43lcNS7lWze6DTVx1JCXH1Tmno+0/1jMpdbR8YDgDUfcUrPp1xyE53G42GFrcM0CMVg=="
84+
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
85+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/languages/markdown.min.js"
86+
integrity="sha512-ADxHovZZYEPiuBlIAejqh6IxCe+Vi7CIYVYpKyXtvain1hzK6DpYlQhoxwo0YBHv11Oj8N3jBqRCoOA8I8lXiw=="
87+
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
88+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.1.0/highlight.min.js"
89+
integrity="sha512-z+/WWfyD5tccCukM4VvONpEtLmbAm5LDu7eKiyMQJ9m7OfPEDL7gENyDRL3Yfe8XAuGsS2fS4xSMnl6d30kqGQ=="
90+
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
91+
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"
92+
integrity="sha512-sIqUEnRn31BgngPmHt2JenzleDDsXwYO+iyvQ46Mw6RL+udAUZj2n/u/PGY80NxRxynO7R9xIGx5LEzw4INWJQ=="
93+
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
7994
<script defer data-domain="starchart.cc" src="https://plausible.io/js/plausible.js"></script>
8095
<script>
96+
new ClipboardJS('.copy-btn');
8197
hljs.initHighlightingOnLoad();
8298
timeago().render(document.querySelectorAll('time'));
8399
</script>

0 commit comments

Comments
 (0)