ant-design/.dumi/theme/common/EditButton.tsx
MadCcc fab90b09f4
docs: fix site issue (#38552)
* docs: put an example loading component

* fix: site issue

* fix: site issue

* feat: add loading

* feat: alert

* docs: rm ReactDOM.render in md

* docs: use style tag

* chore: update snapshot

* Revert "docs: use style tag"

This reverts commit 1f75a99f8c.

* docs: update demo

* chore: update demo

Co-authored-by: PeachScript <scdzwyxst@gmail.com>
2022-11-15 22:55:01 +08:00

57 lines
1.2 KiB
TypeScript

import React from 'react';
import { Tooltip } from 'antd';
import { EditOutlined } from '@ant-design/icons';
import { css } from '@emotion/react';
import useSiteToken from '../../hooks/useSiteToken';
const branchUrl = 'https://github.com/ant-design/ant-design/edit/next/';
export interface EditButtonProps {
title: React.ReactNode;
filename?: string;
}
const useStyle = () => {
const { token } = useSiteToken();
const { colorIcon, colorText, iconCls } = token;
return {
editButton: css`
a& {
display: inline-block;
text-decoration: none;
margin-inline-start: 8px;
${iconCls} {
display: block;
color: ${colorIcon};
font-size: 16px;
transition: all 0.3s;
&:hover {
color: ${colorText};
}
}
}
`,
};
};
export default function EditButton({ title, filename }: EditButtonProps) {
const styles = useStyle();
return (
<Tooltip title={title}>
<a
css={styles.editButton}
href={`${branchUrl}${filename}`}
target="_blank"
rel="noopener noreferrer"
>
<EditOutlined />
</a>
</Tooltip>
);
}