Skip to content

Commit 6140214

Browse files
authored
feat[watermark]: support dark theme (#7067)
* perf[watermark]: replace with token variable * feat: add theme toggle watch
1 parent 2429823 commit 6140214

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: components/watermark/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getStyleStr, getPixelRatio, rotateWatermark, reRendering } from './util
44
import { arrayType, objectType, someType, withInstall } from '../_util/type';
55
import { useMutationObserver } from '../_util/hooks/_vueuse/useMutationObserver';
66
import { initDefaultProps } from '../_util/props-util';
7+
import { useToken } from '../theme/internal';
78

89
/**
910
* Base size of the canvas, 1 for parallel layout and 2 for alternate layout
@@ -42,6 +43,7 @@ const Watermark = defineComponent({
4243
gap: [100, 100],
4344
}),
4445
setup(props, { slots, attrs }) {
46+
const [, token] = useToken();
4547
const containerRef = shallowRef<HTMLDivElement>();
4648
const watermarkRef = shallowRef<HTMLDivElement>();
4749
const stopObservation = shallowRef(false);
@@ -51,11 +53,11 @@ const Watermark = defineComponent({
5153
const gapYCenter = computed(() => gapY.value / 2);
5254
const offsetLeft = computed(() => props.offset?.[0] ?? gapXCenter.value);
5355
const offsetTop = computed(() => props.offset?.[1] ?? gapYCenter.value);
54-
const fontSize = computed(() => props.font?.fontSize ?? 16);
56+
const fontSize = computed(() => props.font?.fontSize ?? token.value.fontSizeLG);
5557
const fontWeight = computed(() => props.font?.fontWeight ?? 'normal');
5658
const fontStyle = computed(() => props.font?.fontStyle ?? 'normal');
5759
const fontFamily = computed(() => props.font?.fontFamily ?? 'sans-serif');
58-
const color = computed(() => props.font?.color ?? 'rgba(0, 0, 0, 0.15)');
60+
const color = computed(() => props.font?.color ?? token.value.colorFill);
5961
const markStyle = computed(() => {
6062
const markStyle: CSSProperties = {
6163
zIndex: props.zIndex ?? 9,
@@ -210,7 +212,7 @@ const Watermark = defineComponent({
210212
renderWatermark();
211213
});
212214
watch(
213-
() => props,
215+
() => [props, token.value.colorFill, token.value.fontSizeLG],
214216
() => {
215217
renderWatermark();
216218
},

0 commit comments

Comments
 (0)