Skip to content

Commit 012d64a

Browse files
authored
add FontAwesome icons (#15)
1 parent 18ecd16 commit 012d64a

File tree

6 files changed

+44
-4
lines changed

6 files changed

+44
-4
lines changed

src/popup.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,18 @@ const logout = async () => {
7878
});
7979
};
8080

81+
const makeIcon = (faIcon: string) => {
82+
const icon = document.createElement('i');
83+
icon.classList.add('fa-regular', faIcon, 'icon');
84+
return icon;
85+
};
86+
8187
const renderLoggedInContent = async (user: User) => {
8288
const emailHash = await sha256(user.email);
8389

8490
const mainEl = document.getElementById('main-content')!;
8591

92+
/* User Info element */
8693
const userEl = document.createElement('div');
8794
userEl.classList.add('user');
8895

@@ -107,15 +114,27 @@ const renderLoggedInContent = async (user: User) => {
107114

108115
userEl.appendChild(userInfoEl);
109116

117+
const siteLink = document.createElement('a');
118+
siteLink.href = 'https://gitkraken.dev';
119+
siteLink.target = '_blank';
120+
const siteIcon = makeIcon('fa-arrow-up-right-from-square');
121+
siteLink.appendChild(siteIcon);
122+
userEl.appendChild(siteLink);
123+
110124
mainEl.appendChild(userEl);
111125

126+
/* Sign out butto */
112127
const signOutBtn = document.createElement('button');
113128
signOutBtn.textContent = 'Sign out';
114129
signOutBtn.classList.add('btn');
115130
signOutBtn.addEventListener('click', async () => {
116131
await logout();
117132
window.close();
118133
});
134+
135+
const signOutIcon = makeIcon('fa-right-from-bracket');
136+
signOutBtn.prepend(signOutIcon);
137+
119138
mainEl.appendChild(signOutBtn);
120139
};
121140

@@ -124,10 +143,13 @@ const renderLoggedOutContent = () => {
124143

125144
const signInLink = document.createElement('a');
126145
signInLink.href = 'https://gitkraken.dev/login';
127-
signInLink.target = '_blank';
128146
signInLink.textContent = 'Sign in GitKraken account';
147+
signInLink.target = '_blank';
129148
signInLink.classList.add('btn');
130149

150+
const signInIcon = makeIcon('fa-right-from-bracket');
151+
signInLink.prepend(signInIcon);
152+
131153
mainEl.appendChild(signInLink);
132154
};
133155

@@ -138,6 +160,9 @@ const main = async () => {
138160
} else {
139161
renderLoggedOutContent();
140162
}
163+
164+
const loadingIcon = document.getElementById('loading-icon');
165+
loadingIcon?.remove();
141166
};
142167

143168
void main();

static/css/fontawesome.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/css/regular.min.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*!
2+
* Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com
3+
* License - https://fontawesome.com/license (Commercial License)
4+
* Copyright 2023 Fonticons, Inc.
5+
*/
6+
:host,:root{--fa-style-family-classic:"Font Awesome 6 Pro";--fa-font-regular:normal 400 1em/1 "Font Awesome 6 Pro"}@font-face{font-family:"Font Awesome 6 Pro";font-style:normal;font-weight:400;font-display:block;src:url(../webfonts/fa-regular-400.woff2) format("woff2"),url(../webfonts/fa-regular-400.ttf) format("truetype")}.fa-regular,.far{font-weight:400}

static/popup.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ button.btn {
3030
text-align: start;
3131
padding: 5px;
3232
}
33+
a.btn .icon, button.btn .icon {
34+
margin-right: 8px;
35+
}
3336

3437
img.avatar {
3538
border-radius: 50%;
@@ -44,7 +47,8 @@ img.avatar {
4447
padding: 8px;
4548
}
4649
.user-info {
47-
margin-left: 8px;
50+
margin: 0 8px;
51+
flex: 1 1 0%;
4852
}
4953
.user-info .user-name {
5054
font-weight: bold;

static/popup.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<html>
2-
<script src="/dist/popup.js"></script>
2+
<link rel="stylesheet" href="css/fontawesome.min.css" />
3+
<link rel="stylesheet" href="css/regular.min.css" />
34
<link rel="stylesheet" href="popup.css" />
5+
<script src="/dist/popup.js"></script>
46
<body>
5-
<main id="main-content"></main>
7+
<main id="main-content">
8+
<i id="loading-icon" class="fa-regular fa-spinner-third fa-spin"></i>
9+
</main>
610
</body>
711
</html>

static/webfonts/fa-regular-400.woff2

409 KB
Binary file not shown.

0 commit comments

Comments
 (0)