Skip to content

Commit

Permalink
refactor: 重构 CSS 变量和 UnoCSS 配置 (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb authored Dec 10, 2024
1 parent 6fe23c1 commit 1f16428
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 25 deletions.
12 changes: 1 addition & 11 deletions src/assets/css/global.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
html {
--color-bg-1: var(--ant-color-bg-container);
--color-bg-2: var(--ant-color-bg-layout);
--color-bg-3: var(--ant-color-fill-quaternary);
--color-bg-4: var(--ant-color-fill-content);
--color-text-1: var(--ant-color-text);
--color-text-2: var(--ant-color-text-secondary);
--color-text-3: var(--ant-color-text-tertiary);
--color-border-1: var(--ant-color-border);
--color-border-2: var(--ant-color-border-secondary);

--uno: color-1 text-14 antialiased select-none overscroll-none;
--uno: text-color-1 text-14 antialiased select-none overscroll-none;

color-scheme: light;

Expand Down
2 changes: 1 addition & 1 deletion src/components/ProList/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

:global {
.ant-list {
--uno: "bg-1 b-color-2";
--uno: "bg-color-1 b-color-2";

.ant-list-item {
--uno: "px-16!";
Expand Down
2 changes: 1 addition & 1 deletion src/components/ProShortcut/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const ProShortcut: FC<ProShortcutProps> = (props) => {
tabIndex={0}
align="center"
gap="small"
className="antd-input group b-color-1 color-3 h-32 rounded-6 px-10"
className="antd-input group b-color-1 h-32 rounded-6 px-10 text-color-3"
onKeyDown={handleKeyDown}
onKeyUp={handleKeyUp}
>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/Preference/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

:global {
.ant-tabs-content-holder {
--uno: "b-0 h-full flex-1 overflow-auto bg-2 p-16";
--uno: "b-0 h-full flex-1 overflow-auto bg-color-2 p-16";

.ant-tabs-tabpane {
--uno: "p-0!";
Expand Down
6 changes: 4 additions & 2 deletions src/layouts/Preference/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const PreferenceLayout = () => {
data-tauri-drag-region
vertical
gap="small"
className={clsx("h-full w-200 p-12", [isMac() ? "pt-32" : "bg-1"])}
className={clsx("h-full w-200 p-12", [
isMac() ? "pt-32" : "bg-color-1",
])}
onClick={(event) => event.stopPropagation()}
>
{tabItems.map((item) => {
Expand All @@ -98,7 +100,7 @@ const PreferenceLayout = () => {
align="center"
gap="small"
className={clsx(
"color-2 cursor-pointer rounded-8 p-12 p-r-0 transition hover:bg-4",
"cursor-pointer rounded-8 p-12 p-r-0 text-color-2 transition hover:bg-color-4",
{
"bg-primary! text-white!": activeKey === key,
},
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Backup/components/Manual/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const Manual: FC<{ state: State }> = (props) => {
align="center"
justify="center"
gap="small"
className="b b-color-2 hover:b-primary h-102 flex-1 cursor-pointer rounded-8 bg-3 px-8 text-center transition hover:text-primary"
className="b b-color-2 hover:b-primary h-102 flex-1 cursor-pointer rounded-8 bg-color-3 px-8 text-center transition hover:text-primary"
onClick={event}
>
<Icon name={icon} size={26} />
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Clipboard/Panel/components/Dock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Dock = () => {
return <div className="h-screen rounded-t-16 bg-1">Dock</div>;
return <div className="h-screen rounded-t-16 bg-color-1">Dock</div>;
};

export default Dock;
4 changes: 2 additions & 2 deletions src/pages/Clipboard/Panel/components/Float/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Float = () => {

return (
<div
className={clsx("h-screen bg-1", {
className={clsx("h-screen bg-color-1", {
"rounded-10": !isWin(),
"b b-color-1": isLinux(),
})}
Expand Down Expand Up @@ -42,7 +42,7 @@ const Float = () => {
>
<Group />

<Flex align="center" gap={4} className="color-2 text-18">
<Flex align="center" gap={4} className="text-18 text-color-2">
<Pin />

<Icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const Header: FC<HeaderProps> = (props) => {
};

return (
<Flex justify="space-between" gap="small" className="color-2">
<Flex justify="space-between" gap="small" className="text-color-2">
<Scrollbar thumbSize={0}>
<Flex gap="small" className="flex-1 whitespace-nowrap text-12">
<span>{renderType()}</span>
Expand Down
3 changes: 3 additions & 0 deletions src/utils/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {
primaryMonitor,
} from "@tauri-apps/api/window";

/**
* 获取当前鼠标所在的显示器
*/
export const getCursorMonitor = async () => {
const primary = await primaryMonitor();

Expand Down
17 changes: 13 additions & 4 deletions uno.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export default defineConfig({
],
rules: [["outline-none", { outline: "none" }]],
shortcuts: [
[/^bg-(\d+)$/, ([, d]) => `bg-[var(--color-bg-${d})]`],
[/^color-(\d+)$/, ([, d]) => `text-[var(--color-text-${d})]`],
[/^b-color-(\d+)$/, ([, d]) => `b-[var(--color-border-${d})]`],
[/^bg-color-(\d+)$/, ([, d]) => `bg-bg-${d}`],
[/^text-color-(\d+)$/, ([, d]) => `text-text-${d}`],
[/^b-color-(\d+)$/, ([, d]) => `b-border-${d}`],
[/^(.*)-primary-(\d+)$/, ([, s, d]) => `${s}-[var(--ant-blue-${d})]`],
{
"antd-input":
Expand All @@ -36,12 +36,21 @@ export default defineConfig({
],
theme: {
colors: {
"bg-1": "var(--ant-color-bg-container)",
"bg-2": "var(--ant-color-bg-layout)",
"bg-3": "var(--ant-color-fill-quaternary)",
"bg-4": "var(--ant-color-fill-content)",
"text-1": "var(--ant-color-text)",
"text-2": "var(--ant-color-text-secondary)",
"text-3": "var(--ant-color-text-tertiary)",
"border-1": "var(--ant-color-border)",
"border-2": "var(--ant-color-border-secondary)",
primary: "var(--ant-blue)",
success: "var(--ant-green)",
danger: "var(--ant-red)",
gold: "var(--ant-gold)",
wechat: "#00c25f",
qq: "#0099ff",
wechat: "#00c25f",
alipay: "#0c79fe",
},
},
Expand Down

0 comments on commit 1f16428

Please sign in to comment.