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

Sidebar rework #503

Merged
merged 8 commits into from
Oct 18, 2023
Merged
14 changes: 11 additions & 3 deletions src/components/App/SideBar/AudioClip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ const _AudioClip = () => {
const isPlay = usePlayerStore((s) => s.isPlaying)
const setIsPlaying = usePlayerStore((s) => s.setIsPlaying)

const { image_url: imageUrl, description, date, boost, type, id, episode_title: episodeTitle } = selectedNode || {}
const {
image_url: imageUrl,
show_title: showTitle,
date,
boost,
type,
id,
episode_title: episodeTitle,
} = selectedNode || {}

useEffect(
() => () => {
Expand Down Expand Up @@ -87,12 +95,12 @@ const _AudioClip = () => {
<StyledEpisode
boostCount={boost || 0}
date={date || 0}
description={formatDescription(description)}
episodeTitle={formatDescription(episodeTitle)}
id={id}
imageUrl={imageUrl || 'audio_default.svg'}
isSelectedView
onClick={() => null}
title={episodeTitle}
showTitle={formatDescription(showTitle)}
type={type}
/>
{/* </Flex> */}
Expand Down
67 changes: 67 additions & 0 deletions src/components/App/SideBar/Description/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import styled from 'styled-components'
import NotesIcon from '~/components/Icons/NotesIcon'
import { Flex } from '~/components/common/Flex'
import { NodeExtended } from '~/types'
import { colors } from '~/utils/colors'

type DescriptionProps = {
stateless?: boolean
node: NodeExtended | null
}

export const Description = ({ stateless, node }: DescriptionProps) => (
<Flex grow={1} shrink={1}>
<Header>
{stateless && (
<Heading>
<div className="icon">
<NotesIcon />
</div>
<div className="title">Description</div>
</Heading>
)}
</Header>
<Box>{node?.description ? `"${node?.description}"` : '...'}</Box>
</Flex>
)

const Heading = styled(Flex).attrs({
direction: 'row',
align: 'center',
})`
.icon {
font-size: 16px;
color: ${colors.GRAY3};
margin-right: 7px;
}

.title {
color: ${colors.white};
font-family: Barlow;
font-size: 10px;
font-style: normal;
font-weight: 700;
line-height: normal;
letter-spacing: 1px;
text-transform: uppercase;
}
`

const Header = styled(Flex).attrs({
direction: 'row',
align: 'center',
justify: 'space-between',
})`
margin-bottom: 18px;
`

const Box = styled(Flex)`
color: ${colors.white};
text-overflow: ellipsis;
whitespace: nowrap;
font-family: Barlow;
font-size: 13px;
font-style: normal;
font-weight: 400;
line-height: 18px;
`
14 changes: 7 additions & 7 deletions src/components/App/SideBar/Relevance/Episode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ const EpisodeWrapper = styled(Flex).attrs({
type Props = {
boostCount: number
date: number
description: string
episodeTitle: string
isSelectedView?: boolean
id?: string
imageUrl: string
title?: string
showTitle?: string
text?: string
type?: string
name?: string
Expand All @@ -60,11 +60,11 @@ type Props = {
export const Episode = ({
boostCount,
date,
description,
episodeTitle,
id,
isSelectedView = false,
imageUrl,
title,
showTitle,
type,
text,
name,
Expand Down Expand Up @@ -94,10 +94,10 @@ export const Episode = ({
</Flex>
</Flex>

<Description data-testid="episode-description">{description}</Description>
<Description data-testid="episode-description">{episodeTitle}</Description>
<Flex direction="row" justify="flex-start">
{Boolean(date) && <Date>{moment.unix(date).format('ll')}</Date>}
{Boolean(title) && <Title>{title}</Title>}
{Boolean(showTitle) && <Title>{showTitle}</Title>}
{!isSelectedView && boostCount > 0 && (
<Flex style={{ marginLeft: 'auto' }}>
<BoostAmt amt={boostCount} />
Expand All @@ -108,7 +108,7 @@ export const Episode = ({
</Flex>
)}
{['person', 'guest'].includes(type as string) && (
<TypePerson imageUrl={imageUrl} name={name || ''} title={title || ''} />
<TypePerson imageUrl={imageUrl} name={name || ''} title={showTitle || ''} />
)}
{type === 'tweet' && (
<TypeTweet
Expand Down
6 changes: 3 additions & 3 deletions src/components/App/SideBar/Relevance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export const Relevance = ({ isSearchResult }: Props) => {
{currentNodes.map((n, index) => {
const {
image_url: imageUrl,
description,
date,
boost,
type,
id,
episode_title: episodeTitle,
show_title: showTitle,
node_type: nodeType,
text,
name,
Expand All @@ -80,14 +80,14 @@ export const Relevance = ({ isSearchResult }: Props) => {
key={index.toString()}
boostCount={boost || 0}
date={date || 0}
description={formatDescription(description)}
episodeTitle={formatDescription(episodeTitle)}
id={id}
imageUrl={imageUrl || 'audio_default.svg'}
name={name || ''}
onClick={() => handleNodeClick(n)}
profilePicture={profilePicture}
showTitle={formatDescription(showTitle)}
text={text || ''}
title={episodeTitle}
twitterHandle={twitterHandle}
type={type || nodeType}
verified={verified}
Expand Down
10 changes: 1 addition & 9 deletions src/components/App/SideBar/Transcript/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,11 @@ export const Transcript = ({ stateless, node }: TranscriptProps) => {
</CloseButton>
)}
</Header>
<ScrollWrapper>
<Box>{node?.text ? `"${node?.text}"` : '...'}</Box>
</ScrollWrapper>
<Box>{node?.text ? `"${node?.text}"` : '...'}</Box>
</Flex>
)
}

const ScrollWrapper = styled(Flex)(() => ({
overflow: 'auto',
flex: 1,
width: '100%',
}))

const Heading = styled(Flex).attrs({
direction: 'row',
align: 'center',
Expand Down
43 changes: 27 additions & 16 deletions src/components/App/SideBar/YouTube/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ import { useDataStore } from '~/stores/useDataStore'
import { formatDescription } from '~/utils/formatDescription'
import { videoTimetoSeconds } from '~/utils/videoTimetoSeconds'
import { BoostAmt } from '../../Helper/BoostAmt'
import { Description } from '../Description'
import { Episode } from '../Relevance/Episode'
import { Transcript } from '../Transcript'

export const YouTube = () => {
const selectedNode = useDataStore((s) => s.selectedNode)
const playerRef = useRef<ReactPlayer | null>(null)
const scrollTargetRef = useRef<HTMLDivElement | null>(null)

const {
link,
timestamp,
image_url: imageUrl,
description,
date,
boost,
type,
id,
show_title: showTitle,
episode_title: episodeTitle,
ref_id: refId,
} = selectedNode || {}

Expand All @@ -35,6 +37,10 @@ export const YouTube = () => {
if (playerRef.current) {
playerRef.current?.seekTo(secs)
}

if (scrollTargetRef.current) {
scrollTargetRef.current.scrollTo({ top: 0, behavior: 'auto' })
}
}, [playerRef, secs])

if (!selectedNode) {
Expand All @@ -51,23 +57,29 @@ export const YouTube = () => {
<StyledEpisode
boostCount={boostAmount || 0}
date={date || 0}
description={formatDescription(description)}
episodeTitle={formatDescription(episodeTitle)}
id={id}
imageUrl={imageUrl || 'video_default.svg'}
isSelectedView
onClick={() => null}
title={showTitle}
showTitle={showTitle}
type={type}
/>
<StyledDivider />
<BoostWrapper>
<BoostAmt amt={boostAmount} />
<Booster content={selectedNode} count={boostAmount} refId={refId} updateCount={setBoostAmount} />
</BoostWrapper>
<StyledDivider />
<TranscriptWrapper grow={1} shrink={1}>
<Transcript node={selectedNode} stateless />
</TranscriptWrapper>
<div ref={scrollTargetRef} style={{ overflow: 'auto', flex: 1, width: '100%' }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make this a styled component

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. I wasn't exactly sure what to do with it since it's acting to reset the scroll.

<BoostWrapper>
<BoostAmt amt={boostAmount} />
<Booster content={selectedNode} count={boostAmount} refId={refId} updateCount={setBoostAmount} />
</BoostWrapper>
<StyledDivider />
<TextWrapper>
<Description node={selectedNode} stateless />
</TextWrapper>
<StyledDivider />
<TextWrapper>
<Transcript node={selectedNode} stateless />
</TextWrapper>
</div>
</Wrapper>
)
}
Expand All @@ -88,11 +100,11 @@ const PlayerWrapper = styled(Flex)`
const BoostWrapper = styled(Flex)`
flex-direction: row;
justify-content: space-between;
padding: 0 18px 18px;
padding: 18px 18px 18px;
`

const TranscriptWrapper = styled(Flex)`
padding: 0 18px 18px;
const TextWrapper = styled(Flex)`
padding: 18px 18px 18px;
`

const StyledEpisode = styled(Episode)`
Expand All @@ -104,7 +116,6 @@ const StyledEpisode = styled(Episode)`
`

const StyledDivider = styled(Divider)`
margin-bottom: 10px;
margin: auto 0px 10px 0px;
margin: auto 0px 1px 0px;
opacity: 75%;
`
Loading