From 61b3b43527bde63de09aa110e7f357a5f3b7a6c9 Mon Sep 17 00:00:00 2001
From: mantou132 <709922234@qq.com>
Date: Sat, 7 Sep 2024 18:51:23 +0800
Subject: [PATCH] [gem] Element level style(only shadow)
Closed #197
---
.../duoyun-ui/src/elements/action-text.ts | 18 ++-
packages/duoyun-ui/src/elements/alert.ts | 17 +-
packages/duoyun-ui/src/elements/area-chart.ts | 118 ++++++++------
packages/duoyun-ui/src/elements/avatar.ts | 17 +-
.../duoyun-ui/src/elements/base/scroll.ts | 1 -
packages/duoyun-ui/src/elements/button.ts | 63 ++++----
packages/duoyun-ui/src/elements/carousel.ts | 14 +-
.../duoyun-ui/src/elements/chart-tooltip.ts | 25 +--
packages/duoyun-ui/src/elements/coach-mark.ts | 12 +-
packages/duoyun-ui/src/elements/code-block.ts | 22 +--
.../duoyun-ui/src/elements/color-panel.ts | 23 +--
.../duoyun-ui/src/elements/contextmenu.ts | 3 -
packages/duoyun-ui/src/elements/divider.ts | 23 ++-
packages/duoyun-ui/src/elements/flow.ts | 23 ++-
packages/duoyun-ui/src/elements/help-text.ts | 18 +--
.../duoyun-ui/src/elements/image-preview.ts | 42 ++---
.../duoyun-ui/src/elements/input-capture.ts | 24 +--
packages/duoyun-ui/src/elements/input.ts | 6 +
packages/duoyun-ui/src/elements/line-chart.ts | 148 +++++++++---------
packages/duoyun-ui/src/elements/modal.ts | 3 -
.../duoyun-ui/src/elements/page-loadbar.ts | 16 +-
packages/duoyun-ui/src/elements/pagination.ts | 12 +-
.../duoyun-ui/src/elements/placeholder.ts | 17 +-
packages/duoyun-ui/src/elements/rate.ts | 19 ++-
.../duoyun-ui/src/elements/scatter-chart.ts | 94 +++++------
packages/duoyun-ui/src/elements/slider.ts | 34 ++--
packages/duoyun-ui/src/elements/switch.ts | 21 +--
packages/duoyun-ui/src/elements/tabs.ts | 11 +-
packages/duoyun-ui/src/elements/tag.ts | 23 ++-
packages/duoyun-ui/src/elements/wait.ts | 35 +++--
packages/gem-book/src/element/elements/404.ts | 3 +-
.../src/element/elements/edit-link.ts | 2 +
.../gem-book/src/element/elements/footer.ts | 3 +-
.../gem-book/src/element/elements/loadbar.ts | 16 +-
.../gem-book/src/element/elements/main.ts | 2 +
.../gem-book/src/element/elements/meta.ts | 3 +-
.../gem-book/src/element/elements/nav-logo.ts | 13 +-
packages/gem-book/src/element/elements/nav.ts | 2 +
.../gem-book/src/element/elements/rel-link.ts | 15 +-
.../gem-book/src/element/elements/sidebar.ts | 2 +
packages/gem-book/src/element/elements/toc.ts | 2 +
packages/gem-book/src/element/index.ts | 17 +-
packages/gem-book/src/element/store.ts | 4 +-
packages/gem-devtools/src/elements/section.ts | 4 +-
packages/gem/src/helper/theme.ts | 19 ++-
packages/gem/src/lib/element.ts | 45 ++++--
46 files changed, 556 insertions(+), 498 deletions(-)
diff --git a/packages/duoyun-ui/src/elements/action-text.ts b/packages/duoyun-ui/src/elements/action-text.ts
index 172e9af7..89fa94b3 100644
--- a/packages/duoyun-ui/src/elements/action-text.ts
+++ b/packages/duoyun-ui/src/elements/action-text.ts
@@ -1,6 +1,7 @@
import { GemElement, html, createCSSSheet } from '@mantou/gem/lib/element';
import { adoptedStyle, customElement, attribute, state, slot, aria, shadow, mounted } from '@mantou/gem/lib/decorators';
import { addListener, css } from '@mantou/gem/lib/utils';
+import { useDecoratorTheme } from '@mantou/gem/helper/theme';
import { theme, getSemanticColor } from '../lib/theme';
import { commonHandle } from '../lib/hotkeys';
@@ -8,17 +9,19 @@ import { focusStyle } from '../lib/styles';
import './tooltip';
+const [elementTheme, updateTheme] = useDecoratorTheme({ color: '', activeColor: '' });
+
const style = createCSSSheet(css`
:host {
overflow: hidden;
text-overflow: ellipsis;
cursor: default;
line-height: 1.5;
- color: var(--color, inherit);
+ color: ${elementTheme.color};
border-radius: ${theme.normalRound};
}
:host(:where(:hover, :state(active))) {
- color: var(--color, ${theme.primaryColor});
+ color: ${elementTheme.activeColor};
text-decoration: underline;
}
:host(:where(:lang(zh), :lang(ja), :lang(kr))) {
@@ -46,13 +49,14 @@ export class DuoyunActionTextElement extends GemElement {
@mounted()
#init = () => addListener(this, 'keydown', commonHandle);
+ @updateTheme()
+ #theme = () => {
+ const color = getSemanticColor(this.color) || this.color;
+ return { color: color || 'inherit', activeColor: color || theme.primaryColor };
+ };
+
render = () => {
return html`
-