diff --git a/src/components/clock/clock-style.ts b/src/components/clock/clock-style.ts index 38d607f..446f4bf 100644 --- a/src/components/clock/clock-style.ts +++ b/src/components/clock/clock-style.ts @@ -1,7 +1,5 @@ -import {css, CSSResult,unsafeCSS} from 'lit' -const darkHour = unsafeCSS( - new URL('./svg/dark_hour.svg', import.meta.url).href -) +import {css, CSSResult, unsafeCSS} from 'lit' +const darkHour = unsafeCSS(new URL('./svg/dark_hour.svg', import.meta.url).href) const darkMinute = unsafeCSS( new URL('./svg/dark_minute.svg', import.meta.url).href ) @@ -83,8 +81,7 @@ export const sharedStyles: CSSResult = css` min-width: var(--autoWidth); height: var(--autoWidth); min-height: var(--autoWidth); - padding: var(--autoBorder); - transform: scale(var(--autoZoom)); + padding: calc(6px * var(--ratio)); display: flex; justify-content: center; align-items: center; @@ -107,13 +104,13 @@ export const sharedStyles: CSSResult = css` } .star-clock-shaft { position: absolute; - width: var(--autoShapt); - height: var(--autoShapt); + width: calc(18px * var(--ratio)); + height: calc(18px * var(--ratio)); top: 50%; left: 50%; border-radius: 50%; background: #c94d18; - border: var(--autoShaptBorder) solid #e07548; + border: calc(4px * var(--ratio)) solid #e07548; transform: translate(-50%, -50%); z-index: 1; } @@ -126,11 +123,12 @@ export const sharedStyles: CSSResult = css` width: 0px; background-color: transparent; transform-origin: 0 100%; + transform: rotate(calc(var(--i) * 30deg)); } .star-clock-point { display: inline-block; - width: var(--autoPoint); - height: var(--autoPoint); + width: calc(10px * var(--ratio)); + height: calc(10px * var(--ratio)); position: absolute; right: 50%; top: 0; @@ -140,37 +138,40 @@ export const sharedStyles: CSSResult = css` rgba(245, 245, 245, 0.01) 100% ); border-radius: 50%; - transform: translate(-50%, 0); + transform: translate(-50%, 0) rotate(calc(var(--i) * -30deg)); } .star-clock-hour-hand { position: absolute; bottom: 50%; left: 50%; - width: 12px; - height: 90px; + width: calc(12px * var(--ratio)); + height: calc(90px * var(--ratio)); transform-origin: 0 100%; display: inline-block; transform: rotate(var(--rotateHour)) translate(-50%, 0); + background-size: cover; } .star-clock-minute-hand { position: absolute; bottom: 50%; left: 50%; - width: 12px; - height: 132px; + width: calc(12px * var(--ratio)); + height: calc(132px * var(--ratio)); transform-origin: 0 100%; display: inline-block; transform: rotate(var(--rotateMinute)) translate(-50%, 0); + background-size: cover; } .star-clock-second-hand { position: absolute; - bottom: calc(50% - 17px); + bottom: calc(50% - 17px * var(--ratio)); left: 50%; display: inline-block; - width: 4px; - height: 160px; - transform-origin: 0 calc(100% - 17px); + width: calc(4px * var(--ratio)); + height: calc(160px * var(--ratio)); + transform-origin: 0 calc(100% - 17px * var(--ratio)); transform: rotate(var(--rotateSecond)) translate(-50%, 0); + background-size: cover; } /*无表盘深色模式*/ .star-clock-case-transparent { @@ -179,7 +180,6 @@ export const sharedStyles: CSSResult = css` min-width: var(--autoWidth); height: var(--autoWidth); min-height: var(--autoWidth); - transform: scale(var(--autoZoom)); border-radius: 50%; display: flex; justify-content: center; @@ -188,8 +188,8 @@ export const sharedStyles: CSSResult = css` } .star-clock-point-transparent { display: inline-block; - width: var(--autoPointTransparent); - height: var(--autoPointTransparent); + width: calc(16px * var(--ratio)); + height: calc(16px * var(--ratio)); position: absolute; right: 50%; top: 0; diff --git a/src/components/clock/clock.ts b/src/components/clock/clock.ts index 007ce9d..ac2bb8f 100644 --- a/src/components/clock/clock.ts +++ b/src/components/clock/clock.ts @@ -27,17 +27,14 @@ export class StarClock extends LitElement { } @query('.star-clock') - starClock: HTMLDivElement | undefined + starClock!: HTMLDivElement getTransparentClock() { return html`