Skip to content

Commit

Permalink
Improve look of blocked info page
Browse files Browse the repository at this point in the history
- replace "by rule" with simple "by"
- move count to the end of message
  • Loading branch information
penge committed Dec 29, 2023
1 parent 9a48cfb commit c852ec0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
25 changes: 24 additions & 1 deletion public/blocked.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
#url, #rule {
font-family: monospace;
opacity: .4;
padding: var(--border-radius);
border-radius: var(--border-radius);
}

#url {
background: #c6c6c6;
color: white;
}

#rule {
background: #ff0100;
color: white;
}

@media (prefers-color-scheme: dark) {
#url {
background: #606060;
color: #121212;
}

#rule {
filter: saturate(50%);
color: #e8e8e8;
}
}
1 change: 1 addition & 0 deletions public/common.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:root {
--background-color: white;
--border-radius: 3px;
--text-color: black;
}

Expand Down
1 change: 0 additions & 1 deletion public/options.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
:root {
--border-color: black;
--border-radius: 3px;
--input-background-color: white;
}

Expand Down
10 changes: 5 additions & 5 deletions src/helpers/__tests__/get-blocked-message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test("getBlockedMessage() returns blocked message", () => {
expect(getBlockedMessage({
url: "http://youtube.com/",
rule: "youtube.com",
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> by rule <span id="rule">youtube.com</span>');
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> by <span id="rule">youtube.com</span>');

expect(getBlockedMessage({
url: "http://youtube.com/",
Expand All @@ -13,7 +13,7 @@ test("getBlockedMessage() returns blocked message", () => {
count: 42,
period: "ALL_TIME",
},
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> (42x overall) by rule <span id="rule">youtube.com</span>');
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> by <span id="rule">youtube.com</span> (42x overall)');

expect(getBlockedMessage({
url: "http://youtube.com/",
Expand All @@ -22,7 +22,7 @@ test("getBlockedMessage() returns blocked message", () => {
count: 5,
period: "TODAY",
},
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> (5x today) by rule <span id="rule">youtube.com</span>');
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> by <span id="rule">youtube.com</span> (5x today)');

expect(getBlockedMessage({
url: "http://youtube.com/",
Expand All @@ -31,7 +31,7 @@ test("getBlockedMessage() returns blocked message", () => {
count: 12,
period: "THIS_WEEK",
},
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> (12x this week) by rule <span id="rule">youtube.com</span>');
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> by <span id="rule">youtube.com</span> (12x this week)');

expect(getBlockedMessage({
url: "http://youtube.com/",
Expand All @@ -40,5 +40,5 @@ test("getBlockedMessage() returns blocked message", () => {
count: 38,
period: "THIS_MONTH",
},
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> (38x this month) by rule <span id="rule">youtube.com</span>');
})).toBe('<span id="url">http://youtube.com/</span> <b>was blocked</b> by <span id="rule">youtube.com</span> (38x this month)');
});
6 changes: 3 additions & 3 deletions src/helpers/get-blocked-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ const periodStrings: Record<CounterPeriod, string> = {
TODAY: "today",
};

export default ({ url, rule, countParams: cp }: GetBlockedUrlParams): string => cp
? `<span id="url">${url}</span> <b>was blocked</b> (${cp.count}x ${periodStrings[cp.period]}) by rule <span id="rule">${rule}</span>`
: `<span id="url">${url}</span> <b>was blocked</b> by rule <span id="rule">${rule}</span>`;
export default ({ url, rule, countParams: cp }: GetBlockedUrlParams): string =>
`<span id="url">${url}</span> <b>was blocked</b> by <span id="rule">${rule}</span>`
+ (cp ? ` (${cp.count}x ${periodStrings[cp.period]})` : "");

0 comments on commit c852ec0

Please sign in to comment.