Skip to content

Commit 9a09586

Browse files
staredclaude
andcommitted
Add MIT License and GitHub repository link with star counter
- Add MIT License (Copyright 2025 Piotr Migdal, Quesma) - Add GitHub repository link in header with official GitHub icon - Implement dynamic star counter using GitHub API - Extract SVG icons to separate icons.ts file for better organization - Add proper TypeScript types for GitHub API response 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent b85d11e commit 9a09586

File tree

3 files changed

+139
-4
lines changed

3 files changed

+139
-4
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Piotr Migdal, Quesma
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

src/App.vue

Lines changed: 108 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,28 @@ import WebRStatus from './components/WebRStatus.vue'
88
import LibrarySelector from './components/LibrarySelector.vue'
99
import { useWebR } from './composables/useWebR'
1010
import { examples } from './data/examples'
11+
import { icons } from './data/icons'
1112
import type { RExample, CsvData } from './types'
1213
14+
// Constants
15+
const GITHUB_REPO_OWNER = 'QuesmaOrg'
16+
const GITHUB_REPO_NAME = 'demo-webr-ggplot'
17+
const GITHUB_API_URL = `https://api.github.com/repos/${GITHUB_REPO_OWNER}/${GITHUB_REPO_NAME}`
18+
19+
// Types
20+
interface GitHubRepo {
21+
stargazers_count: number
22+
[key: string]: unknown
23+
}
24+
1325
// Start with the first example (getting-started)
1426
const code = ref(examples[0].code)
1527
const lastExecutedCode = ref('')
1628
const hasChanges = computed(() => code.value !== lastExecutedCode.value)
1729
30+
// GitHub stars
31+
const githubStars = ref<number | null>(null)
32+
1833
const {
1934
isReady,
2035
isLoading,
@@ -63,20 +78,56 @@ const handleExampleSelect = async (example: RExample) => {
6378
}
6479
}
6580
81+
// Fetch GitHub stars
82+
const fetchGitHubStars = async () => {
83+
try {
84+
const response = await fetch(GITHUB_API_URL)
85+
if (response.ok) {
86+
const data = await response.json() as GitHubRepo
87+
githubStars.value = data.stargazers_count
88+
}
89+
} catch (error) {
90+
console.error('Failed to fetch GitHub stars:', error)
91+
}
92+
}
93+
6694
onMounted(() => {
6795
void initializeWebR(code.value)
6896
// Set initial executed code after auto-execution
6997
setTimeout(() => {
7098
lastExecutedCode.value = code.value
7199
}, 100)
100+
// Fetch GitHub stars
101+
void fetchGitHubStars()
72102
})
73103
</script>
74104

75105
<template>
76106
<div id="app">
77107
<header class="header">
78-
<h1 class="title">WebR ggplot2 & dplyr Demo</h1>
79-
<p class="subtitle">Interactive R data visualization and manipulation in the browser</p>
108+
<div class="header-content">
109+
<div>
110+
<h1 class="title">WebR ggplot2 & dplyr Demo</h1>
111+
<p class="subtitle">Interactive R data visualization and manipulation in the browser</p>
112+
</div>
113+
<a
114+
href="https://github.com/QuesmaOrg/demo-webr-ggplot"
115+
target="_blank"
116+
rel="noopener noreferrer"
117+
class="github-link"
118+
aria-label="View on GitHub">
119+
<svg class="github-icon" :viewBox="icons.github.viewBox" width="16" height="16">
120+
<path fill="currentColor" :d="icons.github.path" />
121+
</svg>
122+
<span class="github-text">View on GitHub</span>
123+
<span v-if="githubStars !== null" class="github-stars">
124+
<svg :viewBox="icons.star.viewBox" width="14" height="14" class="star-icon">
125+
<path fill="currentColor" :d="icons.star.path" />
126+
</svg>
127+
{{ githubStars }}
128+
</span>
129+
</a>
130+
</div>
80131
</header>
81132

82133
<main class="main">
@@ -177,12 +228,19 @@ onMounted(() => {
177228
.header {
178229
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
179230
color: white;
180-
padding: 1.5rem 0;
181-
text-align: center;
231+
padding: 1.5rem 2rem;
182232
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
183233
flex-shrink: 0;
184234
}
185235
236+
.header-content {
237+
display: flex;
238+
justify-content: space-between;
239+
align-items: center;
240+
max-width: 1400px;
241+
margin: 0 auto;
242+
}
243+
186244
.title {
187245
margin: 0;
188246
font-size: 2rem;
@@ -197,6 +255,52 @@ onMounted(() => {
197255
font-weight: 300;
198256
}
199257
258+
.github-link {
259+
color: white;
260+
text-decoration: none;
261+
display: flex;
262+
align-items: center;
263+
gap: 0.75rem;
264+
padding: 0.5rem 1rem;
265+
border-radius: 6px;
266+
transition: all 0.3s ease;
267+
background-color: rgba(255, 255, 255, 0.1);
268+
border: 1px solid rgba(255, 255, 255, 0.2);
269+
}
270+
271+
.github-link:hover {
272+
background-color: rgba(255, 255, 255, 0.2);
273+
transform: translateY(-1px);
274+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
275+
}
276+
277+
.github-icon {
278+
width: 20px;
279+
height: 20px;
280+
flex-shrink: 0;
281+
}
282+
283+
.github-text {
284+
font-size: 0.875rem;
285+
font-weight: 500;
286+
}
287+
288+
.github-stars {
289+
display: flex;
290+
align-items: center;
291+
gap: 0.25rem;
292+
font-size: 0.875rem;
293+
font-weight: 600;
294+
padding-left: 0.75rem;
295+
border-left: 1px solid rgba(255, 255, 255, 0.3);
296+
}
297+
298+
.star-icon {
299+
width: 14px;
300+
height: 14px;
301+
color: #fbbf24;
302+
}
303+
200304
201305
.main {
202306
flex: 1;

src/data/icons.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const icons = {
2+
github: {
3+
viewBox: '0 0 16 16',
4+
path: 'M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8',
5+
},
6+
star: {
7+
viewBox: '0 0 16 16',
8+
path: 'M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z',
9+
},
10+
} as const

0 commit comments

Comments
 (0)