-
Notifications
You must be signed in to change notification settings - Fork 44
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
17 changed files
with
676 additions
and
284 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
packages/components/src/components/Alert/package-relation.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,11 @@ | ||
.dot { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
.filePath { | ||
display: flex; | ||
justify-content: space-between; | ||
} |
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
16 changes: 16 additions & 0 deletions
16
packages/components/src/components/Alerts/bundle-alert.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,16 @@ | ||
.card { | ||
:global { | ||
.ant-card-body { | ||
padding: 0; | ||
} | ||
|
||
.ant-collapse { | ||
border-radius: 0; | ||
border: 0; | ||
} | ||
|
||
.ant-collapse-content { | ||
border-radius: 0 !important; | ||
} | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
packages/components/src/components/Alerts/bundle-alert.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,108 @@ | ||
import { Typography, Tabs } from 'antd'; | ||
import { Rule } from '@rsdoctor/types'; | ||
|
||
import { ViewMode } from '../../constants'; | ||
import { Card } from '../Card'; | ||
import { Overview } from '../Overall/overview'; | ||
import { AlertCollapse } from './collapse'; | ||
import { CommonList } from './list'; | ||
|
||
import { AlertProps } from '../Alert/types'; | ||
|
||
import styles from './bundle-alert.module.scss'; | ||
|
||
interface BundleAlertProps { | ||
title: string; | ||
cwd: string; | ||
dataSource: Rule.RuleStoreDataItem[]; | ||
extraData: Omit<AlertProps, 'data'>; | ||
viewMode: ViewMode; | ||
setViewMode(mode: ViewMode): void; | ||
extraCom?: JSX.Element | undefined; | ||
} | ||
|
||
export const BundleAlert: React.FC<BundleAlertProps> = ({ | ||
title, | ||
dataSource, | ||
extraData, | ||
}) => { | ||
if (!dataSource.length) return null; | ||
|
||
const tabData: Array<{ | ||
key: string; | ||
label: string; | ||
data: Array<Rule.RuleStoreDataItem>; | ||
}> = [ | ||
{ | ||
key: 'E1001', | ||
label: 'Duplicate Packages', | ||
data: [], | ||
}, | ||
{ | ||
key: 'E1002', | ||
label: 'Default Import Check', | ||
data: [], | ||
}, | ||
{ | ||
key: 'E1003', | ||
label: 'Loader Performance Optimization', | ||
data: [], | ||
}, | ||
{ | ||
key: 'E1004', | ||
label: 'ECMA Version Check', | ||
data: [], | ||
}, | ||
]; | ||
|
||
dataSource.forEach((data) => { | ||
const target = tabData.find((td) => td.key === data.code)?.data; | ||
target?.push(data); | ||
}); | ||
|
||
const tabItems = tabData.map((td) => { | ||
const LabelComponent = () => ( | ||
<Overview | ||
key={td.key} | ||
title={td.label} | ||
description={td.data.length} | ||
icon={<Typography.Text code>{td.key}</Typography.Text>} | ||
/> | ||
); | ||
|
||
let children; | ||
switch (td.key) { | ||
case 'E1001': | ||
children = <AlertCollapse data={td.data} extraData={extraData} />; | ||
break; | ||
case 'E1002': | ||
children = <CommonList data={[{ title: 'aaa' }]} />; | ||
break; | ||
case 'E1003': | ||
children = <CommonList data={[{ title: 'bbb' }]} />; | ||
break; | ||
case 'E1004': | ||
children = <>1004</>; | ||
break; | ||
default: | ||
children = null; | ||
break; | ||
} | ||
|
||
return { | ||
key: td.key, | ||
label: <LabelComponent />, | ||
children: ( | ||
<Card className={styles.card} type="inner" title={td.label}> | ||
{children} | ||
</Card> | ||
), | ||
}; | ||
}); | ||
|
||
return ( | ||
<Card title={title}> | ||
<Tabs defaultActiveKey="E1002" items={tabItems} /> | ||
</Card> | ||
); | ||
}; |
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
Oops, something went wrong.