@@ -8,13 +8,28 @@ import WebRStatus from './components/WebRStatus.vue'
88import LibrarySelector from ' ./components/LibrarySelector.vue'
99import { useWebR } from ' ./composables/useWebR'
1010import { examples } from ' ./data/examples'
11+ import { icons } from ' ./data/icons'
1112import 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)
1426const code = ref (examples [0 ].code )
1527const lastExecutedCode = ref (' ' )
1628const hasChanges = computed (() => code .value !== lastExecutedCode .value )
1729
30+ // GitHub stars
31+ const githubStars = ref <number | null >(null )
32+
1833const {
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+
6694onMounted (() => {
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 ;
0 commit comments