arco-design-vue icon indicating copy to clipboard operation
arco-design-vue copied to clipboard

单个元素或组件的 theme 切换

Open jiankafei opened this issue 3 years ago • 0 comments

Basic Info

What are the similar cases of this feature

想让页面头部单独进入某一个主题模式。

What problem does this feature solve?

新增一个 a-theme 组件,任何放在该组件内部的元素或者组件都可以通过传递 theme 属性实现 theme 的切换,这样的实现更加通用,a-menu 组件也就不需要专门设置 theme 属性了。 方案是:

    1. 把 body[acro-theme=’theme‘] {} 改为 [acro-theme='theme'] {},该步骤是必须的;
    1. 新增 a-theme 组件,作用是为元素添加 acro-theme='theme'属性,组件有两个属性: ---- prop: mount: 表示为哪个元素添加主题属性,默认给放入该组件的根元素添加,最外层 a-theme 可手动设置为 body,让其为body添加属性 ---- prop: theme: 设置需要添加的主题名称。
    1. 或者提供一个 useTheme 的 hook ,可以参考 useDark的实现,作用和 a-theme 组件一样,也是可以的。

jiankafei avatar Aug 23 '22 08:08 jiankafei