Skip to content

Commit

Permalink
feat: closes #402 and #454 (#480)
Browse files Browse the repository at this point in the history
* feat: closes #402 and #454

* fix: prettier

* feat: adding two new admins kevkevin and Tom Smith

---------

Co-authored-by: Расул <[email protected]>
Co-authored-by: kevkevin <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent ced7507 commit 058aafa
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 122 deletions.
4 changes: 2 additions & 2 deletions build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Second Brain</title>
<script type="module" crossorigin src="/assets/index-920c478f.js"></script>
<link rel="stylesheet" href="/assets/index-381991a0.css">
<script type="module" crossorigin src="/assets/index-eebde016.js"></script>
<link rel="stylesheet" href="/assets/index-516c5c0e.css">
</head>
<body style="background: #000">
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
3 changes: 1 addition & 2 deletions src/components/App/MainToolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ export const MainToolbar = () => {
const Wrapper = styled(Flex).attrs({
align: 'flex-start',
direction: 'column',
grow: 1,
justify: 'flex-start',
})`
width: 64px;
flex: 0 0 64px;
z-index: 31;
transition: opacity 1s;
background: ${colors.BG2};
Expand Down
21 changes: 14 additions & 7 deletions src/components/App/SideBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useDataStore, useSelectedNode } from '~/stores/useDataStore'
import { colors } from '~/utils/colors'
import clsx from 'clsx'
import { ClipLoader } from 'react-spinners'
import { FetchLoaderText } from '~/components/common/Loader'
import { useGraphData } from '~/components/DataRetriever'
import ChevronLeftIcon from '~/components/Icons/ChevronLeftIcon'
import ClearIcon from '~/components/Icons/ClearIcon'
Expand Down Expand Up @@ -88,13 +89,19 @@ const Content = forwardRef<HTMLDivElement, ContentProp>(({ onSubmit, subViewOpen
</Search>
{searchTerm && (
<SearchDetails>
<div className="left">
<span className="count">{data.nodes.length}</span>
<span className="label"> results</span>
</div>
<div className="right">
<TeachMe />
</div>
{isLoading ? (
<FetchLoaderText />
) : (
<>
<div className="left">
<span className="count">{data.nodes.length}</span>
<span className="label"> results</span>
</div>
<div className="right">
<TeachMe />
</div>
</>
)}
</SearchDetails>
)}
</SearchWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import Table from './Table'
const admins = [
'02c431e64078b10925584d64824c9d1d12eca05e2c56660ffa5ac84aa6946adfe5',
'03a9a8d953fe747d0dd94dd3c567ddc58451101e987e2d2bf7a4d1e10a2c89ff38',
'024efa31d1e4f98bccc415b222c9d971866013ad6f95f7d1ed9e8be8e3355a36ff',
'03bfe6723c06fb2b7546df1e8ca1a17ae5c504615da32c945425ccbe8d3ca6260d',
'024efa31d1e4f98bccc415b222c9d971866013ad6f95f7d1ed9e8be8e3355a36ff',
]

export const Sources = () => {
Expand Down
35 changes: 0 additions & 35 deletions src/components/Universe/Graph/Icons/index.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions src/components/Universe/Graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useDataStore } from '~/stores/useDataStore'
import { GraphData } from '~/types'
import { Cubes } from './Cubes'
import { Earth } from './Earth'
import { GraphLoadingIcon } from './Icons'
import { Particles } from './Particles'
import { Segment } from './Segment'
import { NodeDetailsPanel } from './UI'
Expand All @@ -29,7 +28,7 @@ export const Graph = () => {
}, [showSelectionGraph, graphStyle])

if (isLoading) {
return <GraphLoadingIcon />
return null
}

return (
Expand Down
39 changes: 28 additions & 11 deletions src/components/Universe/Preloader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
import styled from 'styled-components'
import clsx from 'clsx'
import { ClipLoader } from 'react-spinners'
import { colors } from '~/utils/colors'
import styled from 'styled-components'
import { Flex } from '~/components/common/Flex'
import { GRAPH_FOG_COLOR } from '~/constants'
import { useAppStore } from '~/stores/useAppStore'
import { colors } from '~/utils/colors'

export const Preloader = () => (
<Loader align="center" justify="center">
<ClipLoader color={GRAPH_FOG_COLOR} size={100} />
</Loader>
)
type Props = {
fullSize?: boolean
}

export const Preloader = ({ fullSize = true }: Props) => {
const sidebarIsOpen = useAppStore((s) => s.sidebarIsOpen)

return (
<Loader align="center" className={clsx({ 'sidebar-is-open': sidebarIsOpen && !fullSize })} justify="center">
<ClipLoader color={colors.SECONDARY_BLUE} size={64} />
</Loader>
)
}

const Loader = styled(Flex)`
position: fixed;
width: 100%;
height: 100vh;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
background-color: ${colors.black};
z-index: 1;
&.sidebar-is-open {
span {
margin-left: -390px;
}
}
`
38 changes: 33 additions & 5 deletions src/components/Universe/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ import { useControls } from 'leva'
import { BlendFunction, Resolution } from 'postprocessing'
import { Perf } from 'r3f-perf'
import { Suspense, memo, useCallback, useMemo } from 'react'
import styled from 'styled-components'
import { getNodeColorByType } from '~/components/Universe/Graph/constant'
import { isDevelopment } from '~/constants'
import { useControlStore } from '~/stores/useControlStore'
import { useSelectedNode } from '~/stores/useDataStore'
import { useDataStore, useSelectedNode } from '~/stores/useDataStore'
import { colors } from '~/utils/colors'
import { addToGlobalForE2e } from '~/utils/tests'
import { Flex } from '../common/Flex'
import { Controls } from './Controls'
import { initialCameraPosition } from './Controls/CameraAnimations/constants'
import { Graph } from './Graph'
import { Lights } from './Lights'
import { Overlay } from './Overlay'
import { Preloader } from './Preloader'
import { outlineEffectColor } from './constants'

const Fallback = () => (
<Html>
<MyLoader />
<Loader />
</Html>
)
Expand Down Expand Up @@ -89,6 +93,8 @@ const _Universe = () => {
useControlStore((s) => s.setUserMovedCamera),
]

const isLoading = useDataStore((s) => s.isFetching)

const onWheelHandler = useCallback(
(e: React.WheelEvent) => {
const { target } = e
Expand Down Expand Up @@ -119,13 +125,11 @@ const _Universe = () => {
const onCreatedHandler = useCallback((s: RootState) => addToGlobalForE2e(s, 'threeState'), [])

return (
<>
<Wrapper>
<Overlay />

<Suspense fallback={null}>
<Canvas camera={cameraProps} id="universe-canvas" onCreated={onCreatedHandler} onWheel={onWheelHandler}>
{isDevelopment && <Perf position="top-right" />}

<Suspense fallback={<Fallback />}>
<Preload />

Expand All @@ -137,8 +141,32 @@ const _Universe = () => {
</Suspense>
</Canvas>
</Suspense>
</>
{isLoading && <Preloader fullSize={false} />}
</Wrapper>
)
}

const Wrapper = styled(Flex)`
flex: 1 0 100%;
position: relative;
`

const MyLoader = styled(Flex)`
background: ${colors.black};
width: 100%;
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
align-items: center;
justify-content: center;
&.sidebar-is-open {
.span {
margin-left: -390px;
}
}
`

export const Universe = memo(_Universe)
84 changes: 44 additions & 40 deletions src/components/common/Loader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,65 +1,69 @@
import { clsx } from 'clsx'
import { useEffect, useState } from 'react'
import ClipLoader from 'react-spinners/ClipLoader'
import { BeatLoader } from 'react-spinners'
import styled from 'styled-components'
import { Flex } from '~/components/common/Flex'
import { Text } from '~/components/common/Text'
import { ColorName, colors } from '~/utils/colors'
import { colors } from '~/utils/colors'

const messages = [
'Searching Podcast Index',
'Searching YouTube',
'Searching Twitter Spaces',
'Finding Transcripts',
'Loading Audio Clips',
'Loading Video Clips',
'Preparing Results',
['Searching', 'Podcast Index'],
['Searching', 'YouTube'],
['Searching', 'Twitter Spaces'],
['Finding', 'Transcripts'],
['Loading', 'Audio Clips'],
['Loading', 'Video Clips'],
['Preparing', 'Results'],
]

type Props = {
color?: ColorName
}

export const Loader = ({ color = 'white' }: Props) => {
export const FetchLoaderText = () => {
const [msgIndex, setMsgIndex] = useState(0)

useEffect(() => {
if (msgIndex === messages.length - 1) {
return
}

const messageTimeout = setTimeout(() => setMsgIndex((index) => (index + 1) % messages.length), 1000)
const messageTimeout = setTimeout(() => setMsgIndex((index) => (index + 1) % messages.length), 2000)

// eslint-disable-next-line consistent-return
return () => clearTimeout(messageTimeout)
}, [msgIndex])

return (
<Flex align="center" grow={1} id="loader" justify="center">
<Flex align="center" py={8}>
<Text color="primaryText1" kind="mediumBold">
{messages[msgIndex]}...
</Text>
</Flex>

<Flex pt={20}>
<ClipLoader color={colors[color]} loading size={26} />
</Flex>
</Flex>
<Wrapper direction="column">
{messages.map((i, index) => (
<Flex key={i[1]} className={clsx('raw-wrapper', { show: msgIndex === index })} direction="row">
<div className={clsx('action')}>{i[0]}</div>
<div className={clsx('entity')}>{i[1]}</div>
<div>
<BeatLoader color={colors.SECONDARY_BLUE} size={2} />
</div>
</Flex>
))}
</Wrapper>
)
}

export const FetchLoaderText = () => {
const [msgIndex, setMsgIndex] = useState(0)
const Wrapper = styled(Flex)`
overflow: hidden;
height: 20px;
position: relative;
.action {
color: ${colors.white};
margin-right: 8px;
}
useEffect(() => {
if (msgIndex === messages.length - 1) {
return
.raw-wrapper {
height: 0;
overflow: hidden;
transition: height 0.7s ease-in-out;
align-items: flex-end;
&.show {
height: 20px;
}
}
const messageTimeout = setTimeout(() => setMsgIndex((index) => (index + 1) % messages.length), 1000)

// eslint-disable-next-line consistent-return
return () => clearTimeout(messageTimeout)
}, [msgIndex])

return `${messages[msgIndex]}...`
}
.entity {
color: ${colors.SECONDARY_BLUE};
}
`
19 changes: 1 addition & 18 deletions src/network/fetchGraphData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,24 +321,7 @@ const getGraphData = async (searchterm: string) => {
try {
const dataInit = await fetchNodes(searchterm)

const dataSeries = dataInit.data_series
? [
{
...dataInit.data_series,
x: 0,
y: 0,
z: 0,
boost: null,
image_url: 'node_data.webp',
label: dataInit.data_series.title,
name: 'Name',
node_type: 'data_series',
ref_id: '',
type: 'data_series',
weight: 2,
} as Node,
]
: []
const dataSeries = Array.isArray(dataInit.data_series) ? dataInit.data_series : []

const data: Node[] = [...dataInit.exact, ...dataInit.related, ...dataSeries]

Expand Down

0 comments on commit 058aafa

Please sign in to comment.