Skip to content

Commit

Permalink
feat: add flag to anchor encode output + chip color changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILLIPS71 committed May 12, 2024
1 parent 6506c2b commit f9b8084
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/src/components/interfaces/encode/chips/EncodeSpeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ const EncodeSpeed: React.FC<EncodeSpeedProps> = ({ $key }) => {

return (
<>
<Chip color="info">{data.speed.frames} fps</Chip>
<Chip color="warning">{data.speed.frames} fps</Chip>

<Chip color="info">{filesize(data.speed.bitrate * 0.125, { bits: true }).toLowerCase()}/s</Chip>
<Chip color="success">{filesize(data.speed.bitrate * 0.125, { bits: true }).toLowerCase()}/s</Chip>

<Chip color="info">{data.speed.scale.toFixed(2)}x</Chip>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const EncodeScriptPanel: React.FC<EncodeScriptPanelProps> = ({ $key }) => {
</Card.Header>

<Card.Body className="overflow-y-auto">
<EncodeOutputWidget $key={data} />
<EncodeOutputWidget isAnchored $key={data} />
</Card.Body>
</Card>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ const EncodeOperationWidget: React.FC<EncodeOperationWidgetProps> = ({ $key }) =
</Table.Cell>
<Table.Cell className="text-right">
<Typography.Text>
<Chip color="danger" title={dayjs(data.updated_at).format('L LT')}>
<Chip
className="text-pink-500 bg-pink-500/20 border-pink-500"
title={dayjs(data.updated_at).format('L LT')}
>
{dayjs(data.updated_at).fromNow()}
</Chip>
</Typography.Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { EncodeOutputWidgetFragment$key } from '@/__generated__/EncodeOutputWidgetFragment.graphql'
import type { EncodeOutputWidgetSubscription } from '@/__generated__/EncodeOutputWidgetSubscription.graphql'

import React from 'react'
import { graphql, useFragment, useSubscription } from 'react-relay'

import CodeBlock from '@/components/ui/code-block/CodeBlock'
Expand All @@ -23,9 +24,10 @@ const SUBSCRIPTION = graphql`

type EncodeOutputWidgetProps = {
$key: EncodeOutputWidgetFragment$key
isAnchored?: boolean
}

const EncodeOutputWidget: React.FC<EncodeOutputWidgetProps> = ({ $key }) => {
const EncodeOutputWidget: React.FC<EncodeOutputWidgetProps> = ({ $key, isAnchored }) => {
const data = useFragment(FRAGMENT, $key)

useSubscription<EncodeOutputWidgetSubscription>({
Expand All @@ -39,11 +41,13 @@ const EncodeOutputWidget: React.FC<EncodeOutputWidgetProps> = ({ $key }) => {
},
})

return (
<ScrollAnchor>
<CodeBlock language="powershell">{data.output}</CodeBlock>
</ScrollAnchor>
)
const block = React.useCallback(() => <CodeBlock language="powershell">{data.output}</CodeBlock>, [data.output])

return isAnchored ? <ScrollAnchor>{block()}</ScrollAnchor> : block()
}

EncodeOutputWidget.defaultProps = {
isAnchored: false,
}

export default EncodeOutputWidget

0 comments on commit f9b8084

Please sign in to comment.