Skip to content

Commit 26cbd21

Browse files
committed
WIP on activity details
@todo wire up real data
1 parent 10404e6 commit 26cbd21

File tree

7 files changed

+128
-34
lines changed

7 files changed

+128
-34
lines changed

special-pages/pages/new-tab/app/activity/components/Activity.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { ActivityContext, ActivityServiceContext } from '../ActivityProvider.js'
66
import { useTypedTranslationWith } from '../../types.js';
77
import { useOnMiddleClick } from '../../utils.js';
88
import { useAdBlocking, useBatchedActivityApi, usePlatformName } from '../../settings.provider.js';
9-
import { CompanyIcon } from '../../components/CompanyIcon.js';
109
import { Trans } from '../../../../../shared/components/TranslationsProvider.js';
1110
import { ActivityItem } from './ActivityItem.js';
1211
import { ActivityBurningSignalContext, BurnProvider } from '../../burning/BurnProvider.js';
@@ -18,6 +17,7 @@ import { HistoryItems } from './HistoryItems.js';
1817
import { NormalizedDataContext, SignalStateProvider } from '../NormalizeDataProvider.js';
1918
import { ActivityInteractionsContext } from '../../burning/ActivityInteractionsContext.js';
2019
import { ProtectionsEmpty } from '../../protections/components/Protections.js';
20+
import { TickPill } from '../../components/TickPill/TickPill';
2121

2222
/**
2323
* @import enStrings from "../strings.json"
@@ -181,13 +181,12 @@ function TrackerStatus({ id, trackersFound }) {
181181
const { t } = useTypedTranslationWith(/** @type {enStrings} */ ({}));
182182
const { activity } = useContext(NormalizedDataContext);
183183
const status = useComputed(() => activity.value.trackingStatus[id]);
184-
const other = status.value.trackerCompanies.slice(DDG_MAX_TRACKER_ICONS - 1);
185-
const companyIconsMax = other.length === 0 ? DDG_MAX_TRACKER_ICONS : DDG_MAX_TRACKER_ICONS - 1;
184+
// @todo jingram add `cookiePopUpBlocked`
185+
const {totalCount, trackerCompanies} = status.value;
186+
const cookiePopUpBlocked = true;
187+
const other = trackerCompanies.slice(DDG_MAX_TRACKER_ICONS - 1);
186188
const adBlocking = useAdBlocking();
187189

188-
const icons = status.value.trackerCompanies.slice(0, companyIconsMax).map((item, _index) => {
189-
return <CompanyIcon displayName={item.displayName} key={item} />;
190-
});
191190

192191
let otherIcon = null;
193192
if (other.length > 0) {
@@ -199,7 +198,7 @@ function TrackerStatus({ id, trackersFound }) {
199198
);
200199
}
201200

