Bilibili-Evolved/registry/lib/components/style/auto-hide-sidebar/index.ts
2022-01-15 15:48:14 +08:00

31 lines
1007 B
TypeScript

import { ComponentMetadata } from '@/components/types'
import { addComponentListener } from '@/core/settings'
export const component: ComponentMetadata = {
name: 'autoHideSidebar',
entry: () => {
addComponentListener('autoHideSidebar.triggerWidth', (value: number) => {
document.documentElement.style.setProperty('--auto-hide-sidebar-width', `${value}px`)
}, true)
},
displayName: '自动隐藏侧栏',
instantStyles: [
{
name: 'autoHideSidebar',
style: () => import('./auto-hide-sidebar.scss'),
important: true,
},
],
tags: [componentsTags.style, componentsTags.general],
options: {
triggerWidth: {
defaultValue: 8,
displayName: '触发区域宽度 (px)',
validator: (value: number) => lodash.clamp(value, 1, 1000),
},
},
description: {
'zh-CN': '自动隐藏脚本的侧栏 (功能和设置图标). 设置面板停靠在右侧时不建议使用, 因为网页的滚动条会占用右边缘的触发区域.',
},
}