From bde7cbea0cf9e3c5eca139e15b344a6a79ed882e Mon Sep 17 00:00:00 2001 From: joseph izang Date: Wed, 7 Jul 2021 12:24:19 +0100 Subject: [PATCH] refactor and remove redundant components listgroupitem and renderItem --- .../src/lib/components/listGroupItem.tsx | 27 --------- .../src/lib/components/moduleHeading.tsx | 4 +- .../src/lib/components/pluginCard.tsx | 53 ++++++++--------- .../src/lib/components/renderItem.tsx | 57 ------------------- .../src/lib/components/rootView.tsx | 44 +++++++------- .../src/lib/remix-ui-plugin-manager.tsx | 1 - 6 files changed, 47 insertions(+), 139 deletions(-) delete mode 100644 libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx delete mode 100644 libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx diff --git a/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx b/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx deleted file mode 100644 index e767c2cb02..0000000000 --- a/libs/remix-ui/plugin-manager/src/lib/components/listGroupItem.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react' -import { Profile } from '../../customTypes' -import RenderItem from './renderItem' - -interface ListGroupItemProps { - activeProfiles?: Profile[] - inactiveProfiles?: Profile[] -} - -function ListGroupItem () { - return ( -
- {/* { activeProfiles.length > 0 - ? activeProfiles.map(profile => ( - - )) - : inactiveProfiles.map(profile => ( - - )) - } */} - -
List Group Item Component
-
- ) -} - -export default ListGroupItem diff --git a/libs/remix-ui/plugin-manager/src/lib/components/moduleHeading.tsx b/libs/remix-ui/plugin-manager/src/lib/components/moduleHeading.tsx index 8067a42a4e..e0af4ae69d 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/moduleHeading.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/moduleHeading.tsx @@ -6,12 +6,12 @@ interface ModuleHeadingProps { } function ModuleHeading ({ headingLabel }: ModuleHeadingProps) { - const { inactivesCount, activesCount } = useContext(PluginManagerContext) + const { actives, inactives } = useContext(PluginManagerContext) return ( ) diff --git a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx index cedd8e0166..491ab46689 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/pluginCard.tsx @@ -3,17 +3,12 @@ import { PluginManagerContext } from '../contexts/pluginmanagercontext' import '../remix-ui-plugin-manager.css' import Button from './button' interface PluginCardProps { - profileName: string - displayName: string - docLink: string - versionWarning: any - profileIcon: string - profileDescription: string + profile: any } // eslint-disable-next-line no-empty-pattern -function PluginCard () { - const { profile, isActive } = useContext(PluginManagerContext) +function PluginCard ({ profile }: PluginCardProps) { + const { isActive } = useContext(PluginManagerContext) const [displayName] = useState((profile.displayName) ? profile.displayName : profile.name) const [docLink] = useState((profile.documentation) ? ( @@ -26,26 +21,28 @@ function PluginCard () { beta ) : null) return ( -
-
-
-
- {displayName} - {docLink} - {versionWarning} -
- { isActive(profile.name) ? ( -
-
-
- profile icon - {profile.description} -
-
+
+
+
+
+
+ {displayName} + {docLink} + {versionWarning} +
+ { isActive(profile.name) ? ( +
+
+
+ profile icon + {profile.description} +
+
+
) } diff --git a/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx b/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx deleted file mode 100644 index efe554a140..0000000000 --- a/libs/remix-ui/plugin-manager/src/lib/components/renderItem.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import React, { useContext } from 'react' -import { Profile } from '../../customTypes' -import { PluginManagerContext } from '../contexts/pluginmanagercontext' -import PluginCard from './pluginCard' - -interface RenderItemProps { - profile: Profile -} - -function RenderItem () { - const { profile } = useContext(PluginManagerContext) - // const [displayName, setDisplayName] = useState('') - // const [docLink, setDocLink] = useState() - // const [versionWarning, setVersionWarning] = useState, HTMLElement>>() - - // useEffect(() => { - // const checkPluginVersion = (version: string) => { - // // eslint-disable-next-line @typescript-eslint/no-unused-vars - // let versionWarning: React.DetailedHTMLProps, HTMLElement> - // if (version && version.match(/\b(\w*alpha\w*)\b/g)) { - // versionWarning = alpha - // } - // // Beta - // if (version && version.match(/\b(\w*beta\w*)\b/g)) { - // versionWarning = beta - // } - // return versionWarning - // } - - // setDisplayName((profile.displayName) ? profile.displayName : profile.name) - // setDocLink( - // profile.documentation ? ( - //
- // - // - // ) : '') - // setVersionWarning(checkPluginVersion(profile.version)) - // }, [profile.displayName, profile.documentation, profile.name, profile.version, versionWarning]) - console.log('Profile object from render item component', profile) - - return ( - - ) -} - -export default RenderItem diff --git a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx index c2d473dd77..ee52b5547b 100644 --- a/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/components/rootView.tsx @@ -1,32 +1,15 @@ -import React from 'react' -import ListGroupItem from './listGroupItem' +import React, { Fragment, useContext } from 'react' +import { PluginManagerContext } from '../contexts/pluginmanagercontext' import ModuleHeading from './moduleHeading' +import PluginCard from './pluginCard' interface RootViewProps { localPluginButtonText: string } function RootView ({ localPluginButtonText }: RootViewProps) { - // const { actives, inactives, tileLabel } = useContext(PluginManagerContext) + const { actives, inactives } = useContext(PluginManagerContext) return ( - //
- //
- // - // - //
- //
- // - // - //
- //
-
@@ -35,9 +18,22 @@ function RootView ({ localPluginButtonText }: RootViewProps) {
- - - + {actives.length === 0 ? ( + + + {actives.map((profile) => ( + + ))} + + ) : null } + {inactives.length === 0 ? ( + + + {inactives.map((profile) => ( + + ))} + + ) : null}
) diff --git a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx index df8dbcd607..e5a8b17a1b 100644 --- a/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx +++ b/libs/remix-ui/plugin-manager/src/lib/remix-ui-plugin-manager.tsx @@ -14,7 +14,6 @@ export const RemixUiPluginManager = (props: RemixUiPluginManagerProps) => { // /> // -

Remix UI Plugin Manager React

)