-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OPIK-759] implement side dialog component and log a trace dialog (#1111
) * [OPIK-759] implement side dialog component and log a trace dialog * [OPIK-759] fix linter * [OPIK-759] align overlay background color --------- Co-authored-by: Yaroslav Boiko <[email protected]> Co-authored-by: Yaroslav Boiko <[email protected]>
- Loading branch information
1 parent
2e04802
commit fb89646
Showing
13 changed files
with
332 additions
and
118 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 16 additions & 63 deletions
79
...nd/src/components/pages-shared/onboarding/FrameworkIntegrations/FrameworkIntegrations.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,22 @@ | ||
import React, { useState } from "react"; | ||
import { FrameworkIntegration } from "./types"; | ||
import { Button } from "@/components/ui/button"; | ||
import { buildDocsUrl } from "@/lib/utils"; | ||
import { SquareArrowOutUpRight } from "lucide-react"; | ||
import ApiKeyCard from "../ApiKeyCard/ApiKeyCard"; | ||
import GoogleColabCard from "../GoogleColabCard/GoogleColabCard"; | ||
import IntegrationTemplate from "./IntegrationTemplate"; | ||
import usePluginsStore from "@/store/PluginsStore"; | ||
import FrameworkIntegrationsContent, { | ||
FrameworkIntegrationsContentProps, | ||
} from "./FrameworkIntegrationsContent"; | ||
|
||
type FrameworkIntegrationsProps = { | ||
integrationList: FrameworkIntegration[]; | ||
apiKey?: string; | ||
showColabLinks?: boolean; | ||
}; | ||
const FrameworkIntegrations: React.FC<FrameworkIntegrationsProps> = ({ | ||
integrationList, | ||
apiKey, | ||
showColabLinks, | ||
}) => { | ||
const [integrationIndex, setIntegrationIndex] = useState<number>(0); | ||
const integration = integrationList[integrationIndex]; | ||
export type FrameworkIntegrationsProps = Omit< | ||
FrameworkIntegrationsContentProps, | ||
"apiKey" | "showColabLinks" | ||
>; | ||
const FrameworkIntegrations: React.FC<FrameworkIntegrationsProps> = (props) => { | ||
const FrameworkIntegrations = usePluginsStore( | ||
(state) => state.FrameworkIntegrations, | ||
); | ||
|
||
return ( | ||
<div className="m-auto flex w-full max-w-[1250px] gap-6"> | ||
<div className="sticky top-20 flex w-[250px] shrink-0 flex-col gap-4 self-start"> | ||
<h4 className="comet-title-s">Select framework</h4> | ||
<ul className="flex flex-col gap-2"> | ||
{integrationList.map((item, index) => ( | ||
<li | ||
key={item.label} | ||
className="comet-body-s flex h-10 w-full cursor-pointer items-center gap-2 rounded-md pl-2 pr-4 text-foreground hover:bg-primary-foreground data-[status=active]:bg-primary-100" | ||
onClick={() => setIntegrationIndex(index)} | ||
data-status={index === integrationIndex ? "active" : "inactive"} | ||
> | ||
<img | ||
alt={item.label} | ||
src={item.logo} | ||
className="size-[32px] shrink-0" | ||
/> | ||
<div className="ml-1 truncate">{item.label}</div> | ||
</li> | ||
))} | ||
</ul> | ||
<Button className="w-fit pl-2" variant="ghost" asChild> | ||
<a | ||
href={buildDocsUrl("/tracing/integrations/overview")} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Explore all integrations | ||
<SquareArrowOutUpRight className="ml-2 size-4 shrink-0" /> | ||
</a> | ||
</Button> | ||
</div> | ||
<div className="flex min-w-[650px] flex-1 gap-6"> | ||
<div className="flex w-full flex-1 flex-col"> | ||
<IntegrationTemplate code={integration.code} apiKey={apiKey} /> | ||
</div> | ||
if (FrameworkIntegrations) { | ||
return <FrameworkIntegrations {...props} />; | ||
} | ||
|
||
<div className="sticky top-20 flex w-[250px] shrink-0 flex-col gap-6 self-start"> | ||
{apiKey && <ApiKeyCard apiKey={apiKey} />} | ||
{showColabLinks ? <GoogleColabCard link={integration.colab} /> : null} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
return <FrameworkIntegrationsContent {...props} />; | ||
}; | ||
|
||
export default FrameworkIntegrations; |
87 changes: 87 additions & 0 deletions
87
...components/pages-shared/onboarding/FrameworkIntegrations/FrameworkIntegrationsContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React, { useState } from "react"; | ||
import { FrameworkIntegration } from "./types"; | ||
import { Button } from "@/components/ui/button"; | ||
import { buildDocsUrl } from "@/lib/utils"; | ||
import { SquareArrowOutUpRight } from "lucide-react"; | ||
import ApiKeyCard from "../ApiKeyCard/ApiKeyCard"; | ||
import GoogleColabCard from "../GoogleColabCard/GoogleColabCard"; | ||
import IntegrationTemplate from "./IntegrationTemplate"; | ||
import { QUICKSTART_INTEGRATIONS } from "./quickstart-integrations"; | ||
import { cn } from "@/lib/utils"; | ||
|
||
export type FrameworkIntegrationsContentProps = { | ||
integrationList?: FrameworkIntegration[]; | ||
apiKey?: string; | ||
showColabLinks?: boolean; | ||
stickyOffset?: number; | ||
}; | ||
const FrameworkIntegrationsContent: React.FC< | ||
FrameworkIntegrationsContentProps | ||
> = ({ | ||
integrationList = QUICKSTART_INTEGRATIONS, | ||
apiKey, | ||
showColabLinks, | ||
stickyOffset = 0, | ||
}) => { | ||
const [integrationIndex, setIntegrationIndex] = useState<number>(0); | ||
const integration = integrationList[integrationIndex]; | ||
|
||
const stickyOffsetStyle = `top-${stickyOffset}`; | ||
|
||
return ( | ||
<div className="m-auto flex w-full max-w-[1250px] gap-6"> | ||
<div | ||
className={cn( | ||
"sticky flex w-[250px] shrink-0 flex-col gap-4 self-start", | ||
stickyOffsetStyle, | ||
)} | ||
> | ||
<h4 className="comet-title-s">Select framework</h4> | ||
<ul className="flex flex-col gap-2"> | ||
{integrationList.map((item, index) => ( | ||
<li | ||
key={item.label} | ||
className="comet-body-s flex h-10 w-full cursor-pointer items-center gap-2 rounded-md pl-2 pr-4 text-foreground hover:bg-primary-foreground data-[status=active]:bg-primary-100" | ||
onClick={() => setIntegrationIndex(index)} | ||
data-status={index === integrationIndex ? "active" : "inactive"} | ||
> | ||
<img | ||
alt={item.label} | ||
src={item.logo} | ||
className="size-[32px] shrink-0" | ||
/> | ||
<div className="ml-1 truncate">{item.label}</div> | ||
</li> | ||
))} | ||
</ul> | ||
<Button className="w-fit pl-2" variant="ghost" asChild> | ||
<a | ||
href={buildDocsUrl("/tracing/integrations/overview")} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
Explore all integrations | ||
<SquareArrowOutUpRight className="ml-2 size-4 shrink-0" /> | ||
</a> | ||
</Button> | ||
</div> | ||
<div className="flex min-w-[650px] flex-1 gap-6"> | ||
<div className="flex w-full flex-1 flex-col"> | ||
<IntegrationTemplate code={integration.code} apiKey={apiKey} /> | ||
</div> | ||
|
||
<div | ||
className={cn( | ||
"sticky flex w-[250px] shrink-0 flex-col gap-6 self-start", | ||
stickyOffsetStyle, | ||
)} | ||
> | ||
{apiKey && <ApiKeyCard apiKey={apiKey} />} | ||
{showColabLinks ? <GoogleColabCard link={integration.colab} /> : null} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FrameworkIntegrationsContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
apps/opik-frontend/src/components/shared/SideDialog/SideDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from "react"; | ||
import { Sheet, SheetContent } from "@/components/ui/sheet"; | ||
|
||
type SideDialogProps = { | ||
open: boolean; | ||
setOpen: (open: boolean) => void; | ||
children: React.ReactNode; | ||
}; | ||
|
||
const SideDialog: React.FunctionComponent<SideDialogProps> = ({ | ||
open, | ||
setOpen, | ||
children, | ||
}) => { | ||
return ( | ||
<Sheet open={open} onOpenChange={setOpen}> | ||
<SheetContent className="w-[calc(100vw-60px)] sm:max-w-full xl:w-[calc(100vw-240px)]"> | ||
{children} | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
}; | ||
|
||
export default SideDialog; |
Oops, something went wrong.