Skip to content

NW6| Bakhat Begum| CODEWARS-API-PROJECTS | codeware-API-Project | WEEK-4 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions codewars-badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CodeWarsBadge extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.userName = "CodeYourFuture";
this.userName = "BakhatBegum";
this.userData = [];
}

Expand All @@ -31,21 +31,35 @@ class CodeWarsBadge extends HTMLElement {

render() {
this.shadowRoot.innerHTML = `
<style>
:host {
--rank: ${this.userData.ranks.overall.color};
font: 600 100%/1 system-ui, sans-serif;
}
data {
color: var(--rank);
border: 3px solid;
padding: .25em .5em;
}
</style>
<data value="${this.userData.ranks.overall.score}">
${this.userData.ranks.overall.name}
</data>`;
<data>
<table>
<tr>
<td>Rank: </td>
<td>${this.userData.ranks.overall.name}</td>
<td>${this.userData.ranks.overall.score}</td>
<td>${this.userData.ranks.overall.color}</td>
</tr>

<tr>
<td>Honor: </td>
<td>${this.userData.honor}</td>
</tr>

<tr>
<td>JavaScript Rank: </td>
<td>${this.userData.ranks.languages.javascript.name}</td>
<td>${this.userData.ranks.languages.javascript.score}</td>
<td>${this.userData.ranks.languages.javascript.color}</td>
</tr>

<tr>
<td>Total Completed Kata: </td>
<td>${this.userData.codeChallenges.totalCompleted}</td>
</tr>

</table>
</data>`
}
}

customElements.define("codewars-badge", CodeWarsBadge);

10 changes: 9 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="stylesheet" href="style.css">
<title>Codewars Badge</title>
<meta
name="description"
Expand All @@ -11,7 +12,14 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<codewars-badge></codewars-badge>
<div class="layout">
<h1><span>6 kyu </span> BakhatBegum</h1>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you are using data from the API, not hard-coding in the HTML. Your rank will update over time so it needs to change. And if we use the JavaScript for the username, other people could use the page with their own username 🙂

<table>
<tr>
<codewars-badge></codewars-badge>
</tr>
</table>
</div>
<script async defer type="module" src="./codewars-badge.js"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions style.css

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work making this project your own, Bakhat! Just be careful of formatting, it looks like Prettier hasn't formatted this CSS file

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
body{
background-color: #1D1D1B;
margin: 0 auto;
color: white;
}
span{
color: #f7941d;
border:5px solid yellow;
font-size: 1.2rem;
padding: 6px 6px;
border-radius: 50px;
}

.layout {
margin: 0 auto;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 60vh;
margin-right: 500px;
}
@media screen and (max-width: 992px) {
.layout {
margin-right: 300px;
}
}

@media screen and (max-width: 600px) {

.layout {
margin-right: 0px;
}
}