From 1230129a4b0e3acd7bd7e3a8c5c8675697cb5b39 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Sat, 31 Aug 2019 13:07:53 -0500 Subject: [PATCH] refactor SubscribeButton for SRP -> Primary Button & MirrorButtons --- .../src/components/ListInfoDrawer.tsx | 4 +- ...bscribeButton.tsx => SubscribeButtons.tsx} | 59 +++++++++++-------- 2 files changed, 38 insertions(+), 25 deletions(-) rename src/FilterLists.Web.V2/src/components/{SubscribeButton.tsx => SubscribeButtons.tsx} (67%) diff --git a/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx b/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx index db10f89c0..54fe5df6f 100644 --- a/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx +++ b/src/FilterLists.Web.V2/src/components/ListInfoDrawer.tsx @@ -11,7 +11,7 @@ import { Description } from './Description'; import { LanguageCloud } from './languageCloud'; import { LicenseTag } from './LicenseTag'; import { LinkButton } from './LinkButton'; -import { SubscribeButton } from './SubscribeButton'; +import { SubscribeButtons } from './SubscribeButtons'; import { TagCloud } from './tagCloud'; interface Props { @@ -64,7 +64,7 @@ export class ListInfoDrawer extends React.Component - {this.props.list.viewUrl && } + {this.props.list.viewUrl && } {this.props.list.viewUrl && { +export const SubscribeButtons = (props: Props) => + <> + + + ; + +const PrimaryButton = (props: Props) => { const buttonProps = buildButtonProps(props.name, props.viewUrl); return ( - <> - - - + ) }; -const PrimaryButton = (props: [ButtonProps, boolean]) => - ; - const MirrorButtons = (props: Props) => <> {props.viewUrlMirrors && props.viewUrlMirrors.length - ? props.viewUrlMirrors.map((viewUrlMirror: string, i: number) => { - const buttonProps = buildButtonProps(props.name, viewUrlMirror); - return - }) + ? props.viewUrlMirrors.map((viewUrlMirror: string, i: number) => + + ) : null} ; +interface MirrorButtonProps { + index: number; + viewUrlMirror: string; + name: string; +} + +const MirrorButton = (props: MirrorButtonProps) => { + const buttonProps = buildButtonProps(props.name, props.viewUrlMirror); + return ( + + ) +} + const buildButtonProps = (name: string, viewUrl: string): [ButtonProps, boolean] => { let type: ButtonType = "primary"; let disabled: boolean = false;