Skip to content

Commit 28b8d07

Browse files
committed
Add GitHub corner component to display repository link
1 parent ecd36fd commit 28b8d07

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

src/app.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { LitElement, html, css } from "lit";
66
import { customElement, state } from "lit/decorators.js";
77
import { ExceptionListEntry } from "./types";
88
import "./exceptions-table";
9+
import "./github-corner";
10+
11+
const GITHUB_URL = "https://github.com/Trikolon/url-classifier-exceptions-ui";
912

1013
const RS_ENDPOINTS = {
1114
prod: "https://firefox.settings.services.mozilla.com",
@@ -223,6 +226,8 @@ export class App extends LitElement {
223226
>.
224227
</p>
225228
</footer>
229+
<!-- Show a link to the repository in the top right corner -->
230+
<github-corner repoUrl=${GITHUB_URL}></github-corner>
226231
</div>
227232
`;
228233
}

src/github-corner.ts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import { LitElement, html, css } from "lit";
6+
import { customElement, property } from "lit/decorators.js";
7+
8+
/**
9+
* A simple component that displays octocat in the corner of the page linking to
10+
* a GitHub repo.
11+
*/
12+
@customElement("github-corner")
13+
export class GitHubCorner extends LitElement {
14+
@property({ type: String }) repoUrl = "";
15+
16+
static styles = css`
17+
:host {
18+
position: absolute;
19+
top: 0;
20+
border: 0;
21+
right: 0;
22+
}
23+
24+
.github-corner svg {
25+
color: white;
26+
fill: black;
27+
}
28+
29+
@media (prefers-color-scheme: dark) {
30+
.github-corner svg {
31+
filter: invert(1);
32+
}
33+
}
34+
35+
@keyframes octocat-wave {
36+
0%,
37+
100% {
38+
transform: rotate(0);
39+
}
40+
20%,
41+
60% {
42+
transform: rotate(-25deg);
43+
}
44+
40%,
45+
80% {
46+
transform: rotate(10deg);
47+
}
48+
}
49+
50+
.github-corner:hover .octo-arm {
51+
animation: octocat-wave 560ms ease-in-out;
52+
}
53+
54+
@media (prefers-reduced-motion: reduce) {
55+
.github-corner:hover .octo-arm {
56+
animation: none;
57+
}
58+
}
59+
`;
60+
61+
render() {
62+
return html`
63+
<div class="github-corner">
64+
<a
65+
href="${this.repoUrl}"
66+
target="_blank"
67+
rel="noopener noreferrer"
68+
aria-label="View source on GitHub"
69+
>
70+
<svg
71+
width="80"
72+
height="80"
73+
viewBox="0 0 250 250"
74+
class="github-corner-svg"
75+
aria-hidden="true"
76+
>
77+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
78+
<path
79+
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
80+
fill="currentColor"
81+
style="transform-origin: 130px 106px;"
82+
class="octo-arm"
83+
></path>
84+
<path
85+
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
86+
fill="currentColor"
87+
class="octo-body"
88+
></path>
89+
</svg>
90+
</a>
91+
</div>
92+
`;
93+
}
94+
}

0 commit comments

Comments
 (0)