Skip to content

Commit a6d0c2a

Browse files
authored
feat: devtool add header slot (#3886)
1 parent 60a5aa4 commit a6d0c2a

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

packages/chrome-devtools/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const App = (props: RootComponentProps) => {
1818
handleSnapshot,
1919
handleProxyAddress,
2020
customValueValidate,
21+
headerSlot,
2122
} = props;
2223
const [module, setModule] = useState(window.__FEDERATION__?.moduleInfo || {});
2324

@@ -39,6 +40,7 @@ const App = (props: RootComponentProps) => {
3940
handleSnapshot={handleSnapshot}
4041
handleProxyAddress={handleProxyAddress}
4142
customValueValidate={customValueValidate}
43+
headerSlot={headerSlot}
4244
/>
4345
) : (
4446
<Empty description={'No ModuleInfo Detected'} />

packages/chrome-devtools/src/component/Form/index.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
}
4646
}
4747

48+
& .headerSlot {
49+
display: flex;
50+
align-items: center;
51+
}
52+
4853
& .badge {
4954
display: flex;
5055
transform: scale(1.6);

packages/chrome-devtools/src/component/Form/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ interface FormProps {
4545
validateForm: any;
4646
enableHMR: string;
4747
onHMRChange: (on: boolean) => void;
48+
headerSlot?: ReactNode;
4849
}
4950
const FormComponent = (props: FormProps & RootComponentProps) => {
5051
const {
@@ -222,13 +223,16 @@ const FormComponent = (props: FormProps & RootComponentProps) => {
222223
<div className={styles.status}>
223224
<Badge color={condition.color} className={styles.badge} />
224225
<span className={styles.message}>{condition.message}</span>
225-
<Switch
226-
checked={enableHMR === 'enable'}
227-
checkedText={'Enable HMR'}
228-
uncheckedText={'Disable HMR'}
229-
onChange={hmrChange}
230-
className={styles.switch}
231-
/>
226+
<span className={styles.headerSlot}>
227+
{props.headerSlot}
228+
<Switch
229+
checked={enableHMR === 'enable'}
230+
checkedText={'Enable HMR'}
231+
uncheckedText={'Disable HMR'}
232+
onChange={hmrChange}
233+
className={styles.switch}
234+
/>
235+
</span>
232236
</div>
233237
</div>
234238

packages/chrome-devtools/src/component/Layout/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const Layout = (
5959
getVersion,
6060
handleProxyAddress,
6161
customValueValidate,
62+
headerSlot,
6263
} = props;
6364
const { producer } = separateType(moduleInfo);
6465
const [condition, setCondition] = useState(statusInfo.processing);
@@ -219,6 +220,7 @@ const Layout = (
219220
setVersionList={setVersionList}
220221
getVersion={getVersion}
221222
customValueValidate={customValueValidate}
223+
headerSlot={headerSlot}
222224
/>
223225
</Form>
224226

packages/chrome-devtools/src/utils/types/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ReactNode } from 'react';
12
import { getModuleInfo } from '../index';
23

34
export interface FormItemStatus {
@@ -14,4 +15,5 @@ export interface RootComponentProps {
1415
getVersion?: (moduleName: string) => Promise<Array<string>>;
1516
handleProxyAddress?: (address: string) => string;
1617
customValueValidate?: (schema: string) => boolean;
18+
headerSlot?: ReactNode;
1719
}

0 commit comments

Comments
 (0)