-
Notifications
You must be signed in to change notification settings - Fork 52
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
Cleanup & Adjustment to support static site generation #50
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ const nextConfig = { | |
}, | ||
], | ||
}, | ||
output: 'export' | ||
}; | ||
|
||
export default nextConfig; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import { useState } from 'react'; | ||
import { Clipboard } from 'lucide-react'; | ||
import { DiceCmdMeta } from '@/data/command'; | ||
|
||
export default function CommandPage({ title, syntax, body, url }: DiceCmdMeta) { | ||
const [copied, setCopied] = useState(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems unrelated to static site generation, and it breaks the behaviour of "Copied" showing up is that expected? |
||
interface CommandPageProps extends DiceCmdMeta { | ||
onCopy?: () => void; | ||
} | ||
|
||
export default function CommandPage({ | ||
title, | ||
syntax, | ||
body, | ||
url, | ||
onCopy, | ||
}: CommandPageProps) { | ||
const handleCopy = () => { | ||
navigator.clipboard.writeText(syntax); | ||
setCopied(true); | ||
setTimeout(() => setCopied(false), 2000); | ||
navigator.clipboard.writeText(syntax).then(() => { | ||
if (onCopy) { | ||
onCopy(); | ||
} | ||
}); | ||
}; | ||
|
||
return ( | ||
|
@@ -17,16 +26,13 @@ export default function CommandPage({ title, syntax, body, url }: DiceCmdMeta) { | |
|
||
<div className="flex items-center justify-between mb-4 pt-4"> | ||
<h3 className="text-gray-700 text-2xl font-semibold">Syntax</h3> | ||
<div className="flex flex-row"> | ||
{copied && <div className="text-green-500 text-sm">Copied!</div>} | ||
<button | ||
onClick={handleCopy} | ||
className="text-gray-500 hover:text-gray-700 flex items-center ml-4" | ||
title="Copy to clipboard" | ||
> | ||
<Clipboard className="w-5 h-5" /> | ||
</button> | ||
</div> | ||
<button | ||
onClick={handleCopy} | ||
className="text-gray-500 hover:text-gray-700 flex items-center ml-4" | ||
title="Copy to clipboard" | ||
> | ||
<Clipboard className="w-5 h-5" /> | ||
</button> | ||
</div> | ||
|
||
<div className="bg-gray-200 rounded-lg relative overflow-x-auto p-4"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,25 @@ import React from 'react'; | |
interface ButtonProps { | ||
children: React.ReactNode; | ||
className?: string; | ||
variant?: 'outline'; | ||
variant?: 'default' | 'outline'; // Added default variant | ||
} | ||
|
||
export function Button({ children, className }: ButtonProps) { | ||
export function Button({ | ||
children, | ||
className = '', | ||
variant = 'default', | ||
}: ButtonProps) { | ||
const baseClasses = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't seem like this should be inside the function component, would re-define on every render. |
||
'inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2'; | ||
const variantClasses = { | ||
default: 'bg-gray-900 text-white hover:bg-gray-700 focus:ring-gray-400', | ||
outline: | ||
'border border-gray-900 bg-transparent text-gray-900 hover:bg-gray-200 focus:ring-gray-400', | ||
}; | ||
|
||
return ( | ||
<button | ||
className={`inline-flex items-center justify-center rounded-md border border-transparent bg-gray-900 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 ${className}`} | ||
className={`${baseClasses} ${variantClasses[variant]} ${className}`} // Combine all classes | ||
> | ||
{children} | ||
</button> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd also need to move
export const SHELL_COMMAND_URL = 'http://localhost:8080/shell/exec';
as part of.env
for this, otherwise won't be configurable.