Skip to content

Commit

Permalink
chore: add demo for polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonstudio committed Jul 9, 2024
1 parent 715eeb4 commit c8aca0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
21 changes: 9 additions & 12 deletions app/components/outputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const Outputs = React.forwardRef<
>(({ children, ...props }, ref) => {
let infoElement = null;

const [isBrowserSupport, setIsBrowserSupport] = React.useState(true);
const [isEnabledFlags, setIsEnabledFlags] = React.useState(true);

React.useEffect(() => {
Expand All @@ -23,7 +22,7 @@ export const Outputs = React.forwardRef<
return raw ? parseInt(raw[2], 10) : 0;
}
const version = getChromeVersion();
setIsBrowserSupport(version >= 127);
// setIsBrowserSupport(version >= 127);

setIsEnabledFlags(!!('ai' in globalThis));

Expand All @@ -32,7 +31,7 @@ export const Outputs = React.forwardRef<
});
}, []);

if (!isBrowserSupport || !isEnabledFlags) {
if (!isEnabledFlags) {
infoElement = (
<div className="w-[500px] m-auto flex flex-col gap-4">
<h2 className="scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0">
Expand All @@ -43,15 +42,13 @@ export const Outputs = React.forwardRef<
experimental and will change as they test and address feedback.
</p>

{isBrowserSupport ? null : (
<Alert variant="destructive">
<AlertCircle className="h-4 w-4" />
<AlertTitle>Your browser is not supported.</AlertTitle>
<AlertDescription>
Please update Chrome to version 127 or higher.
</AlertDescription>
</Alert>
)}
<Alert variant="destructive">
<AlertCircle className="h-4 w-4" />
<AlertTitle>Your browser is not supported.</AlertTitle>
<AlertDescription>
Please update Chrome to version 127 or higher.
</AlertDescription>
</Alert>

{isEnabledFlags ? null : (
<div className="flex flex-col items-start justify-start">
Expand Down
1 change: 1 addition & 0 deletions app/orders/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

import 'chrome-ai/polyfill';
import { LoaderCircle, SquareKanban } from 'lucide-react';
import { Badge } from '../components/ui/badge';
import { Button } from '../components/ui/button';
Expand Down
1 change: 1 addition & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use client';

require('chrome-ai/polyfill');
import {
CornerDownLeft,
Command,
Expand Down

0 comments on commit c8aca0f

Please sign in to comment.