Skip to content

Commit

Permalink
Use style components for button styles
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmilburn committed Dec 14, 2024
1 parent acda80e commit 46c7da9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 7 additions & 2 deletions admin/src/components/CopyLinkButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { memo, useCallback } from 'react';
import { useIntl } from 'react-intl';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import styled from 'styled-components';
import { Button } from '@strapi/design-system';
import { Link as LinkIcon } from '@strapi/icons';
import { useNotification } from '@strapi/strapi/admin';
Expand All @@ -12,6 +13,10 @@ export interface CopyLinkButtonProps {
url: string;
}

const ButtonStyled = styled(Button)`
width: 100%;
`;

const CopyLinkButton = ({ isDraft, url }: CopyLinkButtonProps) => {
const { formatMessage } = useIntl();
const { toggleNotification } = useNotification();
Expand All @@ -28,7 +33,7 @@ const CopyLinkButton = ({ isDraft, url }: CopyLinkButtonProps) => {

return (
<CopyToClipboard text={url} onCopy={handleOnCopy}>
<Button size="S" startIcon={<LinkIcon />} variant="secondary" style={{ width: '100%' }}>
<ButtonStyled size="S" startIcon={<LinkIcon />} variant="secondary">
{formatMessage(
isDraft
? {
Expand All @@ -40,7 +45,7 @@ const CopyLinkButton = ({ isDraft, url }: CopyLinkButtonProps) => {
defaultMessage: 'Copy link',
}
)}
</Button>
</ButtonStyled>
</CopyToClipboard>
);
};
Expand Down
15 changes: 12 additions & 3 deletions admin/src/components/PreviewButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { memo, useCallback } from 'react';
import { useIntl } from 'react-intl';
import styled from 'styled-components';
import { LinkButton } from '@strapi/design-system';
import { ExternalLink } from '@strapi/icons';

Expand All @@ -10,6 +11,15 @@ export interface PreviewButtonProps extends PreviewButtonStateConfig {
isDraft: boolean;
}

const LinkButtonStyled = styled(LinkButton)`
width: 100%;
// Fix visited state color for the icon.
&:visited {
color: ${({ theme }) => theme.colors.primary700};
}
`;

const PreviewButton = ({ isDraft, openTarget, url }: PreviewButtonProps) => {
const { formatMessage } = useIntl();

Expand All @@ -27,15 +37,14 @@ const PreviewButton = ({ isDraft, openTarget, url }: PreviewButtonProps) => {
);

return (
<LinkButton
<LinkButtonStyled
disabled={!url}
href={url}
onClick={handleClick}
size="S"
startIcon={<ExternalLink />}
target="_blank"
variant="secondary"
style={{ width: '100%' }}
>
{formatMessage(
isDraft
Expand All @@ -48,7 +57,7 @@ const PreviewButton = ({ isDraft, openTarget, url }: PreviewButtonProps) => {
defaultMessage: 'Open live view',
}
)}
</LinkButton>
</LinkButtonStyled>
);
};

Expand Down

0 comments on commit 46c7da9

Please sign in to comment.