Skip to content

Commit caa3a86

Browse files
slorberclaude
andauthored
refactor(pwa): style the reload popup with its CSS module instead of Infima classes (#13139)
* refactor(pwa): style the reload popup with its CSS module instead of Infima classes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor: apply lint autofix * fix(pwa): size the reload popup with border-box, like Infima does for every element Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: slorber <749374+slorber@users.noreply.github.com>
1 parent 5b40188 commit caa3a86

6 files changed

Lines changed: 52 additions & 10 deletions

File tree

‎packages/docusaurus-plugin-pwa/package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@docusaurus/types": "workspace:*",
3131
"@docusaurus/utils": "workspace:*",
3232
"@docusaurus/utils-validation": "workspace:*",
33-
"clsx": "catalog:",
3433
"tslib": "catalog:",
3534
"webpack": "catalog:",
3635
"workbox-build": "catalog:",

‎packages/docusaurus-plugin-pwa/src/theme/PwaReloadPopup/index.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77

88
import {type ReactNode, useState} from 'react';
9-
import clsx from 'clsx';
109
import Translate, {translate} from '@docusaurus/Translate';
1110
import type {Props} from '@theme/PwaReloadPopup';
1211

@@ -17,7 +16,7 @@ export default function PwaReloadPopup({onReload}: Props): ReactNode {
1716

1817
return (
1918
isVisible && (
20-
<div className={clsx('alert', 'alert--secondary', styles.popup)}>
19+
<div className={styles.popup}>
2120
<p>
2221
<Translate
2322
id="theme.PwaReloadPopup.info"
@@ -27,7 +26,7 @@ export default function PwaReloadPopup({onReload}: Props): ReactNode {
2726
</p>
2827
<div className={styles.buttonContainer}>
2928
<button
30-
className="button button--link"
29+
className={styles.refreshButton}
3130
type="button"
3231
onClick={() => {
3332
setIsVisible(false);
@@ -47,7 +46,7 @@ export default function PwaReloadPopup({onReload}: Props): ReactNode {
4746
description:
4847
'The ARIA label for close button of PWA reload popup',
4948
})}
50-
className="close"
49+
className={styles.closeButton}
5150
type="button"
5251
onClick={() => setIsVisible(false)}>
5352
<span aria-hidden="true">×</span>

‎packages/docusaurus-plugin-pwa/src/theme/PwaReloadPopup/styles.module.css‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,33 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8+
/*
9+
The popup looks like an Infima secondary alert when the theme loads Infima,
10+
and falls back to Infima's default values otherwise.
11+
*/
12+
813
.popup {
914
position: fixed;
1015
bottom: 16px;
1116
right: 16px;
17+
box-sizing: border-box;
1218
width: 344px;
1319
display: flex;
1420
align-items: center;
1521
justify-content: space-between;
1622
z-index: 999;
23+
padding: var(--ifm-alert-padding-vertical, 1rem)
24+
var(--ifm-alert-padding-horizontal, 1rem);
25+
border: var(--ifm-alert-border-width, 0) solid
26+
var(--ifm-color-secondary-dark, rgb(212 213 216));
27+
border-left-width: var(--ifm-alert-border-left-width, 5px);
28+
border-radius: var(--ifm-alert-border-radius, 0.4rem);
29+
box-shadow: var(--ifm-alert-shadow, 0 1px 2px 0 rgb(0 0 0 / 10%));
30+
background-color: var(
31+
--ifm-color-secondary-contrast-background,
32+
rgb(253 253 254)
33+
);
34+
color: var(--ifm-color-secondary-contrast-foreground, rgb(71 71 72));
1735
}
1836

1937
.popup p {
@@ -33,7 +51,35 @@
3351
align-items: center;
3452
}
3553

36-
.buttonContainer :global(.close) {
54+
.refreshButton {
55+
padding: var(--ifm-button-padding-vertical, 0.375rem)
56+
var(--ifm-button-padding-horizontal, 1.5rem);
57+
border: var(--ifm-button-border-width, 1px) solid transparent;
58+
border-radius: var(--ifm-button-border-radius, 0.4rem);
59+
background-color: transparent;
60+
color: inherit;
61+
font-size: 0.875rem;
62+
font-weight: var(--ifm-button-font-weight, 700);
63+
line-height: 1.5;
64+
text-decoration: underline;
65+
white-space: nowrap;
66+
cursor: pointer;
67+
user-select: none;
68+
}
69+
70+
.closeButton {
3771
margin: 0;
3872
padding: 0;
73+
color: inherit;
74+
font-size: 1.5rem;
75+
font-weight: 700;
76+
line-height: 1;
77+
opacity: 0.75;
78+
transition: opacity var(--ifm-transition-fast, 200ms)
79+
var(--ifm-transition-timing-default, cubic-bezier(0.08, 0.52, 0.52, 1));
80+
}
81+
82+
.closeButton:hover,
83+
.closeButton:focus {
84+
opacity: 1;
3985
}

‎pnpm-lock.yaml‎

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎project-words.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ héllô
118118
IANAD
119119
Infima
120120
infima
121+
Infima's
121122
infimum
122123
inlines
123124
interactiveness

‎website/docs/api/plugins/plugin-pwa.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ import CodeBlock from '@theme/CodeBlock';
296296

297297
The `@theme/PwaReloadPopup` component is rendered when a new service worker is waiting to be installed, and we suggest a reload to the user. You can [swizzle](../../swizzling.mdx) this component and implement your own UI. It will receive an `onReload` callback as props, which should be called when the `reload` button is clicked. This will tell the service worker to install the waiting service worker and reload the page.
298298

299-
The default theme includes an implementation for the reload popup and uses [Infima Alerts](/infima/components/alert).
299+
The plugin includes a default implementation of the reload popup, styled like a secondary [Infima Alert](/infima/components/alert).
300300

301301
![A screen recording of the reload process. An alert box shows in the bottom right of the window, saying "New content available". After clicking the "Refresh" button, the page's main heading changes from "Introduction" to "PWA :))".](/img/pwa_reload.gif)
302302

0 commit comments

Comments
 (0)