From 288ba26e77620fa3599c3591fe051d4823562211 Mon Sep 17 00:00:00 2001 From: Hakadao Date: Thu, 29 Feb 2024 13:45:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=E4=B8=BA=20adaptedStyles=20?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=AD=A3=E5=88=99=E5=8C=B9=E9=85=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=B7=BB=E5=8A=A0=E4=B8=AD=E6=96=87=E5=AF=B9=E5=BA=94?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/styles/adaptedStyles/index.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/styles/adaptedStyles/index.ts b/src/styles/adaptedStyles/index.ts index 77bd7694..a0fb5aef 100644 --- a/src/styles/adaptedStyles/index.ts +++ b/src/styles/adaptedStyles/index.ts @@ -9,7 +9,7 @@ import './videoPlayer.scss' async function setupStyles() { const currentUrl = document.URL - // homepage + // homepage 首页 if (/https?:\/\/bilibili.com\/?$/.test(currentUrl) || /https?:\/\/www.bilibili.com\/?$/.test(currentUrl) || /https?:\/\/www.bilibili.com\/index.html$/.test(currentUrl) @@ -19,13 +19,13 @@ async function setupStyles() { document.documentElement.classList.add('homePage') } - // notifications page + // notifications page 消息页 else if (/https?:\/\/message.bilibili.com\.*/.test(currentUrl)) { await import('./notificationsPage.scss') document.documentElement.classList.add('notificationsPage') } - // moments page + // moments page 动态页 else if ( // moments /https?:\/\/t.bilibili.com\.*/.test(currentUrl) @@ -35,30 +35,30 @@ async function setupStyles() { document.documentElement.classList.add('momentsPage') } - // history page + // history page 历史记录页 else if (/https?:\/\/(www.)?bilibili.com\/account\/history.*/.test(currentUrl)) { await import('./historyPage.scss') document.documentElement.classList.add('historyPage') } - // user space page + // user space page 空间页 else if (/https?:\/\/space.bilibili.com\.*/.test(currentUrl)) { await import('./userSpacePage.scss') document.documentElement.classList.add('userSpacePage') } - // search page + // search page 搜索结果页 else if (/https?:\/\/search.bilibili.com\.*/.test(currentUrl)) { await import('./searchPage.scss') document.documentElement.classList.add('searchPage') } - // video page + // video page 视频页 else if ( /https?:\/\/(www.)?bilibili.com\/video\/.*/.test(currentUrl) - // watch later playlist + // watch later playlist 稍候再看播放页 || /https?:\/\/(www.)?bilibili.com\/list\/watchlater.*/.test(currentUrl) - // favorite playlist + // favorite playlist 收藏播放页 || /https?:\/\/(www.)?bilibili.com\/list\/ml.*/.test(currentUrl) ) { await import('./videoPage.scss') @@ -66,28 +66,28 @@ async function setupStyles() { } else if ( - // anime playback & movie page + // anime playback & movie page 番剧播放页与电影播放页 /https?:\/\/(www.)?bilibili.com\/bangumi\/play\/.*/.test(currentUrl) ) { await import('./animePlayback&MoviePage.scss') document.documentElement.classList.add('animePlaybackAndMoviePage') } - // anime page & chinese anime page + // anime page & chinese anime page 番剧页 与 国创动漫 else if ( /https?:\/\/(www.)?bilibili.com\/(anime|guochuang).*/.test(currentUrl)) { await import('./animePage.scss') document.documentElement.classList.add('animePage') } - // channel page e.g. tv shows, movie, variety shows, mooc page + // channel page e.g. tv shows, movie, variety shows, mooc page 分区页 else if ( /https?:\/\/(www.)?bilibili.com\/(tv|movie|variety|mooc|documentary).*/.test(currentUrl)) { await import('./channelPage.scss') document.documentElement.classList.add('channelPage') } - // articles page + // articles page 专栏页 else if (/https?:\/\/(www.)?bilibili.com\/read.*/.test(currentUrl)) { await import('./articlesPage.scss') document.documentElement.classList.add('articlesPage') From f0bc3fe5734b372553e5c7e5d27ea263b994a36e Mon Sep 17 00:00:00 2001 From: Hakadao Date: Thu, 29 Feb 2024 13:46:23 +0800 Subject: [PATCH 2/2] doc: add adapted styles readme --- src/styles/adaptedStyles/README.md | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/styles/adaptedStyles/README.md diff --git a/src/styles/adaptedStyles/README.md b/src/styles/adaptedStyles/README.md new file mode 100644 index 00000000..5ae357e0 --- /dev/null +++ b/src/styles/adaptedStyles/README.md @@ -0,0 +1,56 @@ +# Adapted Styles + +Here, place the CSS for dark mode or change the theme color. + +In `index.ts`, we will write some regex rules to match the style used on specific page. + +## Style File Writing Style + +``` scss +.bewly-design.pageName { + // Implement specific modifications to the page, like tweaking the layout, and place those styles here + .right-side-bar .catalog { + line-height: 3em; + } + + ... + + // #region theme color adaption part + // Increase the priority of the style inside by writing a non-existent selector in :not() + :not(fdjslfds) { + a, b, c { + color: var(--bew-theme-color); + } + + d, e, f { + // PLEASE NOTE THAT USING `!important` SHOULD BE A LAST RESORT + color: var(--bew-theme-color) !important; + } + + g, h, i { + background-color: var(--bew-theme-color); + } + + j, k, l { + background-color: var(--bew-theme-color) !important; + } + + ... + } + // #endregion + + // #region dark mode adaption part + &.dark { + aa, bb, cc { + color: var(--bew-text-1); + } + + dd, ee, ff { + color: var(--bew-text-1) !important; + } + + ... + } + // #endregion +} +```