Skip to content

Commit

Permalink
feat: customCSS for addon-bangumi (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
yixiaojiu committed Feb 20, 2024
1 parent 1e9c1c9 commit 58054cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/valaxy-addon-bangumi/components/ValaxyBangumi.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,30 @@
// eslint-disable-next-line ts/ban-ts-comment
// @ts-expect-error
import { defineCustomElements } from 'bilibili-bangumi-component/dist/cjs/loader.cjs'
import { onMounted, ref } from 'vue'
import { useAddonBangumi } from '../client'
defineCustomElements()
const bangumiRef = ref<HTMLElement>()
const bangumiOptions = useAddonBangumi()
const { api, bgmEnabled, bgmUid, bilibiliEnabled, bilibiliUid } = bangumiOptions.value
const { api, bgmEnabled, bgmUid, bilibiliEnabled, bilibiliUid, customCss } = bangumiOptions.value
onMounted(() => {
if (!customCss)
return
const sheet = new CSSStyleSheet()
sheet.replaceSync(customCss)
bangumiRef.value?.shadowRoot?.adoptedStyleSheets.push(sheet)
})
</script>

<template>
<bilibili-bangumi
ref="bangumiRef"
:api="api"
:bgm-enabled="bgmEnabled"
:bgm-uid="bgmUid"
Expand Down
7 changes: 7 additions & 0 deletions packages/valaxy-addon-bangumi/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ export interface BangumiOptions {
* @default true
*/
bgmEnabled?: boolean

/**
* 自定义 css
* @example
* .bbc-bangumi-title a { color: red; }
*/
customCss?: string
}

1 comment on commit 58054cc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://yun.valaxy.site as production
🚀 Deployed on https://65d4ae36da2973e10aee92b9--valaxy.netlify.app

Please sign in to comment.