Skip to content

Commit

Permalink
feat: updated CliCommand component to handle longer tokens and wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
nimish-ks committed Dec 5, 2024
1 parent 9f2bd34 commit 43ef8ec
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions frontend/components/dashboard/CliCommand.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import CopyButton from 'components/common/CopyButton'

export const CliCommand = (props: { command: string; comment?: string; prefix?: string }) => {
const prefix = props.prefix || 'phase'
export const CliCommand = (props: {
command: string;
comment?: string;
prefix?: string;
wrap?: boolean;
}) => {
const prefix = props.prefix ?? 'phase'
const wrap = props.wrap ?? false

const prefixedCommand = `${prefix} ${props.command}`
const prefixedCommand = prefix ? `${prefix} ${props.command}` : props.command

return (
<div className="group relative rounded-lg border border-neutral-500/40 bg-zinc-300/50 dark:bg-zinc-800/50 p-4 text-left text-sm text-zinc-900 dark:text-zinc-100">
<pre className="whitespace-pre-wrap">
<span className="text-emerald-800 dark:text-emerald-300">{prefix}</span> {props.command}{' '}
{props.comment && (
<span className="text-neutral-500">
{'#'}
{props.comment}
</span>
)}
</pre>
<div className="absolute right-4 top-3.5 ">
<div className={`${!wrap ? 'overflow-x-auto scrollbar-thin scrollbar-track-transparent scrollbar-thumb-neutral-600' : ''}`}>
<pre className={`${wrap ? 'whitespace-pre-wrap break-all' : 'whitespace-pre'}`}>
{prefix && (
<span className="text-emerald-800 dark:text-emerald-300">{prefix}</span>
)}
{prefix && ' '}
{props.command}{' '}
{props.comment && (
<span className="text-neutral-500">
{'#'}
{props.comment}
</span>
)}
</pre>
</div>
<div className="absolute right-4 top-3.5">
<CopyButton value={prefixedCommand} />
</div>
</div>
Expand Down

0 comments on commit 43ef8ec

Please sign in to comment.