feat(amis-core): 导出 ThemeContext,支持局部主题设置 - #21486
Open
tianyk wants to merge 1 commit into
Open
Conversation
此前 ThemeContext 仅在 theme.ts 模块内部定义,未从 index 导出,
导致只用 amis-ui 的场景无法通过 ThemeContext.Provider 局部设置主题,
只能依赖 setDefaultTheme 全局修改。
导出后可直接使用:
import {ThemeContext} from 'amis-core';
<ThemeContext.Provider value=antd>
<Button>primary</Button>
</ThemeContext.Provider>
|
👍 Thanks for this! Please review the labels and make any necessary changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
此前
ThemeContext仅在theme.ts模块内部定义,未从index.tsx导出。导致只用amis-ui的场景无法通过ThemeContext.Provider局部设置主题,只能依赖setDefaultTheme全局修改。改动
从
packages/amis-core/src/index.tsx导出ThemeContext,使用方可以直接通过 Context 局部设置主题。用法
为什么需要这个改动
setDefaultTheme是全局修改,影响所有 amis-ui 组件实例ThemeContext可以局部生效,不影响其他组件render(schema, {theme: 'antd'})只对 amis 渲染树生效,不影响直接使用的 amis-ui 组件