Skip to content

Commit

Permalink
feat: 调整样式
Browse files Browse the repository at this point in the history
  • Loading branch information
OpportunityLiu committed Apr 18, 2024
1 parent daba44f commit f33b932
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 43 deletions.
49 changes: 23 additions & 26 deletions src/plugin/popup/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,29 @@
// theme
.theme(@background, @foreground, @shadow, @accent) {
@soft-accent: softlight(@accent, @background);
&,
.ehs-panel {

& {
border: @accent solid 1px;
border-radius: 6px;
background: @background;
color: @foreground;
box-shadow: 0 0 6px 2px @shadow;
}

.action {
background: @background;
color: @accent;
.action {
background: @background;
color: @accent;

&.primary {
border-color: @accent;
background: @accent;
color: @background;
}
&.primary:hover {
background: softlight(@accent, @foreground);
}
&.primary:active {
background: softlight(@accent, @background);
}
&.primary {
border-color: @accent;
background: @accent;
color: @background;
}
&.primary:hover {
background: softlight(@accent, @foreground);
}
&.primary:active {
background: softlight(@accent, @background);
}
}

Expand Down Expand Up @@ -153,23 +156,15 @@
}
}

#eh-syringe-popup-root {
#eh-syringe-popup {
@background: rgb(240, 240, 240);
@foreground: #111;
@shadow: rgba(0, 0, 0, 0.2);
@accent: #8041a6;
.theme(@background, @foreground, @shadow, @accent);
}

#eh-syringe-popup-host {
background: rgb(240, 240, 240);
}

#eh-syringe-popup-host.ex {
background: rgb(49, 49, 49);
}

:root.ex #eh-syringe-popup-root {
:root.ex #eh-syringe-popup {
@background: rgb(49, 49, 49);
@foreground: #eee;
@shadow: rgba(0, 0, 0, 0.2);
Expand Down Expand Up @@ -269,6 +264,8 @@
transform: scale(1);
&.ehs-hide {
transform: scale(0.9);
opacity: 0;
pointer-events: none;
}
}

Expand Down
21 changes: 9 additions & 12 deletions src/user-script/popup-host.less
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,26 @@
z-index: 1000;
background: rgba(0, 0, 0, 0.3);
visibility: hidden;
pointer-events: none;
opacity: 0;
transition:
visibility,
opacity 0.4s;
&.open {

&.open,
&.opening,
&.closing {
visibility: visible;
pointer-events: initial;
}

&.open {
opacity: 1;
}
&.opening {
visibility: visible;
opacity: 1;
}
&.closing {
visibility: visible;
opacity: 0;
}
}
Expand All @@ -63,13 +69,4 @@
position: absolute;
bottom: 12px + 36px + 24px;
right: 12px;
border: #ca8dca solid 1px;
box-shadow: rgba(0, 0, 0, 0.5) 0 0 6px 2px;
background: rgb(240, 240, 240);
border-radius: 6px;
overflow: hidden;

:root.ex & {
background: rgb(49, 49, 49);
}
}
2 changes: 1 addition & 1 deletion src/web-ext/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
</head>
<body id="eh-syringe-popup-host"></body>
<body id="eh-syringe-popup"></body>
</html>
24 changes: 24 additions & 0 deletions src/web-ext/popup.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
:root,
body {
box-sizing: border-box;
margin: 0;
padding: 0;
overflow: hidden;
}

:root {
width: 100%;
height: 100%;

color-scheme: light;
background: white;

&.ex {
color-scheme: dark;
background: black;
}
}

body {
margin: 2px;
}
9 changes: 5 additions & 4 deletions src/web-ext/popup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './polyfills';
import './popup.less';
import { Popup } from 'plugin/popup';
import { Container } from 'services';
import { isEh, isEx } from 'utils/hosts';
Expand All @@ -21,15 +22,15 @@ import { isEh, isEx } from 'utils/hosts';
const currentHost = (current?.[0]?.url && new URL(current[0].url).hostname) ?? '';

if (isEx(currentHost)) {
document.body.classList.add('ex');
document.documentElement.classList.add('ex');
} else if (isEh(currentHost)) {
document.body.classList.add('eh');
document.documentElement.classList.add('eh');
} else if ('matchMedia' in window) {
const matchesDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (matchesDarkTheme) {
document.body.classList.add('ex');
document.documentElement.classList.add('ex');
} else {
document.body.classList.add('eh');
document.documentElement.classList.add('eh');
}
}
})().catch(console.error);

0 comments on commit f33b932

Please sign in to comment.