Skip to content

Commit 3ae6f72

Browse files
committed
feat(plugin-pwa-popup): add more css variables
- refactor: extract css vars to a separate file
1 parent 6197578 commit 3ae6f72

File tree

7 files changed

+40
-19
lines changed

7 files changed

+40
-19
lines changed

docs/reference/plugin/pwa-popup.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,4 @@ module.exports = {
5252

5353
You can customize the style of the popup via CSS variables:
5454

55-
```css
56-
:root {
57-
--pwa-popup-color: #3eaf7c;
58-
}
59-
```
55+
@[code css](@vuepress/plugin-pwa-popup/src/client/styles/vars.css)

docs/zh/reference/plugin/pwa-popup.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,4 @@ module.exports = {
5252

5353
你可以通过 CSS 变量来自定义弹窗的样式:
5454

55-
```css
56-
:root {
57-
--pwa-popup-color: #3eaf7c;
58-
}
59-
```
55+
@[code css](@vuepress/plugin-pwa-popup/src/client/styles/vars.css)

packages/@vuepress/plugin-pwa-popup/src/client/components/PwaPopup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { useRouteLocale } from '@vuepress/client'
44
import { usePwaEvent, useSkipWaiting } from '@vuepress/plugin-pwa/lib/client'
55
import type { LocaleConfig } from '@vuepress/shared'
66

7-
import './PwaPopup.css'
7+
import '../styles/vars.css'
8+
import '../styles/pwa-popup.css'
89

910
export type PwaPopupLocales = LocaleConfig<{
1011
message: string
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './components/PwaPopup'
2+
export * from './components/PwaPopupWrapper'

packages/@vuepress/plugin-pwa-popup/src/client/components/PwaPopup.css renamed to packages/@vuepress/plugin-pwa-popup/src/client/styles/pwa-popup.css

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
:root {
2-
--pwa-popup-color: #3eaf7c;
3-
}
4-
51
.pwa-popup {
62
position: fixed;
73
right: 1em;
84
bottom: 1em;
95
padding: 1em;
10-
border: 1px solid #3eaf7c;
6+
border: 1px solid var(--pwa-popup-border-color);
117
border-radius: 3px;
12-
background: #fff;
13-
box-shadow: 0 4px 16px var(--pwa-popup-color);
8+
background-color: var(--pwa-popup-bg-color);
9+
box-shadow: var(--pwa-popup-shadow);
1410
text-align: center;
15-
z-index: 3;
11+
z-index: var(--pwa-popup-z-index);
1612
}
1713

1814
.pwa-popup > button {
15+
cursor: pointer;
1916
margin-top: 0.5em;
2017
padding: 0.25em 2em;
18+
border: none;
19+
color: var(--pwa-popup-btn-text-color);
20+
background-color: var(--pwa-popup-btn-bg-color);
21+
}
22+
23+
.pwa-popup > button:hover {
24+
background-color: var(--pwa-popup-btn-hover-bg-color);
2125
}
2226

2327
.pwa-popup-enter-active,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
:root {
2+
--pwa-popup-z-index: 3;
3+
4+
--pwa-popup-text-color: #2c3e50;
5+
--pwa-popup-bg-color: #ffffff;
6+
--pwa-popup-border-color: #3eaf7c;
7+
--pwa-popup-shadow: 0 4px 16px var(--pwa-popup-border-color);
8+
9+
--pwa-popup-btn-text-color: #ffffff;
10+
--pwa-popup-btn-bg-color: #3eaf7c;
11+
--pwa-popup-btn-hover-bg-color: #4abf8a;
12+
}

packages/@vuepress/theme-default/src/client/styles/vars.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,14 @@
106106
--docsearch-hit-shadow: 0 1px 3px 0 var(--c-border-dark);
107107
--docsearch-footer-background: var(--c-bg);
108108
}
109+
110+
// plugin-pwa-popup
111+
.pwa-popup {
112+
--pwa-popup-text-color: var(--c-text);
113+
--pwa-popup-bg-color: var(--c-bg);
114+
--pwa-popup-border-color: var(--c-brand);
115+
--pwa-popup-shadow: 0 4px 16px var(--c-brand);
116+
--pwa-popup-btn-text-color: var(--c-bg);
117+
--pwa-popup-btn-bg-color: var(--c-brand);
118+
--pwa-popup-btn-hover-bg-color: var(--c-brand-light);
119+
}

0 commit comments

Comments
 (0)