-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[master] feat: Add KubeSphere App Store usage guide (#4405)
feat: Add KubeSphere App Store usage guide Signed-off-by: leioy <[email protected]> Co-authored-by: leioy <[email protected]>
- Loading branch information
Showing
7 changed files
with
255 additions
and
1 deletion.
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
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
56 changes: 56 additions & 0 deletions
56
packages/shared/src/components/Apps/AppsDashBoard/Card.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,56 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const CardWrapper = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
flex-direction: column; | ||
background: #fff; | ||
border-radius: 4px; | ||
box-shadow: 0 4px 8px 0 rgba(36, 46, 66, 0.06); | ||
@media (max-width: 768px) { | ||
padding-left: 0; | ||
} | ||
@media (min-width: 1164px) { | ||
padding-left: 117px; | ||
} | ||
`; | ||
|
||
const CardHeader = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 12px 20px; | ||
.title { | ||
display: flex; | ||
align-items: center; | ||
gap: 8px; | ||
font-size: 14px; | ||
font-weight: 600; | ||
color: #242e42; | ||
} | ||
`; | ||
|
||
const CardContent = styled.div``; | ||
|
||
interface CardProps { | ||
title: React.ReactNode; | ||
operations?: React.ReactNode; | ||
children?: React.ReactNode; | ||
} | ||
|
||
export const Card: React.FC<CardProps> = ({ title, operations, children }) => { | ||
return ( | ||
<CardWrapper> | ||
<CardHeader> | ||
<div className="title">{title}</div> | ||
{operations && <div className="operations">{operations}</div>} | ||
</CardHeader> | ||
<CardContent>{children}</CardContent> | ||
</CardWrapper> | ||
); | ||
}; | ||
|
||
export default Card; |
157 changes: 157 additions & 0 deletions
157
packages/shared/src/components/Apps/AppsDashBoard/UseGuide.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,157 @@ | ||
import React, { useEffect } from 'react'; | ||
import Icon from '../../Icon'; | ||
import { Card } from './Card'; | ||
import styled from 'styled-components'; | ||
import { openpitrixStore } from '../../../stores'; | ||
|
||
const GuideWrapper = styled.div` | ||
margin-bottom: 12px; | ||
`; | ||
|
||
const GuideContent = styled.div` | ||
padding: 12px 20px; | ||
`; | ||
|
||
const StepList = styled.div` | ||
display: flex; | ||
margin-top: 12px; | ||
`; | ||
|
||
const Step = styled.div` | ||
display: flex; | ||
align-items: flex-start; | ||
flex: 1; | ||
position: relative; | ||
background-color: #f9fbfd; | ||
padding: 12px; | ||
border-radius: 4px; | ||
min-height: 84px; | ||
&:not(:last-child)::after { | ||
content: ''; | ||
position: absolute; | ||
right: -36px; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
width: 36px; | ||
display: flex; | ||
justify-content: center; | ||
} | ||
.step-icon { | ||
width: 40px; | ||
height: 40px; | ||
margin-right: 8px; | ||
} | ||
.step-content { | ||
flex: 1; | ||
} | ||
.step-title { | ||
margin-bottom: 4px; | ||
} | ||
.step-desc { | ||
color: #79879c; | ||
font-size: 12px; | ||
} | ||
`; | ||
|
||
const IconWrapper = styled(Icon)` | ||
cursor: pointer; | ||
`; | ||
|
||
const { useAppList } = openpitrixStore; | ||
export const UseGuide: React.FC = () => { | ||
const { data } = useAppList( | ||
{ workspace: undefined }, | ||
{ | ||
autoFetch: true, | ||
|
||
params: { | ||
status: 'active', | ||
noLimit: true, | ||
categoryID: 'all', | ||
otherQuery: { label: 'application.kubesphere.io/repo-name=upload' }, | ||
}, | ||
}, | ||
); | ||
|
||
const [isGuideVisible, setIsGuideVisible] = React.useState(false); | ||
|
||
useEffect(() => { | ||
setIsGuideVisible(!data?.length); | ||
}, [data]); | ||
|
||
const steps = [ | ||
{ | ||
icon: 'plug-circle-duotone', | ||
title: t('USE_GUIDE_STEP_1'), | ||
}, | ||
{ | ||
icon: 'apps-duotone', | ||
title: t('USE_GUIDE_STEP_2'), | ||
}, | ||
{ | ||
icon: 'cloud-shield-duotone', | ||
title: t('USE_GUIDE_STEP_3'), | ||
}, | ||
{ | ||
icon: 'apps', | ||
title: t('USE_GUIDE_STEP_4'), | ||
}, | ||
]; | ||
|
||
return ( | ||
<GuideWrapper> | ||
<Card | ||
title={ | ||
<> | ||
<Icon name="book-3-duotone" size={20} /> | ||
{t('USE_GUIDE_TITLE')} | ||
</> | ||
} | ||
operations={ | ||
<IconWrapper | ||
name={isGuideVisible ? 'chevron-up' : 'chevron-down'} | ||
size={20} | ||
onClick={() => setIsGuideVisible(!isGuideVisible)} | ||
/> | ||
} | ||
> | ||
{isGuideVisible && ( | ||
<GuideContent> | ||
<div>{t('USE_GUIDE_DESC')}</div> | ||
<div>{t('USE_GUIDE_DESC2')}</div> | ||
<StepList> | ||
{steps.map((step, index) => ( | ||
<React.Fragment key={index}> | ||
<Step> | ||
<Icon name={step.icon} className="step-icon" /> | ||
<div className="step-content"> | ||
<div className="step-title">{`${index + 1}. ${step.title}`}</div> | ||
</div> | ||
</Step> | ||
{index < steps.length - 1 && ( | ||
<Icon | ||
name="more-duotone" | ||
size={20} | ||
style={{ | ||
color: '#79879c', | ||
width: '36px', | ||
alignSelf: 'center', | ||
}} | ||
/> | ||
)} | ||
</React.Fragment> | ||
))} | ||
</StepList> | ||
</GuideContent> | ||
)} | ||
</Card> | ||
</GuideWrapper> | ||
); | ||
}; | ||
|
||
export default UseGuide; |
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