Skip to content

Commit 134fb07

Browse files
shakyShaneMoon Kyongmoon0326
authored
history: adding sites support (#1954)
* history: adding sites support * Add separator above "Sites" item * Add tests for the divider change * Target sites only * Follow the same approach to use the css * Update test screenshots * Remove unncessary tests -- screenshots covers it already --------- Co-authored-by: Moon Kyong <[email protected]> Co-authored-by: Moon Kyong <[email protected]>
1 parent e6f03ef commit 134fb07

File tree

16 files changed

+68
-7
lines changed

16 files changed

+68
-7
lines changed

special-pages/pages/history/app/components/Item.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Item = memo(
1818
* @param {string} props.url - The text to be displayed for the item.
1919
* @param {string} props.domain - The text to be displayed for the domain
2020
* @param {number} props.kind - The kind or type of the item that determines its visual style.
21-
* @param {string} props.dateTimeOfDay - the time of day, like 11.00am.
21+
* @param {string} [props.dateTimeOfDay] - the time of day, like 11.00am.
2222
* @param {string} props.dateRelativeDay - the time of day, like 11.00am.
2323
* @param {string|null} props.etldPlusOne
2424
* @param {number} props.index - original index
@@ -63,7 +63,7 @@ export const Item = memo(
6363
<span class={styles.domain} data-testid="Item.domain" title={props.domain}>
6464
{props.domain}
6565
</span>
66-
<span class={styles.time}>{dateTimeOfDay}</span>
66+
{dateTimeOfDay && <span className={styles.time}>{dateTimeOfDay}</span>}
6767
<button class={styles.dots} data-action={BTN_ACTION_ENTRIES_MENU} data-index={index} value={props.id} tabindex={-1}>
6868
<Dots />
6969
</button>

special-pages/pages/history/app/components/Sidebar.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const iconMap = {
2828
saturday: 'icons/day.svg',
2929
sunday: 'icons/day.svg',
3030
older: 'icons/older.svg',
31+
sites: 'icons/sites.svg',
3132
};
3233

3334
/** @type {Record<RangeId, (t: (s: keyof json) => string) => string>} */
@@ -43,6 +44,7 @@ const titleMap = {
4344
saturday: (t) => t('range_saturday'),
4445
sunday: (t) => t('range_sunday'),
4546
older: (t) => t('range_older'),
47+
sites: (t) => t('range_sites'),
4648
};
4749

4850
/**
@@ -106,7 +108,7 @@ function Item({ current, range, onClick, onDelete, count }) {
106108
if (range === 'all' && current.value === null) {
107109
return cn(styles.item, styles.active);
108110
}
109-
return cn(styles.item, current.value === range && styles.active);
111+
return cn(styles.item, current.value === range && styles.active, styles[`item_${range}`]);
110112
});
111113

112114
return (
@@ -182,6 +184,7 @@ function labels(range, t) {
182184
case 'thursday':
183185
case 'friday':
184186
case 'saturday':
187+
case 'sites':
185188
case 'sunday':
186189
return { linkLabel: t('show_history_for', { range }), buttonLabel: t('delete_history_for', { range }) };
187190
case 'older':

special-pages/pages/history/app/components/Sidebar.module.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@
3939
background: var(--color-white-at-6);
4040
}
4141
}
42+
43+
&.item_sites {
44+
margin-top: 16px;
45+
46+
&::before {
47+
content: '';
48+
position: absolute;
49+
top: -8px;
50+
left: 16px;
51+
right: 16px;
52+
border-top: 1px solid var(--color-black-at-6);
53+
}
54+
55+
[data-theme="dark"] &::before {
56+
border-top: 1px solid var(--color-white-at-6);
57+
}
58+
}
4259
}
4360

4461
.item:hover .delete[aria-disabled="true"] {

special-pages/pages/history/app/history.service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ export function toRange(input) {
421421
'sunday',
422422
'recentlyOpened',
423423
'older',
424+
'sites',
424425
];
425426
return valid.includes(input) ? /** @type {import('../types/history.js').RangeId} */ (input) : null;
426427
}

special-pages/pages/history/app/mocks/mock-transport.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function mockTransport() {
4040
{ id: 'saturday', count: 1 },
4141
{ id: 'friday', count: 1 },
4242
{ id: 'older', count: 1 },
43+
{ id: 'sites', count: 1 },
4344
],
4445
};
4546

@@ -268,8 +269,10 @@ function queryResponseFrom(memory, msg) {
268269
const response = asResponse(memory.slice(0, 10), msg.params.offset, msg.params.limit);
269270
const range = msg.params.query.range;
270271
response.value = response.value.map((item) => {
272+
if (!('range' in msg.params.query)) return item; // unreachable
271273
return {
272274
...item,
275+
dateTimeOfDay: msg.params.query.range === 'sites' ? undefined : item.dateTimeOfDay,
273276
title: 'range:' + range + ' ' + item.title,
274277
};
275278
});

special-pages/pages/history/app/strings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,9 @@
106106
"range_older": {
107107
"title": "Older",
108108
"note": "Label on a button that shows older history entries."
109+
},
110+
"range_sites": {
111+
"title": "Sites",
112+
"note": "Label on a button that shows which sites have been visited"
109113
}
110114
}

special-pages/pages/history/integration-tests/history.page.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,15 @@ export class HistoryTestPage {
601601
const rgb = `rgb(${[r, g, b].join(', ')})`;
602602
await expect(this.page.locator('[data-layout-mode="normal"]')).toHaveCSS('background-color', rgb, { timeout: 50 });
603603
}
604+
605+
async lastItemDividerHasColor({ rgb }) {
606+
const lastItem = this.sidebar().locator('.Sidebar_item').last();
607+
const borderTopColor = await lastItem.evaluate((el) => {
608+
const before = window.getComputedStyle(el, '::before');
609+
return before.borderTopColor;
610+
});
611+
expect(borderTopColor).toBe(rgb);
612+
}
604613
}
605614

606615
/**
1.61 KB
Loading
1.54 KB
Loading
1.52 KB
Loading

0 commit comments

Comments
 (0)