Skip to content

Commit

Permalink
feat(app): apollo client ui and routes
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcalise committed Oct 24, 2023
1 parent e154267 commit b9bc85b
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/reactotron-app/src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import Overlay from "./pages/reactNative/Overlay"
import Storybook from "./pages/reactNative/Storybook"
import CustomCommands from "./pages/customCommands"
import Help from "./pages/help"
import Cache from "./pages/apolloClient/Cache"
import Mutations from "./pages/apolloClient/Mutations"
import Queries from "./pages/apolloClient/Queries"

const AppContainer = styled.div`
position: absolute;
Expand Down Expand Up @@ -68,6 +71,11 @@ function App() {
{/* Custom Commands */}
<Route path="/customCommands" element={<CustomCommands />} />

{/* TODO: Load custom UI pages from installed plugins */}
<Route path="/apolloClient/cache" element={<Cache />} />
<Route path="/apolloClient/queries" element={<Queries />} />
<Route path="/apolloClient/mutations" element={<Mutations />} />

{/* Help */}
<Route path="/help" element={<Help />} />
</Routes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react"
import { MdReorder, MdAssignment, MdPhoneIphone, MdLiveHelp } from "react-icons/md"
import { FaMagic } from "react-icons/fa"
import { SiApollographql } from "react-icons/si"
import styled from "styled-components"

import SideBarButton from "../SideBarButton"
Expand Down Expand Up @@ -42,6 +43,12 @@ function SideBar({ isOpen }: { isOpen: boolean }) {
text="React Native"
/>
<SideBarButton icon={FaMagic} path="/customCommands" text="Custom Commands" iconSize={25} />
<SideBarButton
icon={SiApollographql}
path="/apolloClient/cache"
matchPath="/apolloClient"
text="Apollo Client"
/>
<Spacer />
<SideBarButton icon={MdLiveHelp} path="/help" text="Help" hideTopBar />
</SideBarContainer>
Expand Down
118 changes: 118 additions & 0 deletions apps/reactotron-app/src/renderer/pages/apolloClient/Cache.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import React from "react"
import styled from "styled-components"
import { Header } from "reactotron-core-ui"
import { MdWarning } from "react-icons/md"
import { HiDocumentSearch, HiOutlinePencilAlt } from "react-icons/hi"
import { TbDatabaseDollar } from "react-icons/tb"
import { Title } from "../reactNative/components/Shared"

const Container = styled.div`
display: flex;
flex-direction: column;
width: 100%;
`

const StorybookContainer = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`

const TopSection = styled.div`
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
`

const WarningContainer = styled.div`
display: flex;
color: ${(props) => props.theme.warning};
background-color: ${(props) => props.theme.backgroundDarker};
border-top: 1px solid ${(props) => props.theme.chromeLine};
align-items: center;
padding: 0 20px;
`
const WarningDescription = styled.div`
margin-left: 20px;
`

function Cache() {
return (
<Container>
<Header
isDraggable
tabs={[
{
text: "Cache",
icon: TbDatabaseDollar,
isActive: true,

// eslint-disable-next-line @typescript-eslint/no-empty-function
onClick: () => {},
},
{
text: "Queries",
icon: HiDocumentSearch,
isActive: false,
onClick: () => {
// TODO: Couldn't get react-router-dom to do it for me so I forced it.
window.location.hash = "#/apolloClient/queries"
},
},
{
text: "Mutations",
icon: HiOutlinePencilAlt,
isActive: false,
onClick: () => {
// TODO: Couldn't get react-router-dom to do it for me so I forced it.
window.location.hash = "#/apolloClient/mutations"
},
},
]}
// actions={[
// {
// tip: "Search",
// icon: MdSearch,
// onClick: () => {
// toggleSearch()
// },
// },
// {
// tip: "Filter",
// icon: MdFilterList,
// onClick: () => {
// openFilter()
// },
// },
// {
// tip: "Reverse Order",
// icon: MdSwapVert,
// onClick: () => {
// toggleReverse()
// },
// },
// {
// tip: "Clear",
// icon: MdDeleteSweep,
// onClick: () => {
// clearSelectedConnectionCommands()
// },
// },
// ]}
/>
<StorybookContainer>
<TopSection>
<Title>TODO (utilize state subscription for right now)</Title>
</TopSection>
<WarningContainer>
<MdWarning size={60} />
<WarningDescription>This is preview feature.</WarningDescription>
</WarningContainer>
</StorybookContainer>
</Container>
)
}

export default Cache
117 changes: 117 additions & 0 deletions apps/reactotron-app/src/renderer/pages/apolloClient/Mutations.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React from "react"
import styled from "styled-components"
import { Header } from "reactotron-core-ui"
import { MdWarning } from "react-icons/md"
import { HiDocumentSearch, HiOutlinePencilAlt } from "react-icons/hi"
import { TbDatabaseDollar } from "react-icons/tb"
import { Title } from "../reactNative/components/Shared"

const Container = styled.div`
display: flex;
flex-direction: column;
width: 100%;
`

const StorybookContainer = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`

const TopSection = styled.div`
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
`

const WarningContainer = styled.div`
display: flex;
color: ${(props) => props.theme.warning};
background-color: ${(props) => props.theme.backgroundDarker};
border-top: 1px solid ${(props) => props.theme.chromeLine};
align-items: center;
padding: 0 20px;
`
const WarningDescription = styled.div`
margin-left: 20px;
`

function Mutations() {
return (
<Container>
<Header
isDraggable
tabs={[
{
text: "Cache",
icon: TbDatabaseDollar,
isActive: false,
onClick: () => {
// TODO: Couldn't get react-router-dom to do it for me so I forced it.
window.location.hash = "#/apolloClient/cache"
},
},
{
text: "Queries",
icon: HiDocumentSearch,
isActive: false,
onClick: () => {
// TODO: Couldn't get react-router-dom to do it for me so I forced it.
window.location.hash = "#/apolloClient/queries"
},
},
{
text: "Mutations",
icon: HiOutlinePencilAlt,
isActive: true,
// eslint-disable-next-line @typescript-eslint/no-empty-function
onClick: () => {},
},
]}
// actions={[
// {
// tip: "Search",
// icon: MdSearch,
// onClick: () => {
// toggleSearch()
// },
// },
// {
// tip: "Filter",
// icon: MdFilterList,
// onClick: () => {
// openFilter()
// },
// },
// {
// tip: "Reverse Order",
// icon: MdSwapVert,
// onClick: () => {
// toggleReverse()
// },
// },
// {
// tip: "Clear",
// icon: MdDeleteSweep,
// onClick: () => {
// clearSelectedConnectionCommands()
// },
// },
// ]}
/>
<StorybookContainer>
<TopSection>
<Title>TODO</Title>
</TopSection>
<WarningContainer>
<MdWarning size={60} />
<WarningDescription>This is preview feature.</WarningDescription>
</WarningContainer>
</StorybookContainer>
</Container>
)
}

export default Mutations
Loading

0 comments on commit b9bc85b

Please sign in to comment.