Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 06ad449

Browse files
committed
add styling for shell scripts
1 parent dc525fa commit 06ad449

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/components/code/CodeSwitcherSelect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function CodeSwitcherSelect({
6161
>
6262
<SelectTrigger
6363
aria-label="Switch code language"
64-
className="absolute right-2 top-[3px] z-10 hidden h-8 w-28 bg-white/5 text-2xs font-medium text-zinc-400 ring-1 ring-inset ring-zinc-300/10 hover:bg-white/7.5 dark:bg-white/2.5 dark:hover:bg-white/5 md:flex"
64+
className="absolute right-2 top-[2.5px] z-10 hidden h-8 w-28 bg-white/5 text-2xs font-medium text-zinc-400 ring-1 ring-inset ring-zinc-300/10 hover:bg-white/7.5 dark:bg-white/2.5 dark:hover:bg-white/5 md:flex"
6565
>
6666
<SelectValue />
6767
</SelectTrigger>
@@ -78,7 +78,7 @@ export function CodeSwitcherSelect({
7878
onChange={(e) => setCurrentLanguage(e.target.value as LanguageId)}
7979
className={cn(
8080
'flex h-8 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
81-
'absolute right-2 top-[3px] z-10 w-24 bg-white/5 font-sans text-2xs font-medium text-zinc-400 ring-1 ring-inset ring-zinc-300/10 hover:bg-white/7.5 dark:bg-white/2.5 dark:hover:bg-white/5 md:hidden',
81+
'absolute right-2 top-[2.5px] z-10 w-24 bg-white/5 font-sans text-2xs font-medium text-zinc-400 ring-1 ring-inset ring-zinc-300/10 hover:bg-white/7.5 dark:bg-white/2.5 dark:hover:bg-white/5 md:hidden',
8282
)}
8383
value={selectedLang}
8484
>

src/components/code/CopyButton.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import { cn } from '@/lib/utils'
77

88
export function CopyButton({
99
code,
10-
showPanel,
1110
className,
1211
}: {
1312
code: string
14-
showPanel?: boolean
1513
className?: string
1614
}) {
1715
const [copyCount, setCopyCount] = useState(0)
@@ -30,8 +28,7 @@ export function CopyButton({
3028
<button
3129
type="button"
3230
className={cn(
33-
'group/button absolute right-2 h-8 rounded-md px-1.5 py-1 text-2xs font-medium backdrop-blur transition',
34-
showPanel ? 'top-12' : 'top-2.5',
31+
'group/button absolute right-2 top-2.5 h-8 rounded-md px-1.5 py-1 text-2xs font-medium backdrop-blur transition',
3532
copied
3633
? 'bg-primary-400/10 ring-primary-400/20'
3734
: 'bg-white/5 ring-1 ring-inset ring-zinc-300/10 hover:bg-white/7.5 dark:bg-white/2.5 dark:hover:bg-white/5',

src/components/code/Pre.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,21 @@ const Pre: React.FC<Props> = ({
4141

4242
const showFileNamePanel = showPanel && !!title
4343

44+
const isBash = highlighted.lang === 'shellscript'
45+
4446
return (
4547
<>
48+
{isBash && !showFileNamePanel && (
49+
<div className="relative flex h-9 items-center justify-start pr-12 font-display text-2xs text-zinc-300 sm:text-xs">
50+
{/* one-off breakpoint to hide the filename on extremely narrow screens - to avoid interfering with the lang select */}
51+
<div className="relative flex h-full items-center justify-center gap-x-1 px-4">
52+
<div className="size-[6px] rounded-full bg-zinc-300/10" />
53+
<div className="size-[6px] rounded-full bg-zinc-300/10" />
54+
<div className="size-[6px] rounded-full bg-zinc-300/10" />
55+
</div>
56+
<div className="absolute bottom-0 h-[1px] w-full bg-zinc-300/5" />
57+
</div>
58+
)}
4659
{showFileNamePanel && (
4760
<div className="relative flex h-10 items-center justify-start pr-12 font-display text-2xs text-zinc-300 sm:text-xs">
4861
{/* one-off breakpoint to hide the filename on extremely narrow screens - to avoid interfering with the lang select */}
@@ -55,13 +68,16 @@ const Pre: React.FC<Props> = ({
5568
<div className="absolute bottom-0 h-[1px] w-full bg-zinc-300/5" />
5669
</div>
5770
)}
58-
<CopyButton code={highlighted.code} showPanel={showPanel} />
71+
<CopyButton
72+
code={highlighted.code}
73+
className={cn(showFileNamePanel && 'top-12', isBash && 'top-11')}
74+
/>
5975
<CodeHikePre
6076
code={highlighted}
6177
handlers={handlers}
6278
className={cn(
6379
'overflow-auto overscroll-x-contain p-4',
64-
showPanel && !title && 'pt-8', // add padding to ensure the code doesn't touch the top of the panel
80+
showPanel && !title && 'pt-7', // add padding to ensure the code doesn't touch the top of the panel
6581
className,
6682
)}
6783
style={{

0 commit comments

Comments
 (0)