-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devtools): built-in doctor tab for rsdoctor (#5368)
- Loading branch information
Showing
48 changed files
with
1,315 additions
and
366 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,9 @@ | ||
--- | ||
'@integration-test/devtools': minor | ||
'@modern-js/devtools-client': minor | ||
'@modern-js/plugin-devtools': minor | ||
'@modern-js/devtools-kit': minor | ||
--- | ||
|
||
feat(devtools): add new doctor tab to show overview of rsdoctor | ||
feat(devtools): 新增 doctor 页面展示 Rsdoctor 概览信息 |
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
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
packages/devtools/client/src/components/Card/Indicate.module.scss
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,8 @@ | ||
.indicate-card { | ||
border-radius: var(--radius-5); | ||
box-shadow: var(--shadow-4); | ||
padding: var(--space-5); | ||
:global(.dark) & { | ||
background-color: var(--gray-1); | ||
} | ||
} |
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 { FC } from 'react'; | ||
import clsx from 'clsx'; | ||
import { Box, Flex } from '@radix-ui/themes'; | ||
import type { BoxProps } from '@radix-ui/themes/dist/cjs/components/box'; | ||
import type { FlexProps } from '@radix-ui/themes/dist/cjs/components/flex'; | ||
import styles from './Indicate.module.scss'; | ||
|
||
export type IndicateCardProps = BoxProps & React.RefAttributes<HTMLDivElement>; | ||
|
||
const Card: FC<IndicateCardProps> = ({ children, className, ...props }) => { | ||
return ( | ||
<Box {...props} className={clsx(styles.indicateCard, className)}> | ||
{children} | ||
</Box> | ||
); | ||
}; | ||
|
||
Card.displayName = 'IndicateCard'; | ||
|
||
const Column: FC<FlexProps> = props => ( | ||
<Flex | ||
gap="2" | ||
height="100%" | ||
justify="center" | ||
direction="column" | ||
align="start" | ||
{...props} | ||
/> | ||
); | ||
|
||
Column.displayName = 'IndicateCard.Column'; | ||
|
||
export const IndicateCard = Object.assign(Card, { | ||
Column, | ||
}); |
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 @@ | ||
export * from './Indicate'; |
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
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
9 changes: 9 additions & 0 deletions
9
packages/devtools/client/src/components/Error/FeatureDisabled.module.scss
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,9 @@ | ||
.container { | ||
width: max-content; | ||
min-width: var(--space-9); | ||
color: var(--gray-11); | ||
} | ||
|
||
.children { | ||
color: var(--gray-9); | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/devtools/client/src/components/Error/FeatureDisabled.tsx
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,25 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { Box, Flex, Heading } from '@radix-ui/themes'; | ||
import { HiExclamationCircle } from 'react-icons/hi2'; | ||
import styles from './FeatureDisabled.module.scss'; | ||
|
||
export interface FeatureDisabledProps extends PropsWithChildren { | ||
title: string; | ||
} | ||
|
||
export const FeatureDisabled: React.FC<FeatureDisabledProps> = props => { | ||
const { title, children } = props; | ||
return ( | ||
<Flex className={styles.container} mt="9" mx="auto" gap="2"> | ||
<Flex height="9" align="center"> | ||
<HiExclamationCircle size="36" /> | ||
</Flex> | ||
<Box> | ||
<Flex height="9" align="center"> | ||
<Heading>{title}</Heading> | ||
</Flex> | ||
<Box className={styles.children}>{children}</Box> | ||
</Box> | ||
</Flex> | ||
); | ||
}; |
Empty file.
2 changes: 1 addition & 1 deletion
2
packages/devtools/client/src/entries/client/routes/config/error.tsx
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,3 +1,3 @@ | ||
import { ErrorRouteHandler } from '@/components/ErrorFallback/ErrorFallback'; | ||
import { ErrorRouteHandler } from '@/components/Error/Fallback'; | ||
|
||
export default ErrorRouteHandler; |
2 changes: 1 addition & 1 deletion
2
packages/devtools/client/src/entries/client/routes/context/error.tsx
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,3 +1,3 @@ | ||
import { ErrorRouteHandler } from '@/components/ErrorFallback/ErrorFallback'; | ||
import { ErrorRouteHandler } from '@/components/Error/Fallback'; | ||
|
||
export default ErrorRouteHandler; |
41 changes: 41 additions & 0 deletions
41
packages/devtools/client/src/entries/client/routes/doctor/error.tsx
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,41 @@ | ||
import { FC } from 'react'; | ||
import { useRouteError } from '@modern-js/runtime/router'; | ||
import { Box, Link } from '@radix-ui/themes'; | ||
import { useSnapshot } from 'valtio'; | ||
import { parseURL } from 'ufo'; | ||
import { $definition } from '../state'; | ||
import { | ||
ErrorFallbackProps, | ||
ErrorRouteHandler, | ||
} from '@/components/Error/Fallback'; | ||
import { FeatureDisabled } from '@/components/Error/FeatureDisabled'; | ||
|
||
const Handler: FC<ErrorFallbackProps> = () => { | ||
const error = useRouteError(); | ||
const def = useSnapshot($definition); | ||
const isStateError = | ||
error && typeof error === 'object' && Object.keys(error).length === 0; | ||
if (isStateError) { | ||
const websiteDisplay = parseURL(def.doctor.quickStart).host; | ||
const websiteLink = ( | ||
<Link | ||
href={def.doctor.quickStart} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
🔗{websiteDisplay} | ||
</Link> | ||
); | ||
return ( | ||
<Box width="100%"> | ||
<FeatureDisabled title="Doctor is not working"> | ||
Visit the website of {websiteLink} to learn more. | ||
</FeatureDisabled> | ||
</Box> | ||
); | ||
} else { | ||
return <ErrorRouteHandler />; | ||
} | ||
}; | ||
|
||
export default Handler; |
5 changes: 5 additions & 0 deletions
5
packages/devtools/client/src/entries/client/routes/doctor/layout.config.ts
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,5 @@ | ||
export const handle = { | ||
breadcrumb: { | ||
title: 'Doctor', | ||
}, | ||
}; |
101 changes: 101 additions & 0 deletions
101
packages/devtools/client/src/entries/client/routes/doctor/page.module.scss
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,101 @@ | ||
.container { | ||
max-width: 40rem; | ||
width: 100%; | ||
} | ||
|
||
.primary-card { | ||
flex: 4; | ||
min-width: max-content; | ||
background-color: var(--amber-9); | ||
:global(.dark) & { | ||
background-color: var(--amber-9); | ||
} | ||
button { | ||
border: none; | ||
border-radius: var(--radius-thumb); | ||
color: var(--black-a8); | ||
font-size: var(--font-size-1); | ||
font-weight: var(--font-weight-regular); | ||
padding: var(--space-1) var(--space-2); | ||
overflow: hidden; | ||
background-color: var(--black-a2); | ||
&:hover, | ||
&:active { | ||
background-color: var(--black-a1); | ||
} | ||
} | ||
} | ||
|
||
.info-card { | ||
flex: 2; | ||
min-width: max-content; | ||
} | ||
|
||
.count-card { | ||
flex: 1; | ||
min-width: max-content; | ||
} | ||
|
||
.compile-cost-card { | ||
flex: 4; | ||
} | ||
|
||
.logo { | ||
width: var(--space-8); | ||
opacity: 0.5; | ||
} | ||
|
||
.count-text { | ||
display: flex; | ||
align-items: center; | ||
gap: var(--space-1); | ||
} | ||
|
||
.error-item { | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
gap: var(--space-1); | ||
color: var(--gray-11); | ||
} | ||
|
||
.text-truncation { | ||
width: 100%; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
|
||
.cost-box { | ||
min-width: var(--space-2); | ||
|
||
.cost-bar { | ||
height: var(--space-1); | ||
width: 100%; | ||
border-radius: var(--radius-thumb); | ||
} | ||
|
||
&:nth-child(odd) { | ||
.cost-bar { | ||
background-color: var(--red-9); | ||
} | ||
} | ||
|
||
&:nth-child(even) { | ||
.cost-bar { | ||
background-color: var(--orange-9); | ||
} | ||
} | ||
|
||
.cost-label { | ||
word-break: keep-all; | ||
display: block; | ||
margin-bottom: var(--space-2); | ||
} | ||
} | ||
|
||
.heading { | ||
font-family: 'NotoSans'; | ||
font-weight: 900; | ||
font-size: var(--font-size-7); | ||
} |
Oops, something went wrong.