Files
AFFiNE-Mirror/packages/component/src/components/changeLog/index.tsx
2023-05-09 15:27:05 +00:00

68 lines
1.6 KiB
TypeScript

import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { CloseIcon, NewIcon } from '@blocksuite/icons';
import clsx from 'clsx';
import { useState } from 'react';
import { IconButton } from '../..';
import {
changeLogSlideInStyle,
changeLogSlideOutStyle,
changeLogWrapperSlideInStyle,
changeLogWrapperSlideOutStyle,
iconButtonStyle,
iconStyle,
linkStyle,
linkTextStyle,
} from './index.css';
type ChangeLogProps = {
onCloseWhatsNew: () => void;
};
export const ChangeLog = (props: ChangeLogProps) => {
const { onCloseWhatsNew } = props;
const [isClose, setIsClose] = useState(false);
const t = useAFFiNEI18N();
const handleClose = () => {
setIsClose(true);
onCloseWhatsNew();
};
return (
<div
className={clsx(changeLogWrapperSlideInStyle, {
[changeLogWrapperSlideOutStyle]: isClose,
})}
>
<div
data-testid="change-log"
className={clsx(changeLogSlideInStyle, {
[changeLogSlideOutStyle]: isClose,
})}
>
<div
className={linkStyle}
onClick={() => {
window.open(
'https://github.com/toeverything/AFFiNE/releases',
'_blank'
);
}}
>
<NewIcon className={iconStyle} />
<div className={linkTextStyle}>{t["Discover what's new!"]()}</div>
</div>
<IconButton
className={iconButtonStyle}
onClick={() => {
handleClose();
}}
data-testid="change-log-close-button"
>
<CloseIcon />
</IconButton>
</div>
</div>
);
};
export default ChangeLog;