Skip to content

Commit

Permalink
fix(website): remove window on ssr and allow build
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermerodz committed Feb 20, 2024
1 parent 27a720e commit 91c7d65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions website/src/app/(pages)/(home)/_components/showcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ const DynamicConfetti = dynamic(() =>
)

export function Showcase({ className, ...props }: { className?: string }) {
const isMobile = useMemo(
() => window.matchMedia('(max-width: 1023px)').matches,
[],
)

const [value, setValue] = React.useState('12')
const [disabled, setDisabled] = React.useState(isMobile ? false : true)
const [disabled, setDisabled] = React.useState(false)

const [preloadConfetti, setPreloadConfetti] = React.useState(0)
const [hasGuessed, setHasGuessed] = React.useState(false)

const inputRef = React.useRef<HTMLInputElement>(null)

React.useEffect(() => {
const isMobile = window.matchMedia('(max-width: 1023px)').matches
if (!isMobile) {
setDisabled(true)
}
const t1 = setTimeout(() => {
setDisabled(false)
}, 1_900)
Expand All @@ -40,7 +39,7 @@ export function Showcase({ className, ...props }: { className?: string }) {
clearTimeout(t1)
clearTimeout(t2)
}
}, [isMobile])
}, [])

React.useEffect(() => {
if (value.length > 3) {
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/copy-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface CopyButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
}

export async function copyToClipboardWithMeta(value: string) {
window.isSecureContext && navigator.clipboard.writeText(value)
window && window.isSecureContext && navigator.clipboard.writeText(value)
}

export function CopyButton({
Expand Down

0 comments on commit 91c7d65

Please sign in to comment.