Skip to content

Commit c9f7798

Browse files
vkraucunasShane Osbourne
andauthored
New Tab Page and NTP Widget styles (#1229)
* fix: NextSteps bubble position, rm the unused mock provider * chore: Add RMF to default page, adjust NextSteps styels * chore: Add common border radii 4, 6, 8, 12px * fix: tests, first attempt * reverting adding the RMF to the default page * feat: Add hover show/hide on NExtSteps * chore: Add focus ring consistency * chore: Update text colors to use ntp theme values * chore: remove unneeded css * wip * fix: file names * fix: bubble location * fix: addAppToDockMac NextSteps variant * chore: Add 0 gap option to Stack, use in WidgetList * chore: remove ShowHideButtonWithText, update ShowHideButton to handle full width and round variations * chore: Update ChevronButton Icon * chore: Add long title option to the Favorites data * chore: Adjust widget spacing values * chore: A few cleanups * chore: Reorg RMF * chore: Reorg PrivacyStats * fix: PrivacyStats reorg * chore: Reorg Customizer * chore: Update Examples * fix: Favorites tests * chore: Add type info to the Examples in each widget * fix: Examples view * fix: Component item relative to contain absolutely positioned items * chore: Rename example files consistently * chore: UpdateNotification added to correct space, switched to DismissButton usage * fix: lint * chore: Remove unneeded color * chore: Add a gap var to the ntp-theme css and apply across widgets * rebase bugfix * chore: Fix rmf spacing * fix: Favorites test * fix: thin focus ring --------- Co-authored-by: Shane Osbourne <[email protected]>
1 parent a53559e commit c9f7798

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+535
-692
lines changed

special-pages/messages/new-tab/examples/widgets.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ const widgetConfig = {
3232
const initialSetupResponse = {
3333
widgets: [{ id: 'updateNotification' }, { id: 'rmf' }, { id: 'favorites' }, { id: 'privacyStats' }],
3434
widgetConfigs: [
35+
{ id: 'rmf', visibility: 'visible' },
36+
{ id: 'nextSteps', visibility: 'visible' },
3537
{ id: 'favorites', visibility: 'visible' },
3638
{ id: 'privacyStats', visibility: 'visible' },
3739
],

special-pages/pages/new-tab/app/components/Components.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { Fragment, h } from 'preact';
22
import styles from './Components.module.css';
33
import { mainExamples, otherExamples } from './Examples.jsx';
4-
import { updateNotificationExamples } from '../update-notification/UpdateNotification.examples.js';
54
const url = new URL(window.location.href);
65

76
const list = {
87
...mainExamples,
98
...otherExamples,
10-
...updateNotificationExamples,
119
};
1210

1311
const entries = Object.entries(list);

special-pages/pages/new-tab/app/components/Components.module.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ body[data-display="components"] {
3535
color: var(--ntp-text-normal);
3636
padding: 0.2em 0.3em;
3737
border: 1px solid var(--color-gray-60);
38-
border-radius: 4px;
38+
border-radius: var(--border-radius-xs);
3939
display: inline-block;
4040
line-height: 1;
4141
text-decoration: none;
@@ -72,7 +72,6 @@ body[data-display="components"] {
7272
gap: 1rem; /* Adjust the gap size as needed */
7373
}
7474

75-
.selectItem {
75+
.item {
76+
position: relative;
7677
}
77-
78-
.item {}

special-pages/pages/new-tab/app/components/DismissButton.module.css

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
border-width: 0;
33
text-wrap: nowrap;
44
font-weight: 600;
5-
font-size: calc(11 * var(--px-in-rem));
6-
line-height: calc(11 * var(--px-in-rem));
7-
color: var(--ntp-color-primary);
85
height: 1rem;
96
width: 1rem;
107
padding: 0;
118
line-height: 1;
129
background-color: transparent;
13-
color: var(--color-black-at-60);
10+
color: var(--ntp-text-muted);
1411
border: none;
1512
border-radius: 50%;
16-
13+
transition: all .3s;
1714

1815
&:hover {
1916
background-color: var(--color-black-at-9);
@@ -22,7 +19,7 @@
2219

2320
&:active {
2421
background-color: var(--color-black-at-18);
25-
color: var(--color-black-at-84);
22+
color: var(--ntp-text-normal);
2623
}
2724

2825
&:disabled {
@@ -35,20 +32,17 @@
3532
}
3633

3734
&:focus-visible {
38-
box-shadow: 0px 0px 0px 1px var(--color-white), 0px 0px 0px 3px var(--ntp-focus-outline-color);
35+
box-shadow: var(--focus-ring);
36+
outline: none;
3937
}
4038

4139
@media screen and (prefers-color-scheme: dark) {
42-
color: var(--color-white-at-60);
43-
44-
4540
&:hover {
4641
background-color: var(--color-black-at-9);
4742
}
4843

4944
&:active {
5045
background-color: var(--color-white-at-18);
51-
color: var(--color-white-at-84);
5246
}
5347

5448
&:disabled {
@@ -60,42 +54,5 @@
6054
cursor: not-allowed;
6155
background-color: var(--color-white-at-12);
6256
}
63-
64-
&:focus-visible {
65-
box-shadow: 0px 0px 0px 1px var(--ntp-focus-outline-color), 0px 0px 0px 3px var(--color-white);
66-
}
67-
}
68-
}
69-
/*
70-
.dismissBtn {
71-
height: 1rem;
72-
width: 1rem;
73-
padding: 0;
74-
line-height: 1;
75-
background-color: transparent;
76-
color: var(--color-black-at-60);
77-
border: none;
78-
border-radius: 50%;
79-
80-
&:active {
81-
background-color: var(--color-black-at-18);
82-
color: var(--color-black-at-84);
83-
}
84-
85-
&:hover {
86-
background-color: var(--color-black-at-9);
87-
}
88-
89-
@media screen and (prefers-color-scheme: dark) {
90-
color: var(--color-white-at-60);
91-
92-
&:hover {
93-
background-color: var(--color-white-at-9);
94-
}
95-
96-
&:active {
97-
background-color: var(--color-white-at-18);
98-
color: var(--color-white-at-84);
99-
}
10057
}
101-
} */
58+
}
Lines changed: 13 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,24 @@
1-
import { Fragment, h } from 'preact';
2-
import { PrivacyStatsMockProvider } from '../privacy-stats/mocks/PrivacyStatsMockProvider.js';
3-
import { Body, Heading, PrivacyStatsConsumer } from '../privacy-stats/PrivacyStats.js';
4-
import { RemoteMessagingFramework } from '../remote-messaging-framework/RemoteMessagingFramework.js';
5-
import { nextStepsExamples, otherNextStepsExamples } from '../next-steps/components/NextStepsExamples.js';
6-
import { stats } from '../privacy-stats/mocks/stats.js';
1+
import { h } from 'preact';
2+
import { favoritesExamples } from '../favorites/components/Favorites.examples.js';
3+
import { otherPrivacyStatsExamples, privacyStatsExamples } from '../privacy-stats/components/PrivacyStats.examples.js';
4+
import { nextStepsExamples, otherNextStepsExamples } from '../next-steps/components/NextSteps.examples.js';
5+
import { otherRMFExamples, RMFExamples } from '../remote-messaging-framework/components/RMF.examples.js';
6+
import { customizerExamples } from '../customizer/components/Customizer.examples.js';
77
import { noop } from '../utils.js';
8-
import { VisibilityMenu } from '../customizer/VisibilityMenu.js';
9-
import { CustomizerButton } from '../customizer/Customizer.js';
10-
import { rmfDataExamples } from '../remote-messaging-framework/mocks/rmf.data.js';
11-
import { favoritesExamples } from '../favorites/components/FavoritesExamples.js';
8+
import { updateNotificationExamples } from '../update-notification/components/UpdateNotification.examples.js';
129

1310
/** @type {Record<string, {factory: () => import("preact").ComponentChild}>} */
1411
export const mainExamples = {
15-
'stats.few': {
16-
factory: () => (
17-
<PrivacyStatsMockProvider ticker={true}>
18-
<PrivacyStatsConsumer />
19-
</PrivacyStatsMockProvider>
20-
),
21-
},
22-
'stats.few.collapsed': {
23-
factory: () => (
24-
<PrivacyStatsMockProvider config={{ expansion: 'collapsed' }}>
25-
<PrivacyStatsConsumer />
26-
</PrivacyStatsMockProvider>
27-
),
28-
},
29-
'stats.single': {
30-
factory: () => (
31-
<PrivacyStatsMockProvider data={stats.single}>
32-
<PrivacyStatsConsumer />
33-
</PrivacyStatsMockProvider>
34-
),
35-
},
36-
'stats.none': {
37-
factory: () => (
38-
<PrivacyStatsMockProvider data={stats.none}>
39-
<PrivacyStatsConsumer />
40-
</PrivacyStatsMockProvider>
41-
),
42-
},
43-
'stats.norecent': {
44-
factory: () => (
45-
<PrivacyStatsMockProvider data={stats.norecent}>
46-
<PrivacyStatsConsumer />
47-
</PrivacyStatsMockProvider>
48-
),
49-
},
50-
'stats.list': {
51-
factory: () => <Body trackerCompanies={stats.few.trackerCompanies} listAttrs={{ id: 'example-stats.list' }} />,
52-
},
53-
'stats.heading': {
54-
factory: () => (
55-
<Heading
56-
trackerCompanies={stats.few.trackerCompanies}
57-
totalCount={stats.few.totalCount}
58-
expansion={'expanded'}
59-
onToggle={noop('stats.heading onToggle')}
60-
/>
61-
),
62-
},
63-
'stats.heading.none': {
64-
factory: () => (
65-
<Heading
66-
trackerCompanies={stats.none.trackerCompanies}
67-
totalCount={stats.none.totalCount}
68-
expansion={'expanded'}
69-
onToggle={noop('stats.heading onToggle')}
70-
/>
71-
),
72-
},
73-
'rmf.small': {
74-
factory: () => <RemoteMessagingFramework message={rmfDataExamples.small.content} dismiss={() => {}} />,
75-
},
76-
'rmf.medium': {
77-
factory: () => <RemoteMessagingFramework message={rmfDataExamples.medium.content} dismiss={() => {}} />,
78-
},
79-
'rmf.big-single-action': {
80-
factory: () => (
81-
<RemoteMessagingFramework message={rmfDataExamples.big_single_action.content} primaryAction={() => {}} dismiss={() => {}} />
82-
),
83-
},
84-
'rmf.big-two-action': {
85-
factory: () => (
86-
<RemoteMessagingFramework
87-
message={rmfDataExamples.big_two_action.content}
88-
primaryAction={() => {}}
89-
secondaryAction={() => {}}
90-
dismiss={() => {}}
91-
/>
92-
),
93-
},
9412
...favoritesExamples,
9513
...nextStepsExamples,
14+
...privacyStatsExamples,
15+
...RMFExamples,
9616
};
9717

9818
export const otherExamples = {
99-
'stats.without-animation': {
100-
factory: () => (
101-
<PrivacyStatsMockProvider
102-
ticker={true}
103-
config={{
104-
expansion: 'expanded',
105-
animation: { kind: 'none' },
106-
}}
107-
>
108-
<PrivacyStatsConsumer />
109-
</PrivacyStatsMockProvider>
110-
),
111-
},
112-
'stats.with-view-transitions': {
113-
factory: () => (
114-
<PrivacyStatsMockProvider
115-
ticker={true}
116-
config={{
117-
expansion: 'expanded',
118-
animation: { kind: 'view-transitions' },
119-
}}
120-
>
121-
<PrivacyStatsConsumer />
122-
</PrivacyStatsMockProvider>
123-
),
124-
},
125-
'rmf.big-two-action-overflow': {
126-
factory: () => (
127-
<RemoteMessagingFramework
128-
message={rmfDataExamples.big_two_action_overflow.content}
129-
primaryAction={() => {}}
130-
secondaryAction={() => {}}
131-
dismiss={() => {}}
132-
/>
133-
),
134-
},
13519
...otherNextStepsExamples,
136-
'customizer-menu': {
137-
factory: () => (
138-
<Fragment>
139-
<div>
140-
<CustomizerButton isOpen={true} />
141-
</div>
142-
<br />
143-
<MaxContent>
144-
<VisibilityMenu
145-
rows={[
146-
{
147-
id: 'favorites',
148-
title: 'Favorites',
149-
icon: 'star',
150-
toggle: noop('toggle favorites'),
151-
visibility: 'hidden',
152-
index: 0,
153-
},
154-
{
155-
id: 'privacyStats',
156-
title: 'Privacy Stats',
157-
icon: 'shield',
158-
toggle: noop('toggle favorites'),
159-
visibility: 'visible',
160-
index: 1,
161-
},
162-
]}
163-
/>
164-
</MaxContent>
165-
</Fragment>
166-
),
167-
},
20+
...otherPrivacyStatsExamples,
21+
...otherRMFExamples,
22+
...customizerExamples,
23+
...updateNotificationExamples,
16824
};
169-
170-
function MaxContent({ children }) {
171-
return <div style={{ display: 'grid', gridTemplateColumns: 'max-content' }}>{children}</div>;
172-
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styles from './Icons.module.css';
33

44
export function ChevronButton() {
55
return (
6-
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" class={styles.chevron}>
6+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" class={styles.chevronButton}>
77
<rect fill="black" fill-opacity="0.06" width="24" height="24" rx="12" class={styles.chevronCircle} />
88
<path
99
fill="black"
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
.chevron {
1+
.chevronButton {
22
&:hover .chevronCircle {
33
fill: black;
44
fill-opacity: 0.06;
55

66
@media screen and (prefers-color-scheme: dark) {
77
fill: white;
8-
fill-opacity: 0.12
8+
fill-opacity: 0.12;
99
}
1010
}
1111
}
@@ -18,11 +18,8 @@
1818
.chevronArrow {
1919
@media screen and (prefers-color-scheme: dark) {
2020
fill: white;
21-
fill-opacity: 0.5
21+
fill-opacity: 0.5;
2222
}
2323
}
2424

25-
.customize {
26-
27-
}
2825

0 commit comments

Comments
 (0)