Skip to content

Commit 7fa66fc

Browse files
committed
feat: show git commit on nav bar
1 parent 3e6c8a0 commit 7fa66fc

File tree

6 files changed

+36
-20
lines changed

6 files changed

+36
-20
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_GIT_COMMIT=8a8c364fafdf20ee8504f004b9db54d9bc82eac4
1+
VITE_COMMIT=3e6c8a07d35b2c22fdf4b484b4d43f818dc0ff06

index.html

+5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
href="/src/assets/ignite_logomark.svg"
99
/>
1010
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
11+
<link rel="preconnect" href="https://fonts.gstatic.com" />
12+
<link
13+
href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap"
14+
rel="stylesheet"
15+
/>
1116
<title>Code Generator</title>
1217
</head>
1318
<body>

scripts/getCommit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ exec('git rev-parse HEAD', (err, stdout, stderr) => {
88
console.error(err)
99
}
1010
console.log(stdout, process.env.COMMIT_REF)
11-
fs.writeFileSync('./.env', `VITE_GIT_COMMIT=${stdout}`)
11+
fs.writeFileSync('./.env', `VITE_COMMIT=${stdout}`)
1212
})

src/App.vue

+12-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export default {
4949
--c-brand-yellow: #eaa700;
5050
--c-text: #475569;
5151
--font-size: 1rem;
52-
--font-family-base: Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI',
53-
Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans',
52+
--font-family-base: 'Inter', Avenir, -apple-system, BlinkMacSystemFont,
53+
'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans',
5454
'Helvetica Neue', sans-serif;
5555
--code-font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
5656
--code-font-size: 0.85em;
@@ -68,6 +68,16 @@ body {
6868
-webkit-font-smoothing: antialiased;
6969
-moz-osx-font-smoothing: grayscale;
7070
}
71+
h1 {
72+
font-weight: 600;
73+
}
74+
h2,
75+
h3,
76+
h4,
77+
h5,
78+
h6 {
79+
font-weight: 500;
80+
}
7181
@media (prefers-reduced-motion) {
7282
:focus {
7383
border-radius: 3px;

src/components/NavBar.vue

+15-14
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@
99
height="50"
1010
/>
1111
<span class="pname">Code Generator</span>
12-
<small class="version">v{{ version }}</small>
1312
</a>
1413
</h1>
1514
<div class="left-side-badges">
15+
<a
16+
:href="`https://github.com/pytorch-ignite/code-generator/commit/${currentCommit}`"
17+
target="_blank"
18+
rel="noopener noreferrer"
19+
class="version external-links"
20+
>
21+
v{{ version }}@{{ currentCommit.slice(0, 7) }}
22+
</a>
1623
<button
1724
@click="downloadProject"
1825
class="download-button"
@@ -90,6 +97,7 @@ export default {
9097
setup() {
9198
let zip = new JSZip()
9299
const showDownloadMsg = ref(false)
100+
const currentCommit = import.meta.env.VITE_COMMIT
93101
94102
const downloadProject = () => {
95103
for (const filename in store.code) {
@@ -100,7 +108,7 @@ export default {
100108
})
101109
showDownloadMsg.value = true
102110
}
103-
return { version, downloadProject, showDownloadMsg }
111+
return { version, downloadProject, showDownloadMsg, currentCommit }
104112
}
105113
}
106114
</script>
@@ -121,7 +129,6 @@ h1 img {
121129
}
122130
.external-links {
123131
margin: 0 0.5rem;
124-
font-size: var(--font-size);
125132
border-bottom: 2px solid transparent;
126133
}
127134
.external-links:hover {
@@ -135,25 +142,20 @@ h1 img {
135142
border-bottom: 1px solid var(--c-white-dark);
136143
}
137144
.version {
138-
padding: 0.25rem 0.5rem;
139-
font-size: 0.875rem;
140-
line-height: 1.25rem;
141-
margin-left: 0.25rem;
142-
background-color: #007bff;
143-
border-radius: 8px 2px 8px 2px;
144-
color: var(--c-white-light);
145-
font-weight: bolder;
145+
margin: 0 0.5rem;
146+
color: var(--c-text);
146147
}
147148
.left-side-badges {
148149
display: flex;
149150
align-items: center;
151+
font-size: 0.9em;
150152
}
151153
.download-button {
152154
background: none;
153155
color: var(--c-text);
154156
cursor: pointer;
155157
font-family: var(--font-family-base);
156-
font-size: var(--font-size);
158+
font-size: 1em;
157159
padding-top: 0;
158160
padding-bottom: 0;
159161
}
@@ -194,8 +196,7 @@ h1 img {
194196
}
195197
/* media queries */
196198
@media (max-width: 768px) {
197-
.pname,
198-
.version {
199+
.pname {
199200
display: none;
200201
}
201202
.nav-bar {

src/store.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ const isProd = import.meta.env.PROD
1111
// @ts-ignore
1212
const isDev = import.meta.env.DEV
1313
// @ts-ignore
14-
const gitCommit = import.meta.env.VITE_GIT_COMMIT
14+
const commit = import.meta.env.VITE_COMMIT
1515

1616
// set url for template fetching
1717
// this only works in production and local mode
1818
// not in network mode
1919
const urlTemplates = 'src/templates'
2020
const urlDev = `${location.href}/${urlTemplates}`
21-
const urlProd = `https://raw.githubusercontent.com/pytorch-ignite/code-generator/${gitCommit}/${urlTemplates}`
21+
const urlProd = `https://raw.githubusercontent.com/pytorch-ignite/code-generator/${commit}/${urlTemplates}`
2222
const url = isDev ? urlDev : isProd ? urlProd : null
2323

2424
// ejs options

0 commit comments

Comments
 (0)