Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1548 Redesign 'Advanced Features' section #1205

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
TW-1548 Refactoring according to comments
  • Loading branch information
keshan3262 committed Oct 1, 2024
commit 1e163b3733b95beef4c779fdd88e0985a622c570
4 changes: 2 additions & 2 deletions src/app/atoms/PageModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { PropsWithChildren, ReactNode, memo } from 'react';
import React, { PropsWithChildren, memo } from 'react';

import clsx from 'clsx';
import Modal from 'react-modal';
Expand All @@ -15,7 +15,7 @@ import { IconBase } from '../IconBase';
import ModStyles from './styles.module.css';

interface Props extends TestIDProps {
title: ReactNode;
title: string;
opened: boolean;
shouldShowBackButton?: boolean;
onRequestClose: EmptyFn;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const PartnersPromotionSettings = memo(() => {

return (
<EnablingSetting
title={<T id="partnersPromoSettings" />}
titleI18nKey="partnersPromoSettings"
description={<T id="partnersPromoDescription" />}
enabled={shouldShowPartnersPromo}
onChange={togglePartnersPromotion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const ReferralLinksSettings = memo(() => {

return (
<EnablingSetting
title={<T id="referralLinks" />}
titleI18nKey="referralLinks"
description={<T id="referralLinksDescription" />}
enabled={referralLinksEnabled}
onChange={toggleReferralLinks}
Expand Down
6 changes: 3 additions & 3 deletions src/app/templates/DialogBody.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { ReactNode, memo } from 'react';
import React, { FC, ReactNode } from 'react';

import { ActionModalBodyContainer } from 'app/atoms/action-modal';

interface DialogBodyProps {
description?: ReactNode | ReactNode[];
}

export const DialogBody = memo<PropsWithChildren<DialogBodyProps>>(({ children, description }) => (
export const DialogBody: FC<PropsWithChildren<DialogBodyProps>> = ({ children, description }) => (
<ActionModalBodyContainer>
{description && <p className="w-full text-center text-font-description text-grey-1 pt-1.5 pb-1">{description}</p>}
{children}
</ActionModalBodyContainer>
));
);
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const NotificationsSettings = memo(() => {

return (
<EnablingSetting
title={<T id="notifications" />}
titleI18nKey="notifications"
description={<T id="notificationsSettingsDescription" />}
enabled={isNewsEnabled}
onChange={handleNewsNotificationsChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const PopupSettings = memo(() => {

return (
<EnablingSetting
title={<T id="popupSettings" />}
titleI18nKey="popupSettings"
description={<T id="popupSettingsDescription" />}
enabled={popupEnabled}
onChange={handlePopupModeChange}
Expand Down
33 changes: 18 additions & 15 deletions src/app/templates/enabling-setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ import React, { ReactNode, memo } from 'react';
import { ToggleSwitch } from 'app/atoms';
import { SettingsCell } from 'app/atoms/SettingsCell';
import { SettingsCellGroup } from 'app/atoms/SettingsCellGroup';
import { T, TID } from 'lib/i18n';

interface EnablingSettingProps {
title: ReactNode;
titleI18nKey: TID;
enabled: boolean;
description: ReactNode;
onChange: (newValue: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;
testID: string;
}

export const EnablingSetting = memo(({ title, enabled, description, onChange, testID }: EnablingSettingProps) => (
<SettingsCellGroup>
<SettingsCell Component="div" isLast={false} cellName={title}>
<ToggleSwitch checked={enabled} onChange={onChange} testID={testID} />
</SettingsCell>
<SettingsCell
Component="div"
cellName={description}
cellNameClassName="text-grey-1 text-font-description font-normal"
>
{null}
</SettingsCell>
</SettingsCellGroup>
));
export const EnablingSetting = memo(
({ titleI18nKey, enabled, description, onChange, testID }: EnablingSettingProps) => (
<SettingsCellGroup>
<SettingsCell Component="div" isLast={false} cellName={<T id={titleI18nKey} />}>
<ToggleSwitch checked={enabled} onChange={onChange} testID={testID} />
</SettingsCell>
<SettingsCell
Component="div"
cellName={description}
cellNameClassName="text-grey-1 text-font-description font-normal"
>
{null}
</SettingsCell>
</SettingsCellGroup>
)
);
Loading