202-
if (status.value.totalCount === 0) {
201+
if (totalCount === 0) {
203202
let text;
204203
if (trackersFound) {
205204
text = adBlocking ? t('activity_no_adsAndTrackers_blocked') : t('activity_no_trackers_blocked');
@@ -208,23 +207,26 @@ function TrackerStatus({ id, trackersFound }) {
208207
}
209208
return (
210209
<p class={styles.companiesIconRow} data-testid="TrackerStatus">
211-
{text}
210+
<TickPill text={text} displayTick={false}/>
212211
</p>
213212
);
214213
}
215214

216215
return (
217216
<div class={styles.companiesIconRow} data-testid="TrackerStatus">
218-
<div class={styles.companiesIcons}>
219-
{icons}
220-
{otherIcon}
221-
</div>
222217
<div class={styles.companiesText}>
223-
{adBlocking ? (
224-
<Trans str={t('activity_countBlockedAdsAndTrackersPlural', { count: String(status.value.totalCount) })} values={{}} />
225-
) : (
226-
<Trans str={t('activity_countBlockedPlural', { count: String(status.value.totalCount) })} values={{}} />
218+
{totalCount > 0 && (
219+
<TickPill
220+
text={
221+
t(totalCount === 1
222+
? 'activity_countBlockedSingular'
223+
: 'activity_countBlockedPlural',
224+
{ count: String(totalCount) }
225+
)
226+
}
227+
/>
227228
)}
229+
{cookiePopUpBlocked && <TickPill text={t('activity_cookiePopUpBlocked')} />}
228230
</div>
229231
</div>
230232
);

special-pages/pages/new-tab/app/activity/components/Activity.module.css

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@
7777
background: var(--color-black-at-12);
7878
transition: transform .2s;
7979

80-
border: 0.5px solid rgba(0, 0, 0, 0.09);
8180
background: rgba(255, 255, 255, 0.30);
82-
box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.12), 0px 0px 1.5px 0px rgba(0, 0, 0, 0.16);
8381

8482
[data-theme="dark"] & {
8583
border: 0.5px solid rgba(255, 255, 255, 0.09);
@@ -198,18 +196,14 @@
198196
padding-left: 1px; /* visual alignment */
199197
}
200198

201-
.companiesIcons {
202-
display: flex;
203-
gap: 3px;
204-
> * {
205-
flex-shrink: 0;
206-
min-width: 0;
207-
}
199+
.companiesText {
200+
& div:first-of-type {
201+
margin-bottom: 6px;
202+
}
208203
}
209-
.companiesText {}
210204

211205
.history {
212-
margin-top: 10px;
206+
margin-top: 8px;
213207
}
214208
.historyItem {
215209
display: flex;
@@ -293,4 +287,4 @@
293287
transform: rotate(180deg)
294288
}
295289
}
296-
}
290+
}

special-pages/pages/new-tab/app/activity/strings.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@
1616
"note": "Placeholder message indicating that no trackers are blocked"
1717
},
1818
"activity_countBlockedPlural": {
19-
"title": "<b>{count}</b> tracking attempts blocked",
20-
"note": "The main headline indicating that more than 1 attempt has been blocked. Eg: '2 tracking attempts blocked'"
19+
"title": "{count} Tracking attempts blocked",
20+
"note": "Pill text indicating that more than 1 attempt has been blocked. Eg: '2 Tracking attempts blocked'"
21+
},
22+
"activity_countBlockedSingular": {
23+
"title": "{count} Tracking attempt blocked",
24+
"note": "Pill text indicating that 1 attempt has been blocked. Eg: '1 Tracking attempt blocked'"
25+
},
26+
"activity_cookiePopUpBlocked": {
27+
"title": "Cookie pop-up blocked",
28+
"note": "Pill text indicating that we have blocked cookie pop-ups"
2129
},
2230
"activity_noRecentAdsAndTrackers_subtitle": {
2331
"title": "Recently visited sites will appear here. Keep browsing to see how many ads and trackers we block.",

special-pages/pages/new-tab/app/components/Icons.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,20 @@ export function InfoIcon(props) {
634634
</svg>
635635
);
636636
}
637+
638+
/**
639+
* From https://dub.duckduckgo.com/duckduckgo/Icons/blob/Main/Glyphs/16px/Check-16.svg
640+
* @param {import('preact').JSX.SVGAttributes<SVGSVGElement>} props
641+
*/
642+
export function Check(props) {
643+
return (
644+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none" {...props}>
645+
<path
646+
fill-rule="evenodd"
647+
clip-rule="evenodd"
648+
d="M14.7573 2.12724C15.0304 2.35035 15.0807 2.73423 14.8576 3.00731L6.97593 13.4341C6.43147 14.1336 5.36195 14.1258 4.82836 13.4027L1.12448 9.00075C0.904738 8.7249 0.946807 8.33307 1.22265 8.11333C1.4985 7.89359 1.89033 7.93566 2.11007 8.2115L5.81395 12.6132C5.93397 12.7636 6.14954 12.7645 6.27138 12.6152L14.153 2.18824C14.3761 1.91517 14.76 1.86459 14.7573 2.12724Z"
649+
fill="white"
650+
/>
651+
</svg>
652+
);
653+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { h } from 'preact';
2+
import { Check } from '../Icons.js';
3+
import cn from 'classnames';
4+
import styles from './TickPill.module.css';
5+
6+
/**
7+
* A pill-shaped component displaying a checkmark with text
8+
* @param {Object} props
9+
* @param {string} props.text - The text to display next to the checkmark
10+
* @param {string} [props.className] - Additional CSS classes
11+
* @param {bool} [props.displayTick] - Display the tick or not
12+
*/
13+
export function TickPill({ text, className, displayTick = true }) {
14+
return (
15+
<div class={cn(styles.tickPill, className || '')}>
16+
{displayTick && (
17+
<span class={styles.iconWrapper}>
18+
<Check />
19+
</span>
20+
)}
21+
<span class={styles.text}>{text}</span>
22+
</div>
23+
);
24+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
.tickPill {
2+
display: flex;
3+
align-items: center;
4+
gap: 6px;
5+
padding: 8px 10px;
6+
border-radius: 100px;
7+
background-color: rgba(255, 255, 255, 0.03);
8+
border: 1px solid rgba(255, 255, 255, 0.12);
9+
height: 20px;
10+
width: fit-content;
11+
}
12+
13+
.iconWrapper {
14+
display: flex;
15+
align-items: center;
16+
justify-content: center;
17+
flex-shrink: 0;
18+
}
19+
20+
.iconWrapper svg {
21+
width: 12px;
22+
height: 12px;
23+
}
24+
25+
.text {
26+
font-size: 11px;
27+
font-weight: 400;
28+
line-height: 16px;
29+
color: rgba(255, 255, 255, 0.84);
30+
white-space: nowrap;
31+
}
32+
33+
/* Light mode styles */
34+
[data-theme="light"] .tickPill {
35+
background-color: rgba(0, 0, 0, 0.04);
36+
border: 1px solid rgba(0, 0, 0, 0.12);
37+
}
38+
39+
[data-theme="light"] .text {
40+
color: rgba(0, 0, 0, 0.84);
41+
}
42+
43+
[data-theme="light"] .iconWrapper svg path {
44+
fill: rgba(0, 0, 0, 0.84);
45+
}

special-pages/pages/new-tab/public/locales/en/new-tab.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,16 @@
418418
"note": "Placeholder message indicating that no trackers are blocked"
419419
},
420420
"activity_countBlockedPlural": {
421-
"title": "{tickMark} {count} Tracking attempts blocked",
422-
"note": "The main headline indicating that more than 1 attempt has been blocked. Eg: '2 Tracking attempts blocked'"
421+
"title": "{count} Tracking attempts blocked",
422+
"note": "Pill text indicating that more than 1 attempt has been blocked. Eg: '2 Tracking attempts blocked'"
423423
},
424424
"activity_countBlockedSingular": {
425-
"title": "{tickMark} {count} Tracking attempt blocked",
426-
"note": "The main headline indicating that 1 attempt has been blocked. Eg: '1 Tracking attempt blocked'"
425+
"title": "{count} Tracking attempt blocked",
426+
"note": "Pill text indicating that 1 attempt has been blocked. Eg: '1 Tracking attempt blocked'"
427+
},
428+
"activity_cookiePopUpBlocked": {
429+
"title": "Cookie pop-up blocked",
430+
"note": "Pill text indicating that we have blocked cookie pop-ups"
427431
},
428432
"activity_noRecentAdsAndTrackers_subtitle": {
429433
"title": "Recently visited sites will appear here. Keep browsing to see how many ads and trackers we block.",

0 commit comments

Comments
 (0)