Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
import { splitTheme } from '../../.storybook/decorators/splitThemeDecorator';
import { ArticleDesign, ArticleDisplay, Pillar } from '../lib/articleFormat';
import { FollowNotificationsButton, FollowTagButton } from './FollowButtons';
import { FollowTagButton } from './FollowTagButton';

export default {
component: [FollowNotificationsButton, FollowTagButton],
title: 'Components/FollowStatus',
component: FollowTagButton,
title: 'Components/FollowTagButton',
args: {
isFollowing: false,
},
};

export const Default = ({ isFollowing }: { isFollowing: boolean }) => {
return (
<>
<FollowTagButton
isFollowing={isFollowing}
displayName={'John Doe'}
onClickHandler={() => undefined}
/>
<FollowNotificationsButton
isFollowing={isFollowing}
onClickHandler={() => undefined}
/>
</>
<FollowTagButton
isFollowing={isFollowing}
displayName={'John Doe'}
onClickHandler={() => undefined}
/>
);
};

Expand All @@ -37,22 +31,6 @@ Default.decorators = [
]),
];

export const NotificationsButtonBothStates = () => {
return (
<>
<FollowNotificationsButton
isFollowing={false}
onClickHandler={() => undefined}
/>
<FollowNotificationsButton
isFollowing={true}
onClickHandler={() => undefined}
/>
</>
);
};
NotificationsButtonBothStates.decorators = [splitTheme()];

export const FollowContributorBothStates = () => {
return (
<>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
import { render, waitFor } from '@testing-library/react';
import { FollowNotificationsButton, FollowTagButton } from './FollowButtons';

it('should show a Notifications Off button for a single contributor when rendering for apps', () => {
const { getByText } = render(
<FollowNotificationsButton
isFollowing={false}
onClickHandler={() => undefined}
/>,
);
expect(getByText('Notifications off')).toBeInTheDocument();
});

it('should show a Notifications On button for a single contributor when rendering for apps', async () => {
const { getByText } = render(
<FollowNotificationsButton
onClickHandler={() => undefined}
isFollowing={true}
/>,
);
await waitFor(() =>
expect(getByText('Notifications on')).toBeInTheDocument(),
);
});
import { FollowTagButton } from './FollowTagButton';

it('should show a follow contributor button for a single contributor when rendering for apps', () => {
const { getByText } = render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { css } from '@emotion/react';
import { space, textSans15 } from '@guardian/source/foundations';
import {
SvgCheckmark,
SvgNotificationsOff,
SvgNotificationsOn,
SvgPlus,
} from '@guardian/source/react-components';
import { SvgCheckmark, SvgPlus } from '@guardian/source/react-components';
import type { ReactNode } from 'react';
import { palette } from '../palette';

Expand Down Expand Up @@ -65,12 +60,6 @@ const containerStyles = css`
column-gap: 0.2em;
`;

const notificationsTextSpan = ({
isFollowing,
}: Pick<ButtonProps, 'isFollowing'>) => (
<span>Notifications {isFollowing ? 'on' : 'off'}</span>
);

const tagTextSpan = ({
isFollowing,
displayName,
Expand All @@ -90,29 +79,6 @@ type ButtonProps = {
onClickHandler: () => void;
};

export const FollowNotificationsButton = ({
isFollowing,
onClickHandler,
withExtraBottomMargin = false,
}: ButtonProps & { withExtraBottomMargin?: boolean }) => {
return (
<button
onClick={onClickHandler}
type="button"
css={[buttonStyles(withExtraBottomMargin)]}
>
<span css={containerStyles}>
<FollowIcon
isFollowing={isFollowing}
iconIsFollowing={<SvgNotificationsOn size="xsmall" />}
iconIsNotFollowing={<SvgNotificationsOff size="xsmall" />}
/>
{notificationsTextSpan({ isFollowing })}
</span>
</button>
);
};

export const FollowTagButton = ({
isFollowing,
displayName = '',
Expand Down
2 changes: 1 addition & 1 deletion dotcom-rendering/src/components/FollowWrapper.island.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getNotificationsClient, getTagClient } from '../lib/bridgetApi';
import { useIsBridgetCompatible } from '../lib/useIsBridgetCompatible';
import { useIsMyGuardianEnabled } from '../lib/useIsMyGuardianEnabled';
import { palette as schemedPalette } from '../palette';
import { FollowTagButton } from './FollowButtons';
import { FollowTagButton } from './FollowTagButton';

type Props = {
id: string;
Expand Down
Loading