Skip to content

Commit

Permalink
fix(components): provide support getPrefixCls
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Sep 28, 2022
1 parent bf3fd22 commit b3da61f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/provider/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const ConfigProviderWrap: React.FC<Record<string, unknown>> = ({
children,
autoClearCache = false,
}) => {
const { locale } = useContext(AntdConfigProvider.ConfigContext);
const { locale, getPrefixCls } = useContext(AntdConfigProvider.ConfigContext);
const token = useToken?.();
// 如果 locale 不存在自动注入的 AntdConfigProvider
const Provider = locale === undefined ? AntdConfigProvider : React.Fragment;
Expand Down Expand Up @@ -322,7 +322,9 @@ export const ConfigProviderWrap: React.FC<Record<string, unknown>> = ({
</Provider>
);
if (proProvide.isDeps) return provide;
return <div className={`ant-pro ${token.hashId}`}>{provide}</div>;
return (
<div className={`${getPrefixCls?.('pro') || 'ant-pro'} ${token.hashId}`}>{provide}</div>
);
}}
</ConfigConsumer>
);
Expand Down
2 changes: 1 addition & 1 deletion tests/layout/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12813,7 +12813,7 @@ exports[`layout demos 📸 renders ./packages/layout/src/demos/collapsedShowTitl
exports[`layout demos 📸 renders ./packages/layout/src/demos/config-provider.tsx correctly 1`] = `
<DocumentFragment>
<div
class="ant-pro "
class="qixian-pro "
>
<div
class="ant-design-pro qixian-pro-layout screen-md qixian-pro-layout-fix-siderbar qixian-pro-layout-side"
Expand Down
2 changes: 1 addition & 1 deletion tests/list/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9009,7 +9009,7 @@ exports[`list demos 📸 renders ./packages/list/src/demos/special.tsx correctly
exports[`list demos 📸 renders ./packages/list/src/demos/testConfigProvider.tsx correctly 1`] = `
<DocumentFragment>
<div
class="ant-pro "
class="qixian-pro-pro "
>
<div
class="qixian-pro-pro-table qixian-pro-pro-list qixian-pro-pro-list qixian-pro-pro-list-no-split"
Expand Down
2 changes: 1 addition & 1 deletion tests/table/__snapshots__/column.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ exports[`Table ColumnSetting 🎏 columns proFieldProps support custom 1`] = `

exports[`Table ColumnSetting 🎏 config provide render 1`] = `
<div
class="ant-pro "
class="qixian-pro "
>
<div
class="qixian-pro-table"
Expand Down
2 changes: 1 addition & 1 deletion tests/table/__snapshots__/demo.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17910,7 +17910,7 @@ exports[`table demos 📸 renders ./packages/table/src/demos/columnsStateMap.tsx
exports[`table demos 📸 renders ./packages/table/src/demos/config-provider.tsx correctly 1`] = `
<DocumentFragment>
<div
class="ant-pro "
class="qixian-pro "
>
<div
class="qixian-pro-table"
Expand Down

0 comments on commit b3da61f

Please sign in to comment.