Skip to content

Commit

Permalink
wistia player playground in nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
philipstubbs13 committed Aug 1, 2024
1 parent c55883c commit 564bcbd
Show file tree
Hide file tree
Showing 12 changed files with 379 additions and 259 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# dependencies
/node_modules
storybook-static/
/.pnp
.pnp.js
.yarn/install-state.gz
Expand Down
3 changes: 0 additions & 3 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const preview: Preview = {
date: /Date$/i,
},
},
docs: {
toc: true,
},
},
};

Expand Down
1 change: 1 addition & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "./globals.css";
const inter = Inter({ subsets: ["latin"] });

export const metadata: Metadata = {
title: "Wistia Video Player",
title: "Wistia Video Playground",
description:
"A video player component built using React and the Wistia Player API",
};
Expand Down
27 changes: 20 additions & 7 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,30 @@

import { WistiaVideoPlayer } from "@/components/wistia-video-player/WistiaVideoPlayer";
import Link from "next/link";
import { useSearchParams } from "next/navigation";

export default function Home() {
const searchParams = useSearchParams();
const videoId = searchParams.get("videoId") || "hb26s9rudm";

return (
<main>
<div className="w-full max-w-5xl mx-auto py-12 px-4 md:px-6">
<div className="space-y-4 text-center">
<h1 className="text-3xl font-bold">Wistia Video Player</h1>
<p className="text-muted-foreground">
A custom video player built using React and Wistia
</p>
<div className="flex justify-center space-x-4">
<h1 className="text-3xl font-bold">Wistia Video Playground</h1>
<div className="max-w-[600px] mx-auto">
<p className="text-muted-foreground">
A custom video player built using React and Wistia. You can use
this page as a playground to try out and test your different
Wistia videos.
</p>
<p className="text-muted-foreground pt-7">
To load a specific Wistia video, specify your Wistia video id
using the <b>videoId</b> url query param. For example:
</p>
</div>
<pre>https://wistia-video-player.vercel.app/?videoId=hb26s9rudm</pre>
<div className="flex justify-center space-x-4 pt-4">
<Link
href="https://github.com/philipstubbs13/wistia-video-player"
className="inline-flex h-10 items-center justify-center rounded-md bg-slate-900 px-4 py-2 text-sm font-medium text-slate-200 shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
Expand All @@ -22,15 +35,15 @@ export default function Home() {
GitHub
</Link>
<Link
href="https://www.chromatic.com/library?appId=66aa07fde316cf9b3445ce6d"
href="https://66aa07fde316cf9b3445ce6d-wzfdwyrtml.chromatic.com/?path=/docs/components-wistia-video-player--docs"
className="inline-flex h-10 items-center justify-center rounded-md border border-input bg-background px-4 py-2 text-sm font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
prefetch={false}
target={"_blank"}
>
Storybook
</Link>
</div>
<WistiaVideoPlayer videoId="hb26s9rudm" />
{videoId && <WistiaVideoPlayer videoId={videoId} />}
</div>
</div>
</main>
Expand Down
17 changes: 17 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "app/globals.css",
"baseColor": "slate",
"cssVariables": false,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
56 changes: 56 additions & 0 deletions components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"

const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-white transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 dark:ring-offset-slate-950 dark:focus-visible:ring-slate-300",
{
variants: {
variant: {
default: "bg-slate-900 text-slate-50 hover:bg-slate-900/90 dark:bg-slate-50 dark:text-slate-900 dark:hover:bg-slate-50/90",
destructive:
"bg-red-500 text-slate-50 hover:bg-red-500/90 dark:bg-red-900 dark:text-slate-50 dark:hover:bg-red-900/90",
outline:
"border border-slate-200 bg-white hover:bg-slate-100 hover:text-slate-900 dark:border-slate-800 dark:bg-slate-950 dark:hover:bg-slate-800 dark:hover:text-slate-50",
secondary:
"bg-slate-100 text-slate-900 hover:bg-slate-100/80 dark:bg-slate-800 dark:text-slate-50 dark:hover:bg-slate-800/80",
ghost: "hover:bg-slate-100 hover:text-slate-900 dark:hover:bg-slate-800 dark:hover:text-slate-50",
link: "text-slate-900 underline-offset-4 hover:underline dark:text-slate-50",
},
size: {
default: "h-10 px-4 py-2",
sm: "h-9 rounded-md px-3",
lg: "h-11 rounded-md px-8",
icon: "h-10 w-10",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)

export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean
}

const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
)
}
)
Button.displayName = "Button"

export { Button, buttonVariants }
25 changes: 25 additions & 0 deletions components/ui/input.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import * as React from "react"

import { cn } from "@/lib/utils"

export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}

const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
"flex h-10 w-full rounded-md border border-slate-200 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-800 dark:bg-slate-950 dark:ring-offset-slate-950 dark:placeholder:text-slate-400 dark:focus-visible:ring-slate-300",
className
)}
ref={ref}
{...props}
/>
)
}
)
Input.displayName = "Input"

export { Input }
6 changes: 6 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
Loading

0 comments on commit 564bcbd

Please sign in to comment.