-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(platform,platform-server): make project public to anyone
- Loading branch information
1 parent
1073a82
commit 8fc893b
Showing
23 changed files
with
512 additions
and
95 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
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,105 @@ | ||
/* | ||
Copyright 2022 ByteDance and/or its affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { CloseOutlined, ExclamationCircleOutlined, InfoCircleOutlined } from '@ant-design/icons' | ||
import { DefaultButton, Modal as FluentModal, SharedColors, IModalStyles } from '@fluentui/react' | ||
import { memo, useMemo, useCallback } from 'react' | ||
import type { FC, ReactNode } from 'react' | ||
|
||
import { ColorButton } from '../color-button' | ||
|
||
import { CloseIconWrap, Container, Content, Footer, Header, Icon, Title } from './style' | ||
|
||
export enum ModalType { | ||
Confirm, | ||
Warning, | ||
} | ||
|
||
export type ModalProps = { | ||
isOpen: boolean | ||
type?: ModalType | ||
title?: string | ||
children?: ReactNode | ||
showCloseIcon?: boolean | ||
confirmDisabled?: boolean | ||
onClose: () => void | ||
onConfirm?: () => void | ||
} | ||
|
||
const ModalColors: Record<ModalType, string> = { | ||
[ModalType.Confirm]: SharedColors.cyanBlue10, | ||
[ModalType.Warning]: SharedColors.red10, | ||
} | ||
|
||
const ModalIcons: Record<ModalType, ReactNode> = { | ||
[ModalType.Confirm]: <InfoCircleOutlined />, | ||
[ModalType.Warning]: <ExclamationCircleOutlined />, | ||
} | ||
|
||
export const Modal: FC<ModalProps> = memo((props) => { | ||
const { | ||
isOpen, | ||
title, | ||
children, | ||
showCloseIcon = true, | ||
type = ModalType.Confirm, | ||
confirmDisabled = false, | ||
onClose, | ||
onConfirm, | ||
} = props | ||
|
||
const primaryColor = ModalColors[type] | ||
|
||
const modalStyles = useMemo<Partial<IModalStyles>>( | ||
() => ({ | ||
main: { | ||
minWidth: '400px', | ||
}, | ||
}), | ||
[], | ||
) | ||
|
||
const onClickConfirm = useCallback(() => { | ||
if (!confirmDisabled && onConfirm) { | ||
onConfirm() | ||
} | ||
}, [confirmDisabled, onConfirm]) | ||
|
||
return ( | ||
<FluentModal isOpen={isOpen} styles={modalStyles}> | ||
<Container> | ||
<Header> | ||
<Title> | ||
<Icon color={primaryColor}>{ModalIcons[type]}</Icon> | ||
<span>{title}</span> | ||
</Title> | ||
{showCloseIcon && ( | ||
<CloseIconWrap onClick={onClose}> | ||
<CloseOutlined /> | ||
</CloseIconWrap> | ||
)} | ||
</Header> | ||
<Content>{children}</Content> | ||
<Footer> | ||
<DefaultButton onClick={onClose}>Cancel</DefaultButton> | ||
<ColorButton color={primaryColor} disabled={confirmDisabled} onClick={onClickConfirm}> | ||
Confirm | ||
</ColorButton> | ||
</Footer> | ||
</Container> | ||
</FluentModal> | ||
) | ||
}) |
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,77 @@ | ||
/* | ||
Copyright 2022 ByteDance and/or its affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import styled from '@emotion/styled' | ||
|
||
export const Container = styled.div({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
height: '100%', | ||
}) | ||
|
||
export const Header = styled.div(({ theme }) => ({ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
padding: '12px', | ||
flexShrink: 0, | ||
|
||
borderBottom: `1px solid ${theme.border.color}`, | ||
})) | ||
|
||
export const Content = styled.div({ | ||
minHeight: '60px', | ||
flex: 1, | ||
}) | ||
|
||
export const Footer = styled.div({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'flex-end', | ||
flexShrink: 0, | ||
|
||
padding: '12px', | ||
|
||
'> button + button': { | ||
marginLeft: '12px', | ||
}, | ||
}) | ||
|
||
export const Title = styled.div({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
|
||
span: { | ||
fontSize: '18px', | ||
fontWeight: 500, | ||
}, | ||
}) | ||
|
||
export const Icon = styled.div<{ color: string }>(({ color }) => ({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
color, | ||
marginRight: '8px', | ||
})) | ||
|
||
export const CloseIconWrap = styled.div({ | ||
width: '18px', | ||
height: '18px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
cursor: 'pointer', | ||
}) |
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
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
Oops, something went wrong.