Skip to content

Commit

Permalink
feat: logo img update
Browse files Browse the repository at this point in the history
  • Loading branch information
xsf0105 committed May 30, 2023
1 parent 99ba4f7 commit dab79e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quark-doc-header",
"version": "0.0.14",
"version": "0.0.15",
"main": "./lib/index.js",
"module": "./lib/index.js",
"files": [
Expand Down
25 changes: 20 additions & 5 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QuarkElement, Fragment, createRef, customElement } from "quarkc"
import { QuarkElement, Fragment, createRef, customElement, state } from "quarkc"
import style from "./main.css"
import "./dark-light-mode.mjs"
import "./dark-light-mode.mjs" // 备注:黑夜模式切换包含了全局css变量的更改,只在引用的工程中生效

import docsearch from "@docsearch/js";
import "@docsearch/css";
Expand Down Expand Up @@ -50,20 +50,22 @@ const langs = {
class MyComponent extends QuarkElement {
#isZhLang
#ecosystemLangs
#isSearchShow

@state() // 响应式内部状态
logo = 'https://quark.hellobike.com/assets/quark-logo.f9a6a307.png'

searchRef = createRef()

constructor() {
super()
this.#isZhLang = localStorage.getItem("language") === "zh-CN"
this.#ecosystemLangs = this.#isZhLang ? langs["zh-CN"] : langs["en-US"]
this.#isSearchShow = true
}


componentDidMount(): void {
const container = this.searchRef.current;

if(location.host.indexOf("vue-quarkdesign") > -1) {
docsearch({
container,
Expand All @@ -72,6 +74,7 @@ class MyComponent extends QuarkElement {
localStorage.getItem("language") === "en-US" ? "ENDoc" : "CNDoc",
apiKey: "5d1fd7c976a98a74421011f1374dd200",
});
this._logoSwitch()
} else if(location.host.indexOf("react-quarkdesign") > -1) {
docsearch({
container,
Expand All @@ -80,6 +83,18 @@ class MyComponent extends QuarkElement {
localStorage.getItem("language") === "en-US" ? "react-ENDoc" : "react-CNDoc",
apiKey: "5d1fd7c976a98a74421011f1374dd200",
});
this._logoSwitch()
}
}

_logoSwitch = () => {
const themeMedia = window.matchMedia("(prefers-color-scheme: dark)");
if (localStorage.theme === "dark") {
this.logo = 'https://m.hellobike.com/resource/helloyun/13459/9uKAS_quark-logo3.png?x-oss-process=image/quality,q_80'
} else if (localStorage.theme === "light") {
this.logo = 'https://m.hellobike.com/resource/helloyun/13459/8k1Dm_quark-logo2.png?x-oss-process=image/quality,q_80'
} else if(themeMedia.matches && localStorage.theme !== "light") {
this.logo = 'https://m.hellobike.com/resource/helloyun/13459/9uKAS_quark-logo3.png?x-oss-process=image/quality,q_80'
}
}

Expand All @@ -104,7 +119,7 @@ class MyComponent extends QuarkElement {
<div class="container">
<div class="left-bar">
<a href="/">
<img src="https://quark.hellobike.com/assets/quark-logo.f9a6a307.png" alt="" />
<img src={this.logo} alt="" />
</a>

<div ref={this.searchRef} id="docsearch"></div>
Expand Down

0 comments on commit dab79e0

Please sign in to comment.