generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
106 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* iframe: 80 | ||
*/ | ||
const App = () => { | ||
return ( | ||
<div style={{ padding: 16 }}> | ||
<a href="">节点样式</a> | ||
</div> | ||
); | ||
}; | ||
export default App; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,16 @@ | ||
/** | ||
* iframe: true | ||
* iframe: 80 | ||
*/ | ||
import { Button, Divider, Space } from 'antd'; | ||
import { AppContainer, message } from 'antd-style'; | ||
import { AppContainer } from 'antd-style'; | ||
|
||
const App = () => { | ||
return ( | ||
<Space> | ||
<Button | ||
onClick={() => { | ||
message.success('成功'); | ||
}} | ||
> | ||
打开 message | ||
</Button> | ||
<a href="">节点样式</a> | ||
</Space> | ||
); | ||
}; | ||
export default () => { | ||
return ( | ||
<> | ||
<AppContainer appearance={'dark'}> | ||
<App /> | ||
<AppContainer> | ||
<div style={{ padding: 16 }}> | ||
<a href="">节点样式</a> | ||
</div> | ||
</AppContainer> | ||
|
||
<Divider>没有包裹</Divider> | ||
|
||
<App /> | ||
</> | ||
); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: 使用 styled | ||
--- | ||
|
||
# 使用 styled 组织样式组件 | ||
|
||
antd-style 中 styled 的 `styled` 方法和 `styled-component` 基本一致 |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { App, ConfigProvider } from 'antd'; | ||
import { ConfigProviderProps } from 'antd/es/config-provider'; | ||
import { type FC } from 'react'; | ||
|
||
import StaticMethod from './AntdStaticMethod'; | ||
|
||
const AntdProvider: FC<ConfigProviderProps> = ({ children, ...props }) => { | ||
return ( | ||
<ConfigProvider {...props}> | ||
<App> | ||
<StaticMethod /> | ||
{children} | ||
</App> | ||
</ConfigProvider> | ||
); | ||
}; | ||
|
||
export default AntdProvider; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Entry component | ||
import { App } from 'antd'; | ||
import type { MessageInstance } from 'antd/es/message/interface'; | ||
import type { ModalStaticFunctions } from 'antd/es/modal/confirm'; | ||
import type { NotificationInstance } from 'antd/es/notification/interface'; | ||
|
||
let message: MessageInstance; | ||
let notification: NotificationInstance; | ||
let modal: Omit<ModalStaticFunctions, 'warn'>; | ||
|
||
export default () => { | ||
const staticFunction = App.useApp(); | ||
message = staticFunction.message; | ||
modal = staticFunction.modal; | ||
notification = staticFunction.notification; | ||
return null; | ||
}; | ||
|
||
export { message, notification, modal }; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ThemeConfig } from 'antd/es/config-provider/context'; | ||
import { FC, ReactNode } from 'react'; | ||
|
||
import AntdProvider from './AntdProvider'; | ||
|
||
export type DisplayTheme = 'dark' | 'light'; | ||
|
||
export type ThemeMode = 'auto' | 'dark' | 'light'; | ||
|
||
export interface AppContainerProps { | ||
/** | ||
* 应用的展示外观主题,只存在亮色和暗色两种 | ||
*/ | ||
appearance?: DisplayTheme; | ||
defaultAppearance?: DisplayTheme; | ||
onAppearanceChange?: (mode: DisplayTheme) => void; | ||
/** | ||
* 主题的展示模式,有三种配置:跟随系统、亮色、暗色 | ||
* 默认不开启自动模式,需要手动进行配置 | ||
* @default light | ||
*/ | ||
themeMode?: ThemeMode; | ||
defaultThemeMode?: ThemeMode; | ||
onThemeModeChange?: (mode: ThemeMode) => void; | ||
|
||
/** | ||
* 透传到 antd CP 中的主题对象 | ||
*/ | ||
antdTheme?: ThemeConfig; | ||
children: ReactNode; | ||
} | ||
|
||
export const AppContainer: FC<AppContainerProps> = ({ children }) => { | ||
return <AntdProvider>{children}</AntdProvider>; | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { message, modal, notification } from './AntdStaticMethod'; | ||
export { AppContainer } from './AppContainer'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './AppContainer'; | ||
export * from './ThemeProvider'; |