1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-28 17:55:15 +02:00
unleash.unleash/frontend/src/component/admin/users/LinkField/LinkField.tsx
NicolaeUnleash 23af7a3474
refactor: light theme colors (#3252)
## About the changes
Refactoring the colors for the light theme to be much easier to continue
with dark mode

This is the first step to finish dark mode

https://linear.app/unleash/project/[low][s][alpha]-dark-mode-in-unleash-admin-ui-31b407d13c4b/1

This PR uses `main-theme` as a placeholder for `dark-theme` for now due
to the new changes. Still need to set the correct values here.

---------

Co-authored-by: Nuno Góis <github@nunogois.com>
2023-03-06 12:58:36 +02:00

73 lines
2.1 KiB
TypeScript

import { Box, IconButton, Tooltip } from '@mui/material';
import CopyIcon from '@mui/icons-material/FileCopy';
import useToast from 'hooks/useToast';
interface ILinkFieldProps {
inviteLink: string;
small?: boolean;
}
export const LinkField = ({ inviteLink, small }: ILinkFieldProps) => {
const { setToastData } = useToast();
const handleCopy = () => {
try {
return navigator.clipboard
.writeText(inviteLink)
.then(() => {
setToastData({
type: 'success',
title: 'Successfully copied invite link.',
});
})
.catch(() => {
setError();
});
} catch (e) {
setError();
}
};
const setError = () =>
setToastData({
type: 'error',
title: 'Could not copy invite link.',
});
return (
<Box
sx={{
backgroundColor: theme => theme.palette.background.elevation2,
py: 4,
px: 4,
borderRadius: theme => `${theme.shape.borderRadius}px`,
mt: 2,
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
wordBreak: 'break-all',
...(small
? {
my: 0,
py: 0.5,
pl: 1.5,
pr: 0.5,
fontSize: theme => theme.typography.body2.fontSize,
}
: {}),
}}
>
{inviteLink}
<Tooltip title="Copy link" arrow>
<IconButton
onClick={handleCopy}
size={small ? 'small' : 'large'}
sx={small ? { ml: 0.5 } : {}}
>
<CopyIcon sx={{ fontSize: small ? 20 : undefined }} />
</IconButton>
</Tooltip>
</Box>
);
};