Skip to content

Commit

Permalink
Add EmbedPage component and refactor EmbedWidget
Browse files Browse the repository at this point in the history
- Introduced a new EmbedPage component that displays a loading state while fetching issues using the IssuesList component.
- Removed the theme selection from EmbedWidget, simplifying the embed code generation.
- Updated the embed code to remove the theme parameter and adjusted the height of the Textarea for better usability.
  • Loading branch information
aliirz committed Dec 14, 2024
1 parent 0da3183 commit 9b94232
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
16 changes: 16 additions & 0 deletions app/embed/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Suspense } from 'react'
import { IssuesList } from "@/components/IssuesList"

export default function EmbedPage() {
return (
<Suspense fallback={
<div className="flex items-center justify-center p-4">
<div className="text-sm text-muted-foreground">Loading issues...</div>
</div>
}>
<div className="p-2">
<IssuesList minimal={true} />
</div>
</Suspense>
)
}
22 changes: 3 additions & 19 deletions components/EmbedWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import { Textarea } from "@/components/ui/textarea"

export function EmbedWidget() {
const [copied, setCopied] = useState(false)
const [theme, setTheme] = useState<'light' | 'dark'>('light')
const [height, setHeight] = useState("600")

const embedCode = `<iframe
src="${process.env.NEXT_PUBLIC_APP_URL}/embed?theme=${theme}"
src="${process.env.NEXT_PUBLIC_APP_URL}/embed"
width="100%"
height="${height}px"
frameborder="0"
Expand All @@ -29,21 +28,6 @@ export function EmbedWidget() {
return (
<div className="space-y-6">
<div className="grid gap-4 sm:grid-cols-2">
<div className="space-y-2">
<label className="text-sm font-medium">Theme</label>
<Select
value={theme}
onValueChange={(value: 'light' | 'dark') => setTheme(value)}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="light">Light</SelectItem>
<SelectItem value="dark">Dark</SelectItem>
</SelectContent>
</Select>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Height (px)</label>
<Input
Expand All @@ -60,7 +44,7 @@ export function EmbedWidget() {
<Textarea
value={embedCode}
readOnly
className="font-mono text-sm min-h-[100px] resize-none"
className="font-mono text-sm min-h-[155px] resize-none"
/>
<Button
size="sm"
Expand All @@ -80,7 +64,7 @@ export function EmbedWidget() {
className="rounded border bg-background"
style={{ height: `${height}px` }}
>
<IssuesList minimal={true} theme={theme} />
<IssuesList minimal={true} />
</div>
</div>
</div>
Expand Down

0 comments on commit 9b94232

Please sign in to comment.