Skip to content

Commit

Permalink
add FontAwesome icons (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdgarcia authored Jan 18, 2024
1 parent 18ecd16 commit 012d64a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
27 changes: 26 additions & 1 deletion src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,18 @@ const logout = async () => {
});
};

const makeIcon = (faIcon: string) => {
const icon = document.createElement('i');
icon.classList.add('fa-regular', faIcon, 'icon');
return icon;
};

const renderLoggedInContent = async (user: User) => {
const emailHash = await sha256(user.email);

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

/* User Info element */
const userEl = document.createElement('div');
userEl.classList.add('user');

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

userEl.appendChild(userInfoEl);

const siteLink = document.createElement('a');
siteLink.href = 'https://gitkraken.dev';
siteLink.target = '_blank';
const siteIcon = makeIcon('fa-arrow-up-right-from-square');
siteLink.appendChild(siteIcon);
userEl.appendChild(siteLink);

mainEl.appendChild(userEl);

/* Sign out butto */
const signOutBtn = document.createElement('button');
signOutBtn.textContent = 'Sign out';
signOutBtn.classList.add('btn');
signOutBtn.addEventListener('click', async () => {
await logout();
window.close();
});

const signOutIcon = makeIcon('fa-right-from-bracket');
signOutBtn.prepend(signOutIcon);

mainEl.appendChild(signOutBtn);
};

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

const signInLink = document.createElement('a');
signInLink.href = 'https://gitkraken.dev/login';
signInLink.target = '_blank';
signInLink.textContent = 'Sign in GitKraken account';
signInLink.target = '_blank';
signInLink.classList.add('btn');

const signInIcon = makeIcon('fa-right-from-bracket');
signInLink.prepend(signInIcon);

mainEl.appendChild(signInLink);
};

Expand All @@ -138,6 +160,9 @@ const main = async () => {
} else {
renderLoggedOutContent();
}

const loadingIcon = document.getElementById('loading-icon');
loadingIcon?.remove();
};

void main();
1 change: 1 addition & 0 deletions static/css/fontawesome.min.css

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions static/css/regular.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*!
* Font Awesome Pro 6.5.1 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license (Commercial License)
* Copyright 2023 Fonticons, Inc.
*/
: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}
6 changes: 5 additions & 1 deletion static/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ button.btn {
text-align: start;
padding: 5px;
}
a.btn .icon, button.btn .icon {
margin-right: 8px;
}

img.avatar {
border-radius: 50%;
Expand All @@ -44,7 +47,8 @@ img.avatar {
padding: 8px;
}
.user-info {
margin-left: 8px;
margin: 0 8px;
flex: 1 1 0%;
}
.user-info .user-name {
font-weight: bold;
Expand Down
8 changes: 6 additions & 2 deletions static/popup.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<html>
<script src="/dist/popup.js"></script>
<link rel="stylesheet" href="css/fontawesome.min.css" />
<link rel="stylesheet" href="css/regular.min.css" />
<link rel="stylesheet" href="popup.css" />
<script src="/dist/popup.js"></script>
<body>
<main id="main-content"></main>
<main id="main-content">
<i id="loading-icon" class="fa-regular fa-spinner-third fa-spin"></i>
</main>
</body>
</html>
Binary file added static/webfonts/fa-regular-400.woff2
Binary file not shown.

0 comments on commit 012d64a

Please sign in to comment.