Skip to content

Commit 1315ce3

Browse files
authored
ntp: support big sur (#1380)
* ntp: support big sur * Fixing favorites grid on big sur * fixing privacy stats layout * don't use aspect ratio * fixing outlines
1 parent 9dbf7ae commit 1315ce3

File tree

13 files changed

+64
-58
lines changed

13 files changed

+64
-58
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function App() {
3131
// prettier-ignore
3232
const {
3333
buttonRef,
34-
wrapperRef,
34+
asideRef,
3535
visibility,
3636
displayChildren,
3737
animating,
@@ -47,8 +47,8 @@ export function App() {
4747
return (
4848
<Fragment>
4949
<BackgroundConsumer browser={browser} />
50-
<div class={styles.layout} ref={wrapperRef} data-animating={animating} data-drawer-visibility={visibility}>
51-
<main class={cn(styles.main, styles.mainScroller)} data-main-scroller data-theme={main}>
50+
<div class={styles.layout} data-animating={animating} data-drawer-visibility={visibility}>
51+
<main class={cn(styles.main, styles.mainLayout, styles.mainScroller)} data-main-scroller data-theme={main}>
5252
<div class={styles.content}>
5353
<div className={styles.tube} data-content-tube data-platform={platformName}>
5454
<WidgetList />
@@ -69,11 +69,12 @@ export function App() {
6969
</main>
7070
{customizerKind === 'drawer' && (
7171
<aside
72-
class={cn(styles.aside, styles.asideScroller)}
72+
class={cn(styles.aside, styles.asideLayout, styles.asideScroller)}
7373
tabindex={tabIndex}
7474
aria-hidden={hidden}
7575
data-theme={browser}
7676
data-browser-panel
77+
ref={asideRef}
7778
>
7879
<div class={styles.asideContent}>
7980
<InlineErrorBoundary

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ body:has([data-reset-layout="true"]) .tube {
2828
}
2929

3030
:global(.vertical-space) {
31-
padding-block: 1rem;
31+
padding-top: 1rem;
32+
padding-bottom: 1rem;
3233
}
3334

3435
/** Don't affect layout if empty (eg: if a widget was toggled) **/
@@ -37,16 +38,8 @@ body:has([data-reset-layout="true"]) .tube {
3738
}
3839

3940
.layout {
40-
display: grid;
41-
grid-template-columns: auto 0 0;
42-
grid-template-areas: "main gap aside";
43-
transition: all .3s ease-in-out;
4441
position: relative;
4542
z-index: 1;
46-
47-
&[data-drawer-visibility='visible'] {
48-
grid-template-columns: auto 4px var(--ntp-combined-width);
49-
}
5043
}
5144

5245
.main {
@@ -56,6 +49,14 @@ body:has([data-reset-layout="true"]) .tube {
5649
color: var(--ntp-text-normal);
5750
}
5851

52+
.mainLayout {
53+
padding-right: 0;
54+
transition: padding-right .3s;
55+
[data-drawer-visibility='visible'] & {
56+
padding-right: var(--ntp-combined-width);
57+
}
58+
}
59+
5960
.mainScroller {
6061
&::-webkit-scrollbar {
6162
width: 4px;
@@ -82,6 +83,7 @@ body:has([data-reset-layout="true"]) .tube {
8283
height: 100vh;
8384
z-index: 1;
8485
overflow: auto;
86+
width: var(--ntp-combined-width);
8587

8688
/** todo: is this re-usable in any way, or unique? */
8789
box-shadow: 0px 0px 1px 0px #FFF inset, 0px 0px 2px 0px rgba(0, 0, 0, 0.08), 0px 8px 12px 0px rgba(0, 0, 0, 0.12);
@@ -100,6 +102,19 @@ body:has([data-reset-layout="true"]) .tube {
100102
}
101103
}
102104

105+
.asideLayout {
106+
position: absolute;
107+
right: 0;
108+
top: 0;
109+
z-index: 1;
110+
transform: translateX(100%);
111+
transition: transform .3s;
112+
113+
[data-drawer-visibility="visible"] & {
114+
transform: translateX(0)
115+
}
116+
}
117+
103118
.asideContent {
104119
opacity: 1;
105120
width: var(--ntp-drawer-width);

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useMessaging } from '../types.js';
66
const CLOSE_DRAWER_EVENT = 'close-drawer';
77
const TOGGLE_DRAWER_EVENT = 'toggle-drawer';
88
const OPEN_DRAWER_EVENT = 'open-drawer';
9-
const REQUEST_VISIBILITY_EVENT = 'request-visibility';
109

1110
/**
1211
* @typedef {'hidden' | 'visible'} DrawerVisibility
@@ -21,8 +20,8 @@ const REQUEST_VISIBILITY_EVENT = 'request-visibility';
2120
* - 3: we provide a way for child components to render AFTER animations have ended, again for performance.
2221
* @param {DrawerVisibility} initial
2322
* @return {{
24-
* wrapperRef: import("preact").RefObject<HTMLDivElement>,
2523
* buttonRef: import("preact").RefObject<HTMLButtonElement>,
24+
* asideRef: import("preact").RefObject<HTMLDivElement>,
2625
* visibility: import("@preact/signals").Signal<DrawerVisibility>,
2726
* buttonId: string,
2827
* drawerId: string,
@@ -33,7 +32,7 @@ const REQUEST_VISIBILITY_EVENT = 'request-visibility';
3332
*/
3433
export function useDrawer(initial) {
3534
const { isReducedMotion } = useEnv();
36-
const wrapperRef = useRef(/** @type {HTMLDivElement|null} */ (null));
35+
const asideRef = useRef(/** @type {HTMLDivElement|null} */ (null));
3736
const buttonRef = useRef(/** @type {HTMLButtonElement|null} */ (null));
3837

3938
// id's for accessibility
@@ -55,8 +54,8 @@ export function useDrawer(initial) {
5554
// react to the global API events
5655
useLayoutEffect(() => {
5756
const controller = new AbortController();
58-
const wrapper = wrapperRef.current;
59-
if (!wrapper) return;
57+
const aside = asideRef.current;
58+
if (!aside) return;
6059

6160
/**
6261
* @param {DrawerVisibility} value
@@ -81,17 +80,8 @@ export function useDrawer(initial) {
8180
window.addEventListener(TOGGLE_DRAWER_EVENT, toggle, { signal: controller.signal });
8281
window.addEventListener(OPEN_DRAWER_EVENT, open, { signal: controller.signal });
8382

84-
// allow anywhere in the application to read the current state
85-
wrapper.addEventListener(
86-
REQUEST_VISIBILITY_EVENT,
87-
(/** @type {CustomEvent} */ e) => {
88-
e.detail.value = visibility.value;
89-
},
90-
{ signal: controller.signal },
91-
);
92-
9383
// update `displayChildren` when animations complete.
94-
wrapper?.addEventListener(
84+
aside?.addEventListener(
9585
'transitionend',
9686
(e) => {
9787
// ignore child animations
@@ -111,12 +101,15 @@ export function useDrawer(initial) {
111101
);
112102

113103
// set animating = true when a parent transition starts
114-
wrapper?.addEventListener(
104+
aside?.addEventListener(
115105
'transitionstart',
116106
(e) => {
117107
// ignore child animations
118108
if (e.target !== e.currentTarget) return;
119-
animating.value = true;
109+
batch(() => {
110+
animating.value = true;
111+
displayChildren.value = true;
112+
});
120113
},
121114
{ signal: controller.signal },
122115
);
@@ -141,14 +134,14 @@ export function useDrawer(initial) {
141134
}, [initial, ntp]);
142135

143136
return {
144-
wrapperRef,
145137
buttonRef,
146138
visibility,
147139
displayChildren,
148140
buttonId,
149141
drawerId,
150142
hidden,
151143
animating,
144+
asideRef,
152145
};
153146
}
154147

special-pages/pages/new-tab/app/customizer/components/BrowserThemeSection.module.css

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
border-radius: 50%;
1717

1818
&[aria-checked="true"] {
19-
outline: 2px solid var(--ntp-color-primary);
20-
outline-offset: 2px;
19+
box-shadow: var(--focus-ring-primary);
2120
}
2221

2322
&:focus-visible {
24-
outline: 2px solid var(--ntp-focus-outline-color);
25-
outline-offset: 2px;
23+
box-shadow: var(--focus-ring-primary);
2624
}
2725

2826
&:active {

special-pages/pages/new-tab/app/customizer/components/CustomizerDrawerInner.module.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@
102102
}
103103
.bgPanel {
104104
display: grid;
105-
aspect-ratio: 16/10.6;
105+
width: 100%;
106+
height: 4rem;
106107
border-radius: 4px;
107108
align-items: center;
108109
justify-content: center;
@@ -111,12 +112,11 @@
111112
box-shadow: 0 0 0 1px var(--ntp-surface-border-color) inset;
112113

113114
&[aria-checked="true"] {
114-
outline: 2px solid var(--ntp-color-primary);
115-
outline-offset: 2px;
115+
box-shadow: var(--focus-ring-primary);
116116
}
117+
117118
&:focus-visible {
118-
outline: 2px solid var(--ntp-focus-outline-color);
119-
outline-offset: 2px;
119+
box-shadow: var(--focus-ring-primary);
120120
}
121121

122122
&:active {

special-pages/pages/new-tab/app/favorites/components/Favorites.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const ROW_CAPACITY = 6;
2323
/**
2424
* Note: These values MUST match exactly what's defined in the CSS.
2525
*/
26-
const ITEM_HEIGHT = 98;
26+
const ITEM_HEIGHT = 90;
2727
const ROW_GAP = 8;
2828

2929
/**

special-pages/pages/new-tab/app/favorites/components/PragmaticDND.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export function useItemState(url, id) {
230230
},
231231
);
232232
},
233-
getIsSticky: () => true,
233+
getIsSticky: () => false,
234234
canDrop: ({ source }) => {
235235
return source.data.instanceId === instanceId && source.data.type === 'grid-item' && source.data.id !== id;
236236
},

special-pages/pages/new-tab/app/favorites/components/Tile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function ImageLoader({ faviconSrc, faviconMax, title, url }) {
9090
return (
9191
<img
9292
src={src}
93-
className={styles.favicon}
93+
class={styles.favicon}
9494
alt={`favicon for ${title}`}
9595
onLoad={imgLoaded}
9696
onError={imgError}
@@ -122,8 +122,8 @@ export function Placeholder() {
122122
const id = useId();
123123
const { state, ref } = useItemState(`PLACEHOLDER-URL-${id}`, `PLACEHOLDER-ID-${id}`);
124124
return (
125-
<div className={styles.item} ref={ref} data-edge={'closestEdge' in state && state.closestEdge}>
126-
<div className={cn(styles.icon, styles.placeholder)} />
125+
<div class={styles.item} ref={ref} data-edge={'closestEdge' in state && state.closestEdge}>
126+
<div class={cn(styles.icon, styles.placeholder)} />
127127
{state.type === 'is-dragging-over' && state.closestEdge ? <div class={styles.dropper} data-edge={state.closestEdge} /> : null}
128128
</div>
129129
);

special-pages/pages/new-tab/app/favorites/components/Tile.module.css

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
.item {
2-
display: grid;
3-
grid-row-gap: calc(6 * var(--px-in-rem));
4-
align-content: center;
5-
justify-content: center;
2+
display: block;
63
position: relative;
74
text-decoration: none;
85
color: currentColor;
9-
padding-inline: var(--sp-3);
106
outline: none;
7+
padding-left: var(--sp-3);
8+
padding-right: var(--sp-3);
119

1210
&:focus-visible .icon {
1311
box-shadow: var(--focus-ring);
@@ -33,6 +31,7 @@
3331
justify-items: center;
3432
width: 4rem;
3533
height: 4rem;
34+
margin-bottom: 4px;
3635
border-radius: var(--border-radius-lg);
3736
}
3837

@@ -92,9 +91,8 @@
9291
.text {
9392
text-align: center;
9493
font-size: calc(10 * var(--px-in-rem));
95-
line-height: calc(13 * var(--px-in-rem));
94+
line-height: 1.1;
9695
font-weight: 400;
97-
min-height: 2.8em;
9896
overflow: hidden;
9997
text-overflow: ellipsis;
10098
line-clamp: 2;

special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.module.css

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
grid-template-columns: 1.5rem auto 2rem;
2727
grid-column-gap: var(--sp-2);
2828
grid-row-gap: var(--sp-1);
29-
grid-template-rows: auto;
30-
grid-template-areas: 'icon title expander';
31-
}
32-
.heading:has(.subtitle) {
3329
grid-template-rows: auto auto;
3430
grid-template-areas:
3531
'icon title expander'
3632
'empty label label';
3733
}
34+
3835
.headingIcon {
3936
grid-area: icon;
4037
width: 1.5rem;

0 commit comments

Comments
 (0)