Skip to content

Commit 0e71fb0

Browse files
committed
add styling to difficulty ratings
1 parent d2cc93c commit 0e71fb0

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/problems-by-company/company.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,31 @@ function rebuildTable() {
225225
solutions.forEach((solution) => {
226226
const row = table.insertRow(-1);
227227
row.insertCell(0).innerText = solution.id.toString();
228-
const difficultyText = solution.difficulty === 1 ? 'Easy' : solution.difficulty === 2 ? 'Medium' : 'Hard';
229-
row.insertCell(1).innerText = difficultyText || 'N/A';
228+
229+
// Get the difficulty level
230+
const difficulty = solution.difficulty;
231+
const difficultyCell = row.insertCell(1);
232+
let difficultyText = '';
233+
let color = '';
234+
235+
// Define the difficulty text and background color
236+
if (difficulty === 1) {
237+
difficultyText = 'Easy';
238+
color = 'lightgreen';
239+
} else if (difficulty === 2) {
240+
difficultyText = 'Medium';
241+
color = 'orange';
242+
} else {
243+
difficultyText = 'Hard';
244+
color = 'red';
245+
}
246+
247+
difficultyCell.innerText = difficultyText || 'N/A';
248+
difficultyCell.style.color = color;
249+
difficultyCell.style.fontWeight = 'bold';
250+
difficultyCell.style.fontSize = '10px';
251+
difficultyCell.style.borderRadius = '5px'; // Apply border radius
252+
230253
row.insertCell(2).innerHTML = `<a href="${solution.url}" target="_blank">${solution.title}</a>`;
231254
row.insertCell(3).innerText = (solution.acceptance ? (solution.acceptance * 100).toFixed(2) + '%' : 'N/A'); // New column for acceptance
232255

@@ -244,7 +267,6 @@ function rebuildTable() {
244267
}
245268

246269

247-
248270
// Keep track of the sorting order for each column
249271
const sortOrders = {
250272
'#': false,

0 commit comments

Comments
 (0)