@jswork/react-pwa-promotion 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -6
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +22 -24
- package/dist/index.d.ts +22 -24
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/style.css +1 -2
- package/package.json +13 -15
- package/src/index.tsx +67 -78
- package/src/style.css +135 -0
- package/dist/style.css.map +0 -1
- package/dist/style.scss +0 -48
- package/global.d.ts +0 -3
- package/src/style.scss +0 -48
package/README.md
CHANGED
|
@@ -1,12 +1,91 @@
|
|
|
1
|
-
# react-pwa-promotion
|
|
2
|
-
>
|
|
1
|
+
# @jswork/react-pwa-promotion
|
|
2
|
+
> React PWA 版本升级提示组件(纯 UI,不绑定构建工具)。
|
|
3
|
+
|
|
4
|
+
## 安装
|
|
3
5
|
|
|
4
|
-
## installation
|
|
5
6
|
```shell
|
|
6
|
-
|
|
7
|
+
pnpm add @jswork/react-pwa-promotion
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
样式是独立文件,在入口引入一次:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import '@jswork/react-pwa-promotion/dist/style.css';
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 构建
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
pnpm build
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- `tsup` → `dist/index.cjs.js` / `dist/index.esm.js` / `dist/index.d.ts`
|
|
23
|
+
- `@jswork/tsup-plugin-lightningcss`(挂在配置 `esbuildPlugins` 上)→ 构建结束时用 [Lightning CSS](https://lightningcss.dev/) 把 `src/style.css` 压缩并按 targets 降级,输出 `dist/style.css`
|
|
24
|
+
|
|
25
|
+
插件已抽成独立仓库 `/Users/afei/github/tsup-plugin-lightningcss`,本包用 `link:../../../tsup-plugin-lightningcss` 做本地联调;插件发布到 npm 后把依赖改成版本号即可。可选参数:`entry`、`outFile`、`targets`、`minify`、`silent`,输出目录自动跟随 tsup 的 `outDir`。
|
|
26
|
+
|
|
27
|
+
`src/style.css` 用**原生 CSS Nesting** 写(嵌套更好维护),构建时按 targets 展开成扁平选择器,产物不依赖浏览器对 nesting 的支持。注意写法遵循 CSS Nesting 规范(`& .xxx` / `&.xxx`),不是 Sass 的 `&__xxx` 后缀拼接。
|
|
28
|
+
|
|
29
|
+
组件本身不往 DOM 注入 `<style>`,样式完全由 CSS 文件控制。
|
|
30
|
+
|
|
31
|
+
## 配合 vite-plugin-pwa
|
|
32
|
+
|
|
33
|
+
`vite.config.ts`:
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { VitePWA } from 'vite-plugin-pwa';
|
|
37
|
+
|
|
38
|
+
export default defineConfig({
|
|
39
|
+
plugins: [
|
|
40
|
+
react(),
|
|
41
|
+
VitePWA({ registerType: 'prompt', injectRegister: null })
|
|
42
|
+
]
|
|
43
|
+
});
|
|
7
44
|
```
|
|
8
45
|
|
|
9
|
-
|
|
46
|
+
`src/vite-env.d.ts` 加一行:
|
|
47
|
+
|
|
10
48
|
```ts
|
|
11
|
-
/// <reference types="
|
|
49
|
+
/// <reference types="vite-plugin-pwa/client" />
|
|
12
50
|
```
|
|
51
|
+
|
|
52
|
+
`App.tsx`:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { useRegisterSW } from 'virtual:pwa-register/react';
|
|
56
|
+
import PwaUpdatePrompt from '@jswork/react-pwa-promotion';
|
|
57
|
+
|
|
58
|
+
export default function App() {
|
|
59
|
+
const {
|
|
60
|
+
needRefresh: [needRefresh, setNeedRefresh],
|
|
61
|
+
updateServiceWorker
|
|
62
|
+
} = useRegisterSW();
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<PwaUpdatePrompt
|
|
66
|
+
open={needRefresh}
|
|
67
|
+
onUpdate={() => void updateServiceWorker(true)}
|
|
68
|
+
onDismiss={() => setNeedRefresh(false)}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Props
|
|
75
|
+
|
|
76
|
+
| 名称 | 类型 | 默认值 | 说明 |
|
|
77
|
+
| --- | --- | --- | --- |
|
|
78
|
+
| `open` | `boolean` | — | 是否有新版本待更新,由宿主 SW 状态提供 |
|
|
79
|
+
| `onUpdate` | `() => void` | — | 点击「立即更新」,宿主负责让新 SW 接管并刷新 |
|
|
80
|
+
| `onDismiss` | `() => void` | — | 点击「稍后」 |
|
|
81
|
+
| `position` | `PwaUpdatePosition \| CSSProperties` | `'bottom-right'` | 四角,或传样式对象自定义坐标 |
|
|
82
|
+
| `className` | `string` | — | 追加根类名 |
|
|
83
|
+
| `texts` | `Partial<PwaUpdateTexts>` | 中文 | 覆盖标题 / 描述 / 两个按钮文案 |
|
|
84
|
+
|
|
85
|
+
`PwaUpdatePosition` = `'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'`。
|
|
86
|
+
|
|
87
|
+
## 特性
|
|
88
|
+
|
|
89
|
+
- 240px 紧凑卡片、无圆角、小按钮;按钮带 hover / 按下 / 键盘焦点反馈
|
|
90
|
+
- 自带入场动画,并尊重 `prefers-reduced-motion`
|
|
91
|
+
- 不依赖 `vite-plugin-pwa`,非 Vite 项目也可以自己控制 `open` 使用
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var u=Object.defineProperty;var p=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var d=(i,t,e)=>t in i?u(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,n=(i,t)=>{for(var e in t||(t={}))_.call(t,e)&&d(i,e,t[e]);if(p)for(var e of p(t))b.call(t,e)&&d(i,e,t[e]);return i};var _jsxruntime = require('react/jsx-runtime');var s="react-pwa-promotion",f={title:"\u53D1\u73B0\u65B0\u7248\u672C",description:"\u65B0\u7248\u672C\u5DF2\u5C31\u7EEA\uFF0C\u5237\u65B0\u5373\u53EF\u4F7F\u7528\u3002",update:"\u7ACB\u5373\u66F4\u65B0",dismiss:"\u7A0D\u540E"};function g({open:i,onUpdate:t,onDismiss:e,position:a="top-right",className:c,texts:m}){if(!i)return null;let o=n(n({},f),m),P=[s,typeof a=="string"?`${s}--${a}`:"",c].filter(Boolean).join(" ");return _jsxruntime.jsxs.call(void 0, "div",{className:P,style:typeof a=="string"?void 0:a,role:"dialog","aria-live":"polite","aria-label":o.title,children:[_jsxruntime.jsx.call(void 0, "div",{className:`${s}__title`,children:o.title}),_jsxruntime.jsx.call(void 0, "div",{className:`${s}__desc`,children:o.description}),_jsxruntime.jsxs.call(void 0, "div",{className:`${s}__actions`,children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`${s}__btn ${s}__btn--ghost`,onClick:e,children:o.dismiss}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:`${s}__btn ${s}__btn--primary`,onClick:t,children:o.update})]})]})}exports.default = g;
|
|
2
2
|
|
|
3
3
|
module.exports = exports.default;
|
|
4
4
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["jsx","jsxs","CLASS_NAME","defaultTexts","PwaUpdatePrompt","open","onUpdate","onDismiss","position","className","texts","t","__spreadValues","classes"],"mappings":"yVA2DM,cAAAA,EAEA,QAAAC,MAFA,oBAlCN,IAAMC,EAAa,sBAEbC,EAA+B,CACnC,MAAO,iCACP,YAAa,uFACb,OAAQ,2BACR,QAAS,cACX,EAIe,SAARC,EAAiC,CACtC,KAAAC,EACA,SAAAC,EACA,UAAAC,EACA,SAAAC,EAAW,YACX,UAAAC,EACA,MAAAC,CACF,EAAyB,CACvB,GAAI,CAACL,EAAM,OAAO,KAElB,IAAMM,EAAIC,IAAA,GAAKT,GAAiBO,GAE1BG,EAAU,CAACX,EADF,OAAOM,GAAa,SACG,GAAGN,CAAU,KAAKM,CAAQ,GAAK,GAAIC,CAAS,EAC/E,OAAO,OAAO,EACd,KAAK,GAAG,EAEX,OACER,EAAC,OACC,UAAWY,EACX,MAAO,OAAOL,GAAa,SAAW,OAAYA,EAClD,KAAK,SACL,YAAU,SACV,aAAYG,EAAE,MACd,UAAAX,EAAC,OAAI,UAAW,GAAGE,CAAU,UAAY,SAAAS,EAAE,MAAM,EACjDX,EAAC,OAAI,UAAW,GAAGE,CAAU,SAAW,SAAAS,EAAE,YAAY,EACtDV,EAAC,OAAI,UAAW,GAAGC,CAAU,YAC3B,UAAAF,EAAC,UACC,KAAK,SACL,UAAW,GAAGE,CAAU,SAASA,CAAU,eAC3C,QAASK,EACR,SAAAI,EAAE,QACL,EACAX,EAAC,UACC,KAAK,SACL,UAAW,GAAGE,CAAU,SAASA,CAAU,iBAC3C,QAASI,EACR,SAAAK,EAAE,OACL,GACF,GACF,CAEJ","sourcesContent":["import type { CSSProperties } from 'react';\n\nexport type PwaUpdatePosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n\nexport type PwaUpdateTexts = {\n title: string;\n description: string;\n update: string;\n dismiss: string;\n};\n\nexport interface PwaUpdatePromptProps {\n /** 是否有新版本待更新,由宿主的 Service Worker 状态提供 */\n open: boolean;\n /** 点击「立即更新」:宿主负责让新 SW 接管并刷新页面 */\n onUpdate: () => void;\n /** 点击「稍后」 */\n onDismiss: () => void;\n /** 四个角,或传样式对象自定义坐标(如 { left: 40, top: 40 }) */\n position?: PwaUpdatePosition | CSSProperties;\n className?: string;\n /** 覆盖默认中文文案 */\n texts?: Partial<PwaUpdateTexts>;\n}\n\nconst CLASS_NAME = 'react-pwa-promotion';\n\nconst defaultTexts: PwaUpdateTexts = {\n title: '发现新版本',\n description: '新版本已就绪,刷新即可使用。',\n update: '立即更新',\n dismiss: '稍后'\n};\n\n// 样式独立在 src/style.css(构建时用 Lightning CSS 编译到 dist/style.css),\n// 使用方需引入一次 CSS,组件本身不往 DOM 注入 <style>。\nexport default function PwaUpdatePrompt({\n open,\n onUpdate,\n onDismiss,\n position = 'top-right',\n className,\n texts\n}: PwaUpdatePromptProps) {\n if (!open) return null;\n\n const t = { ...defaultTexts, ...texts };\n const preset = typeof position === 'string';\n const classes = [CLASS_NAME, preset ? `${CLASS_NAME}--${position}` : '', className]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div\n className={classes}\n style={typeof position === 'string' ? undefined : position}\n role=\"dialog\"\n aria-live=\"polite\"\n aria-label={t.title}>\n <div className={`${CLASS_NAME}__title`}>{t.title}</div>\n <div className={`${CLASS_NAME}__desc`}>{t.description}</div>\n <div className={`${CLASS_NAME}__actions`}>\n <button\n type=\"button\"\n className={`${CLASS_NAME}__btn ${CLASS_NAME}__btn--ghost`}\n onClick={onDismiss}>\n {t.dismiss}\n </button>\n <button\n type=\"button\"\n className={`${CLASS_NAME}__btn ${CLASS_NAME}__btn--primary`}\n onClick={onUpdate}>\n {t.update}\n </button>\n </div>\n </div>\n );\n}\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
2
3
|
|
|
3
|
-
type
|
|
4
|
+
type PwaUpdatePosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
5
|
+
type PwaUpdateTexts = {
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
update: string;
|
|
9
|
+
dismiss: string;
|
|
10
|
+
};
|
|
11
|
+
interface PwaUpdatePromptProps {
|
|
12
|
+
/** 是否有新版本待更新,由宿主的 Service Worker 状态提供 */
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** 点击「立即更新」:宿主负责让新 SW 接管并刷新页面 */
|
|
15
|
+
onUpdate: () => void;
|
|
16
|
+
/** 点击「稍后」 */
|
|
17
|
+
onDismiss: () => void;
|
|
18
|
+
/** 四个角,或传样式对象自定义坐标(如 { left: 40, top: 40 }) */
|
|
19
|
+
position?: PwaUpdatePosition | CSSProperties;
|
|
4
20
|
className?: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
interval?: number;
|
|
8
|
-
mute?: boolean;
|
|
9
|
-
} & HTMLAttributes<any>;
|
|
10
|
-
declare class ReactPwaPromotion extends React.Component<ReactPwaPromotionProps> {
|
|
11
|
-
static defaultProps: {
|
|
12
|
-
lang: string;
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
interval: number;
|
|
15
|
-
mute: boolean;
|
|
16
|
-
};
|
|
17
|
-
state: {
|
|
18
|
-
needRefresh: boolean;
|
|
19
|
-
};
|
|
20
|
-
private swInstance;
|
|
21
|
-
t: (inKey: any) => any;
|
|
22
|
-
componentDidMount(): void;
|
|
23
|
-
updateServiceWorker: () => void;
|
|
24
|
-
setNeedRefresh: (needRefresh: boolean) => void;
|
|
25
|
-
render(): React.JSX.Element | null;
|
|
21
|
+
/** 覆盖默认中文文案 */
|
|
22
|
+
texts?: Partial<PwaUpdateTexts>;
|
|
26
23
|
}
|
|
24
|
+
declare function PwaUpdatePrompt({ open, onUpdate, onDismiss, position, className, texts }: PwaUpdatePromptProps): react.JSX.Element | null;
|
|
27
25
|
|
|
28
|
-
export {
|
|
26
|
+
export { type PwaUpdatePosition, type PwaUpdatePromptProps, type PwaUpdateTexts, PwaUpdatePrompt as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
2
3
|
|
|
3
|
-
type
|
|
4
|
+
type PwaUpdatePosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
5
|
+
type PwaUpdateTexts = {
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
update: string;
|
|
9
|
+
dismiss: string;
|
|
10
|
+
};
|
|
11
|
+
interface PwaUpdatePromptProps {
|
|
12
|
+
/** 是否有新版本待更新,由宿主的 Service Worker 状态提供 */
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** 点击「立即更新」:宿主负责让新 SW 接管并刷新页面 */
|
|
15
|
+
onUpdate: () => void;
|
|
16
|
+
/** 点击「稍后」 */
|
|
17
|
+
onDismiss: () => void;
|
|
18
|
+
/** 四个角,或传样式对象自定义坐标(如 { left: 40, top: 40 }) */
|
|
19
|
+
position?: PwaUpdatePosition | CSSProperties;
|
|
4
20
|
className?: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
interval?: number;
|
|
8
|
-
mute?: boolean;
|
|
9
|
-
} & HTMLAttributes<any>;
|
|
10
|
-
declare class ReactPwaPromotion extends React.Component<ReactPwaPromotionProps> {
|
|
11
|
-
static defaultProps: {
|
|
12
|
-
lang: string;
|
|
13
|
-
disabled: boolean;
|
|
14
|
-
interval: number;
|
|
15
|
-
mute: boolean;
|
|
16
|
-
};
|
|
17
|
-
state: {
|
|
18
|
-
needRefresh: boolean;
|
|
19
|
-
};
|
|
20
|
-
private swInstance;
|
|
21
|
-
t: (inKey: any) => any;
|
|
22
|
-
componentDidMount(): void;
|
|
23
|
-
updateServiceWorker: () => void;
|
|
24
|
-
setNeedRefresh: (needRefresh: boolean) => void;
|
|
25
|
-
render(): React.JSX.Element | null;
|
|
21
|
+
/** 覆盖默认中文文案 */
|
|
22
|
+
texts?: Partial<PwaUpdateTexts>;
|
|
26
23
|
}
|
|
24
|
+
declare function PwaUpdatePrompt({ open, onUpdate, onDismiss, position, className, texts }: PwaUpdatePromptProps): react.JSX.Element | null;
|
|
27
25
|
|
|
28
|
-
export
|
|
26
|
+
export { type PwaUpdatePosition, type PwaUpdatePromptProps, type PwaUpdateTexts, PwaUpdatePrompt as default };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var u=Object.defineProperty;var p=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var d=(i,t,e)=>t in i?u(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,n=(i,t)=>{for(var e in t||(t={}))_.call(t,e)&&d(i,e,t[e]);if(p)for(var e of p(t))b.call(t,e)&&d(i,e,t[e]);return i};import{jsx as r,jsxs as l}from"react/jsx-runtime";var s="react-pwa-promotion",f={title:"\u53D1\u73B0\u65B0\u7248\u672C",description:"\u65B0\u7248\u672C\u5DF2\u5C31\u7EEA\uFF0C\u5237\u65B0\u5373\u53EF\u4F7F\u7528\u3002",update:"\u7ACB\u5373\u66F4\u65B0",dismiss:"\u7A0D\u540E"};function g({open:i,onUpdate:t,onDismiss:e,position:a="top-right",className:c,texts:m}){if(!i)return null;let o=n(n({},f),m),P=[s,typeof a=="string"?`${s}--${a}`:"",c].filter(Boolean).join(" ");return l("div",{className:P,style:typeof a=="string"?void 0:a,role:"dialog","aria-live":"polite","aria-label":o.title,children:[r("div",{className:`${s}__title`,children:o.title}),r("div",{className:`${s}__desc`,children:o.description}),l("div",{className:`${s}__actions`,children:[r("button",{type:"button",className:`${s}__btn ${s}__btn--ghost`,onClick:e,children:o.dismiss}),r("button",{type:"button",className:`${s}__btn ${s}__btn--primary`,onClick:t,children:o.update})]})]})}export{g as default};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"sourcesContent":["import type { CSSProperties } from 'react';\n\nexport type PwaUpdatePosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\n\nexport type PwaUpdateTexts = {\n title: string;\n description: string;\n update: string;\n dismiss: string;\n};\n\nexport interface PwaUpdatePromptProps {\n /** 是否有新版本待更新,由宿主的 Service Worker 状态提供 */\n open: boolean;\n /** 点击「立即更新」:宿主负责让新 SW 接管并刷新页面 */\n onUpdate: () => void;\n /** 点击「稍后」 */\n onDismiss: () => void;\n /** 四个角,或传样式对象自定义坐标(如 { left: 40, top: 40 }) */\n position?: PwaUpdatePosition | CSSProperties;\n className?: string;\n /** 覆盖默认中文文案 */\n texts?: Partial<PwaUpdateTexts>;\n}\n\nconst CLASS_NAME = 'react-pwa-promotion';\n\nconst defaultTexts: PwaUpdateTexts = {\n title: '发现新版本',\n description: '新版本已就绪,刷新即可使用。',\n update: '立即更新',\n dismiss: '稍后'\n};\n\n// 样式独立在 src/style.css(构建时用 Lightning CSS 编译到 dist/style.css),\n// 使用方需引入一次 CSS,组件本身不往 DOM 注入 <style>。\nexport default function PwaUpdatePrompt({\n open,\n onUpdate,\n onDismiss,\n position = 'top-right',\n className,\n texts\n}: PwaUpdatePromptProps) {\n if (!open) return null;\n\n const t = { ...defaultTexts, ...texts };\n const preset = typeof position === 'string';\n const classes = [CLASS_NAME, preset ? `${CLASS_NAME}--${position}` : '', className]\n .filter(Boolean)\n .join(' ');\n\n return (\n <div\n className={classes}\n style={typeof position === 'string' ? undefined : position}\n role=\"dialog\"\n aria-live=\"polite\"\n aria-label={t.title}>\n <div className={`${CLASS_NAME}__title`}>{t.title}</div>\n <div className={`${CLASS_NAME}__desc`}>{t.description}</div>\n <div className={`${CLASS_NAME}__actions`}>\n <button\n type=\"button\"\n className={`${CLASS_NAME}__btn ${CLASS_NAME}__btn--ghost`}\n onClick={onDismiss}>\n {t.dismiss}\n </button>\n <button\n type=\"button\"\n className={`${CLASS_NAME}__btn ${CLASS_NAME}__btn--primary`}\n onClick={onUpdate}>\n {t.update}\n </button>\n </div>\n </div>\n );\n}\n"],"mappings":"yVA2DM,cAAAA,EAEA,QAAAC,MAFA,oBAlCN,IAAMC,EAAa,sBAEbC,EAA+B,CACnC,MAAO,iCACP,YAAa,uFACb,OAAQ,2BACR,QAAS,cACX,EAIe,SAARC,EAAiC,CACtC,KAAAC,EACA,SAAAC,EACA,UAAAC,EACA,SAAAC,EAAW,YACX,UAAAC,EACA,MAAAC,CACF,EAAyB,CACvB,GAAI,CAACL,EAAM,OAAO,KAElB,IAAMM,EAAIC,IAAA,GAAKT,GAAiBO,GAE1BG,EAAU,CAACX,EADF,OAAOM,GAAa,SACG,GAAGN,CAAU,KAAKM,CAAQ,GAAK,GAAIC,CAAS,EAC/E,OAAO,OAAO,EACd,KAAK,GAAG,EAEX,OACER,EAAC,OACC,UAAWY,EACX,MAAO,OAAOL,GAAa,SAAW,OAAYA,EAClD,KAAK,SACL,YAAU,SACV,aAAYG,EAAE,MACd,UAAAX,EAAC,OAAI,UAAW,GAAGE,CAAU,UAAY,SAAAS,EAAE,MAAM,EACjDX,EAAC,OAAI,UAAW,GAAGE,CAAU,SAAW,SAAAS,EAAE,YAAY,EACtDV,EAAC,OAAI,UAAW,GAAGC,CAAU,YAC3B,UAAAF,EAAC,UACC,KAAK,SACL,UAAW,GAAGE,CAAU,SAASA,CAAU,eAC3C,QAASK,EACR,SAAAI,EAAE,QACL,EACAX,EAAC,UACC,KAAK,SACL,UAAW,GAAGE,CAAU,SAASA,CAAU,iBAC3C,QAASI,EACR,SAAAK,EAAE,OACL,GACF,GACF,CAEJ","names":["jsx","jsxs","CLASS_NAME","defaultTexts","PwaUpdatePrompt","open","onUpdate","onDismiss","position","className","texts","t","__spreadValues","classes"]}
|
package/dist/style.css
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
.react-pwa-promotion{
|
|
2
|
-
/*# sourceMappingURL=src/style.scss.map */
|
|
1
|
+
.react-pwa-promotion{--rpwa-bg:#fff;--rpwa-color:#111827;--rpwa-muted:#6b7280;--rpwa-border:#e5e7eb;--rpwa-radius:8px;--rpwa-radius-sm:4px;--rpwa-shadow:0 8px 24px #0000001f;--rpwa-accent:#6366f1;--rpwa-btn-ghost-bg:#fff;--rpwa-btn-ghost-color:#374151;--rpwa-btn-ghost-bg-hover:#f3f4f6;--rpwa-btn-primary-bg:#111827;--rpwa-btn-primary-color:#fff;--rpwa-btn-primary-bg-hover:#374151;z-index:9999;box-sizing:border-box;border-radius:var(--rpwa-radius);border:1px solid var(--rpwa-border);background:var(--rpwa-bg);width:240px;color:var(--rpwa-color);box-shadow:var(--rpwa-shadow);padding:8px 12px;font:12px/1.35 system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;animation:.18s ease-out both react-pwa-promotion-in;position:fixed}.react-pwa-promotion.react-pwa-promotion--bottom-right{bottom:16px;right:16px}.react-pwa-promotion.react-pwa-promotion--bottom-left{bottom:16px;left:16px}.react-pwa-promotion.react-pwa-promotion--top-right{animation-name:react-pwa-promotion-in-top;top:16px;right:16px}.react-pwa-promotion.react-pwa-promotion--top-left{animation-name:react-pwa-promotion-in-top;top:16px;left:16px}.react-pwa-promotion .react-pwa-promotion__title{margin-bottom:2px;font-size:13px;font-weight:600}.react-pwa-promotion .react-pwa-promotion__desc{color:var(--rpwa-muted);margin-bottom:6px}.react-pwa-promotion .react-pwa-promotion__actions{justify-content:flex-end;gap:4px;display:flex}.react-pwa-promotion .react-pwa-promotion__actions .react-pwa-promotion__btn{border-radius:var(--rpwa-radius-sm);font:inherit;cursor:pointer;padding:3px 8px;font-size:11px;transition:background .15s,border-color .15s,color .15s,box-shadow .15s,transform .15s}.react-pwa-promotion .react-pwa-promotion__actions .react-pwa-promotion__btn:active{transform:translateY(1px)}.react-pwa-promotion .react-pwa-promotion__actions .react-pwa-promotion__btn:focus-visible{outline:2px solid var(--rpwa-accent);outline-offset:2px}.react-pwa-promotion .react-pwa-promotion__actions .react-pwa-promotion__btn.react-pwa-promotion__btn--ghost{border:1px solid var(--rpwa-border);background:var(--rpwa-btn-ghost-bg);color:var(--rpwa-btn-ghost-color)}.react-pwa-promotion .react-pwa-promotion__actions .react-pwa-promotion__btn.react-pwa-promotion__btn--ghost:hover{background:var(--rpwa-btn-ghost-bg-hover);color:var(--rpwa-color);border-color:#d1d5db}.react-pwa-promotion .react-pwa-promotion__actions .react-pwa-promotion__btn.react-pwa-promotion__btn--primary{border:1px solid var(--rpwa-btn-primary-bg);background:var(--rpwa-btn-primary-bg);color:var(--rpwa-btn-primary-color)}.react-pwa-promotion .react-pwa-promotion__actions .react-pwa-promotion__btn.react-pwa-promotion__btn--primary:hover{background:var(--rpwa-btn-primary-bg-hover);border-color:var(--rpwa-btn-primary-bg-hover);box-shadow:0 3px 10px #11182740}@media (prefers-reduced-motion:reduce){.react-pwa-promotion{animation:none}.react-pwa-promotion .react-pwa-promotion__btn{transition:none}}@keyframes react-pwa-promotion-in{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}@keyframes react-pwa-promotion-in-top{0%{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:none}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jswork/react-pwa-promotion",
|
|
3
|
-
"description": "A
|
|
4
|
-
"version": "1.0.
|
|
3
|
+
"description": "A tiny React update prompt for Vite PWA (vite-plugin-pwa).",
|
|
4
|
+
"version": "1.0.16",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -9,36 +9,34 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsup",
|
|
12
|
-
"postbuild": "postsass -s src/style.scss -d dist/style.css -c",
|
|
13
12
|
"release": "release-it --ci --npm.skipChecks"
|
|
14
13
|
},
|
|
15
14
|
"devDependencies": {
|
|
16
|
-
"@
|
|
15
|
+
"@jswork/tsup-plugin-lightningcss": "link:../../../tsup-plugin-lightningcss",
|
|
16
|
+
"@types/node": "^20.11.0",
|
|
17
17
|
"@types/react": "^18.2.28",
|
|
18
18
|
"@types/react-dom": "^18.2.13",
|
|
19
|
-
"
|
|
20
|
-
"cssnano": "^6.0.1",
|
|
21
|
-
"prettier": "^3.2.4",
|
|
19
|
+
"lightningcss": "^1.33.0",
|
|
22
20
|
"react": "^18.2.0",
|
|
23
21
|
"react-dom": "^18.2.0",
|
|
24
22
|
"tsup": "^7.2.0",
|
|
25
23
|
"typescript": "^5.2.2"
|
|
26
24
|
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": ">=18",
|
|
27
|
+
"react-dom": ">=18"
|
|
28
|
+
},
|
|
27
29
|
"publishConfig": {
|
|
28
30
|
"access": "public",
|
|
29
31
|
"registry": "https://registry.npmjs.org"
|
|
30
32
|
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@jswork/sw-runtime": "^1.0.10",
|
|
33
|
-
"classnames": "^2.5.1"
|
|
34
|
-
},
|
|
35
33
|
"keywords": [
|
|
36
34
|
"component",
|
|
37
35
|
"pwa",
|
|
38
36
|
"react",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
37
|
+
"vite",
|
|
38
|
+
"vite-plugin-pwa",
|
|
39
|
+
"serviceworker",
|
|
40
|
+
"update"
|
|
43
41
|
]
|
|
44
42
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,89 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
import cx from 'classnames';
|
|
3
|
-
import SwRuntime from '@jswork/sw-runtime';
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'zh-CN': {
|
|
13
|
-
'update-available': '有新内容可用,点击重新加载按钮更新。',
|
|
14
|
-
'reload': '⚡️ 重新加载',
|
|
15
|
-
'close': '🧨 关闭',
|
|
16
|
-
},
|
|
3
|
+
export type PwaUpdatePosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
4
|
+
|
|
5
|
+
export type PwaUpdateTexts = {
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
update: string;
|
|
9
|
+
dismiss: string;
|
|
17
10
|
};
|
|
18
11
|
|
|
19
|
-
|
|
12
|
+
export interface PwaUpdatePromptProps {
|
|
13
|
+
/** 是否有新版本待更新,由宿主的 Service Worker 状态提供 */
|
|
14
|
+
open: boolean;
|
|
15
|
+
/** 点击「立即更新」:宿主负责让新 SW 接管并刷新页面 */
|
|
16
|
+
onUpdate: () => void;
|
|
17
|
+
/** 点击「稍后」 */
|
|
18
|
+
onDismiss: () => void;
|
|
19
|
+
/** 四个角,或传样式对象自定义坐标(如 { left: 40, top: 40 }) */
|
|
20
|
+
position?: PwaUpdatePosition | CSSProperties;
|
|
20
21
|
className?: string;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
mute?: boolean;
|
|
25
|
-
} & HTMLAttributes<any>;
|
|
26
|
-
|
|
27
|
-
export default class ReactPwaPromotion extends React.Component<ReactPwaPromotionProps> {
|
|
28
|
-
static defaultProps = {
|
|
29
|
-
lang: 'en-US',
|
|
30
|
-
disabled: false,
|
|
31
|
-
interval: 20 * 1000,
|
|
32
|
-
mute: false,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
state = {
|
|
36
|
-
needRefresh: false,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
private swInstance: any;
|
|
40
|
-
|
|
41
|
-
t = (inKey) => {
|
|
42
|
-
const { lang } = this.props;
|
|
43
|
-
return locals[lang!][inKey] || inKey;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
componentDidMount() {
|
|
47
|
-
const { disabled, interval, mute } = this.props;
|
|
48
|
-
this.swInstance = SwRuntime.install({
|
|
49
|
-
autoUpdate: true,
|
|
50
|
-
disabled,
|
|
51
|
-
autoUpdateInterval: interval,
|
|
52
|
-
onAutoUpdate: function () {
|
|
53
|
-
if (mute) return;
|
|
54
|
-
console.log('SW Event: onAutoUpdate');
|
|
55
|
-
},
|
|
56
|
-
onUpdateReady: () => {
|
|
57
|
-
this.setNeedRefresh(true);
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
}
|
|
22
|
+
/** 覆盖默认中文文案 */
|
|
23
|
+
texts?: Partial<PwaUpdateTexts>;
|
|
24
|
+
}
|
|
61
25
|
|
|
62
|
-
|
|
63
|
-
this.swInstance.applyUpdate().then(() => {
|
|
64
|
-
this.setNeedRefresh(false);
|
|
65
|
-
window.location.reload();
|
|
66
|
-
});
|
|
67
|
-
};
|
|
26
|
+
const CLASS_NAME = 'react-pwa-promotion';
|
|
68
27
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
28
|
+
const defaultTexts: PwaUpdateTexts = {
|
|
29
|
+
title: '发现新版本',
|
|
30
|
+
description: '新版本已就绪,刷新即可使用。',
|
|
31
|
+
update: '立即更新',
|
|
32
|
+
dismiss: '稍后'
|
|
33
|
+
};
|
|
72
34
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
35
|
+
// 样式独立在 src/style.css(构建时用 Lightning CSS 编译到 dist/style.css),
|
|
36
|
+
// 使用方需引入一次 CSS,组件本身不往 DOM 注入 <style>。
|
|
37
|
+
export default function PwaUpdatePrompt({
|
|
38
|
+
open,
|
|
39
|
+
onUpdate,
|
|
40
|
+
onDismiss,
|
|
41
|
+
position = 'top-right',
|
|
42
|
+
className,
|
|
43
|
+
texts
|
|
44
|
+
}: PwaUpdatePromptProps) {
|
|
45
|
+
if (!open) return null;
|
|
76
46
|
|
|
77
|
-
|
|
47
|
+
const t = { ...defaultTexts, ...texts };
|
|
48
|
+
const preset = typeof position === 'string';
|
|
49
|
+
const classes = [CLASS_NAME, preset ? `${CLASS_NAME}--${position}` : '', className]
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
.join(' ');
|
|
78
52
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
className={classes}
|
|
56
|
+
style={typeof position === 'string' ? undefined : position}
|
|
57
|
+
role="dialog"
|
|
58
|
+
aria-live="polite"
|
|
59
|
+
aria-label={t.title}>
|
|
60
|
+
<div className={`${CLASS_NAME}__title`}>{t.title}</div>
|
|
61
|
+
<div className={`${CLASS_NAME}__desc`}>{t.description}</div>
|
|
62
|
+
<div className={`${CLASS_NAME}__actions`}>
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
className={`${CLASS_NAME}__btn ${CLASS_NAME}__btn--ghost`}
|
|
66
|
+
onClick={onDismiss}>
|
|
67
|
+
{t.dismiss}
|
|
68
|
+
</button>
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
className={`${CLASS_NAME}__btn ${CLASS_NAME}__btn--primary`}
|
|
72
|
+
onClick={onUpdate}>
|
|
73
|
+
{t.update}
|
|
74
|
+
</button>
|
|
86
75
|
</div>
|
|
87
|
-
|
|
88
|
-
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
89
78
|
}
|
package/src/style.css
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* 源码用原生 CSS Nesting 组织,构建时由 Lightning CSS 按 targets 展开成扁平选择器。
|
|
2
|
+
注意:这里不能用 Sass 风格的 &__xxx 后缀拼接(Lightning CSS 不支持)。
|
|
3
|
+
主题定制:覆盖 .react-pwa-promotion 上的 --rpwa-* 变量即可。 */
|
|
4
|
+
|
|
5
|
+
.react-pwa-promotion {
|
|
6
|
+
/* 主题变量 */
|
|
7
|
+
--rpwa-bg: #fff;
|
|
8
|
+
--rpwa-color: #111827;
|
|
9
|
+
--rpwa-muted: #6b7280;
|
|
10
|
+
--rpwa-border: #e5e7eb;
|
|
11
|
+
--rpwa-radius: 8px;
|
|
12
|
+
--rpwa-radius-sm: 4px;
|
|
13
|
+
--rpwa-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
|
14
|
+
--rpwa-accent: #6366f1;
|
|
15
|
+
--rpwa-btn-ghost-bg: #fff;
|
|
16
|
+
--rpwa-btn-ghost-color: #374151;
|
|
17
|
+
--rpwa-btn-ghost-bg-hover: #f3f4f6;
|
|
18
|
+
--rpwa-btn-primary-bg: #111827;
|
|
19
|
+
--rpwa-btn-primary-color: #fff;
|
|
20
|
+
--rpwa-btn-primary-bg-hover: #374151;
|
|
21
|
+
|
|
22
|
+
position: fixed;
|
|
23
|
+
z-index: 9999;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
width: 240px;
|
|
26
|
+
padding: 8px 12px;
|
|
27
|
+
border-radius: var(--rpwa-radius);
|
|
28
|
+
border: 1px solid var(--rpwa-border);
|
|
29
|
+
background: var(--rpwa-bg);
|
|
30
|
+
color: var(--rpwa-color);
|
|
31
|
+
box-shadow: var(--rpwa-shadow);
|
|
32
|
+
font: 12px/1.35 system-ui, sans-serif;
|
|
33
|
+
animation: react-pwa-promotion-in 0.18s ease-out both;
|
|
34
|
+
|
|
35
|
+
/* 位置变体:& 后接完整类选择器,展开后根类与变体类同时命中 */
|
|
36
|
+
&.react-pwa-promotion--bottom-right {
|
|
37
|
+
right: 16px;
|
|
38
|
+
bottom: 16px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.react-pwa-promotion--bottom-left {
|
|
42
|
+
left: 16px;
|
|
43
|
+
bottom: 16px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.react-pwa-promotion--top-right {
|
|
47
|
+
right: 16px;
|
|
48
|
+
top: 16px;
|
|
49
|
+
animation-name: react-pwa-promotion-in-top;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&.react-pwa-promotion--top-left {
|
|
53
|
+
left: 16px;
|
|
54
|
+
top: 16px;
|
|
55
|
+
animation-name: react-pwa-promotion-in-top;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
& .react-pwa-promotion__title {
|
|
59
|
+
font-size: 13px;
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
margin-bottom: 2px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
& .react-pwa-promotion__desc {
|
|
65
|
+
color: var(--rpwa-muted);
|
|
66
|
+
margin-bottom: 6px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
& .react-pwa-promotion__actions {
|
|
70
|
+
display: flex;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
justify-content: flex-end;
|
|
73
|
+
|
|
74
|
+
& .react-pwa-promotion__btn {
|
|
75
|
+
padding: 3px 8px;
|
|
76
|
+
border-radius: var(--rpwa-radius-sm);
|
|
77
|
+
font: inherit;
|
|
78
|
+
font-size: 11px;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s,
|
|
81
|
+
transform 0.15s;
|
|
82
|
+
|
|
83
|
+
&:active {
|
|
84
|
+
transform: translateY(1px);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&:focus-visible {
|
|
88
|
+
outline: 2px solid var(--rpwa-accent);
|
|
89
|
+
outline-offset: 2px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&.react-pwa-promotion__btn--ghost {
|
|
93
|
+
border: 1px solid var(--rpwa-border);
|
|
94
|
+
background: var(--rpwa-btn-ghost-bg);
|
|
95
|
+
color: var(--rpwa-btn-ghost-color);
|
|
96
|
+
|
|
97
|
+
&:hover {
|
|
98
|
+
background: var(--rpwa-btn-ghost-bg-hover);
|
|
99
|
+
border-color: #d1d5db;
|
|
100
|
+
color: var(--rpwa-color);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&.react-pwa-promotion__btn--primary {
|
|
105
|
+
border: 1px solid var(--rpwa-btn-primary-bg);
|
|
106
|
+
background: var(--rpwa-btn-primary-bg);
|
|
107
|
+
color: var(--rpwa-btn-primary-color);
|
|
108
|
+
|
|
109
|
+
&:hover {
|
|
110
|
+
background: var(--rpwa-btn-primary-bg-hover);
|
|
111
|
+
border-color: var(--rpwa-btn-primary-bg-hover);
|
|
112
|
+
box-shadow: 0 3px 10px rgba(17, 24, 39, 0.25);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@media (prefers-reduced-motion: reduce) {
|
|
119
|
+
animation: none;
|
|
120
|
+
|
|
121
|
+
& .react-pwa-promotion__btn {
|
|
122
|
+
transition: none;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@keyframes react-pwa-promotion-in {
|
|
128
|
+
from { opacity: 0; transform: translateY(6px); }
|
|
129
|
+
to { opacity: 1; transform: none; }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@keyframes react-pwa-promotion-in-top {
|
|
133
|
+
from { opacity: 0; transform: translateY(-6px); }
|
|
134
|
+
to { opacity: 1; transform: none; }
|
|
135
|
+
}
|
package/dist/style.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["src/style.scss"],"names":[],"mappings":"AAAA,qBAYE,qBAAuB,CALvB,oCAAmD,CACnD,iBAAkB,CAGlB,6BAA8B,CAE9B,cAAe,CARf,WAAY,CAHZ,eAAgB,CAIhB,YAAa,CALb,cAAe,CAEf,OAAQ,CAOR,eAAgB,CANhB,KAAM,CAUN,kBAAoB,CALpB,aAMF,CACA,2BACE,6BACF,CACA,6BACE,kBACF,CACA,6BACE,gBACF,CACA,oCAEE,oCAAmD,CAGnD,iBAAkB,CADlB,gBAAiB,CADjB,YAAa,CAGb,gBAAiB,CALjB,kBAMF,CACA,0CAGE,8BAA6C,CAD7C,gCAA+C,CAD/C,cAGF,CACA,0CAEE,0CAAgD,CADhD,YAEF","file":"src/style.scss","sourcesContent":[".react-pwa-promotion {\n position: fixed;\n min-width: 280px;\n right: 0;\n top: 0;\n margin: 16px;\n padding: 12px;\n border: 1px solid rgba(136, 136, 136, 0.3333333333);\n border-radius: 4px;\n z-index: 10000;\n text-align: left;\n box-shadow: 3px 4px 5px 0 #eee;\n background-color: white;\n font-size: 14px;\n transition: all 0.3s;\n}\n.react-pwa-promotion:hover {\n box-shadow: 3px 4px 5px 0 #ddd;\n}\n.react-pwa-promotion__header {\n margin-bottom: 10px;\n}\n.react-pwa-promotion__footer {\n text-align: right;\n}\n.react-pwa-promotion__footer button {\n transition: all 0.2s;\n border: 1px solid rgba(136, 136, 136, 0.3333333333);\n outline: none;\n margin-right: 5px;\n border-radius: 2px;\n padding: 5px 14px;\n}\n.react-pwa-promotion__footer button:hover {\n cursor: pointer;\n border-color: rgba(136, 136, 136, 0.5333333333);\n background: rgba(136, 136, 136, 0.3333333333);\n}\n.react-pwa-promotion__footer button:focus {\n outline: none;\n box-shadow: 0 0 0 0.1rem rgba(49, 132, 253, 0.5);\n}"]}
|
package/dist/style.scss
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
.react-pwa-promotion {
|
|
2
|
-
position: fixed;
|
|
3
|
-
min-width: 280px;
|
|
4
|
-
right: 0;
|
|
5
|
-
top: 0;
|
|
6
|
-
margin: 16px;
|
|
7
|
-
padding: 12px;
|
|
8
|
-
border: 1px solid #8885;
|
|
9
|
-
border-radius: 4px;
|
|
10
|
-
z-index: 10000;
|
|
11
|
-
text-align: left;
|
|
12
|
-
box-shadow: 3px 4px 5px 0 #eee;
|
|
13
|
-
background-color: white;
|
|
14
|
-
font-size: 14px;
|
|
15
|
-
transition: all 0.3s;
|
|
16
|
-
|
|
17
|
-
&:hover {
|
|
18
|
-
box-shadow: 3px 4px 5px 0 #ddd;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&__header {
|
|
22
|
-
margin-bottom: 10px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&__footer {
|
|
26
|
-
text-align: right;
|
|
27
|
-
|
|
28
|
-
button {
|
|
29
|
-
transition: all 0.2s;
|
|
30
|
-
border: 1px solid #8885;
|
|
31
|
-
outline: none;
|
|
32
|
-
margin-right: 5px;
|
|
33
|
-
border-radius: 2px;
|
|
34
|
-
padding: 5px 14px;
|
|
35
|
-
|
|
36
|
-
&:hover {
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
border-color: #8888;
|
|
39
|
-
background: #8885;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&:focus {
|
|
43
|
-
outline: none;
|
|
44
|
-
box-shadow: 0 0 0 0.1rem rgb(49 132 253 / 50%);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
package/global.d.ts
DELETED
package/src/style.scss
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
.react-pwa-promotion {
|
|
2
|
-
position: fixed;
|
|
3
|
-
min-width: 280px;
|
|
4
|
-
right: 0;
|
|
5
|
-
top: 0;
|
|
6
|
-
margin: 16px;
|
|
7
|
-
padding: 12px;
|
|
8
|
-
border: 1px solid #8885;
|
|
9
|
-
border-radius: 4px;
|
|
10
|
-
z-index: 10000;
|
|
11
|
-
text-align: left;
|
|
12
|
-
box-shadow: 3px 4px 5px 0 #eee;
|
|
13
|
-
background-color: white;
|
|
14
|
-
font-size: 14px;
|
|
15
|
-
transition: all 0.3s;
|
|
16
|
-
|
|
17
|
-
&:hover {
|
|
18
|
-
box-shadow: 3px 4px 5px 0 #ddd;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&__header {
|
|
22
|
-
margin-bottom: 10px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&__footer {
|
|
26
|
-
text-align: right;
|
|
27
|
-
|
|
28
|
-
button {
|
|
29
|
-
transition: all 0.2s;
|
|
30
|
-
border: 1px solid #8885;
|
|
31
|
-
outline: none;
|
|
32
|
-
margin-right: 5px;
|
|
33
|
-
border-radius: 2px;
|
|
34
|
-
padding: 5px 14px;
|
|
35
|
-
|
|
36
|
-
&:hover {
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
border-color: #8888;
|
|
39
|
-
background: #8885;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
&:focus {
|
|
43
|
-
outline: none;
|
|
44
|
-
box-shadow: 0 0 0 0.1rem rgb(49 132 253 / 50%);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|