Skip to content

Commit

Permalink
Create a small variant for SharedDialog to be small
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjarling committed Mar 5, 2024
1 parent 37baf21 commit ddb5db3
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 60 deletions.
61 changes: 61 additions & 0 deletions components/Search/GenerativeAI.styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import * as Tooltip from "@radix-ui/react-tooltip";

import { styled } from "@/stitches.config";

/* eslint sort-keys: 0 */

const GenerativeAIToggleWrapper = styled("div", {
color: "$black50",
fontSize: "$gr2",
display: "flex",
flexShrink: "0",
alignItems: "center",
marginRight: "$gr1",

"& label": {
cursor: "pointer",
flexShrink: "0",
marginLeft: "3px",
marginRight: "4px",
},

"& svg": {
position: "relative",
padding: "0 0 1px",
height: "$gr3",
width: "$gr3",
fill: "$black50",
},
});

const GenerativeAIDialogMessage = styled("p", {});

const FlexBody = styled("div", {
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
width: "100%",
});

const DialogButtonRow = styled("div", {
display: "flex",
justifyContent: "flex-end",
});

const TooltipTrigger = styled(Tooltip.Trigger, {
background: "transparent",
border: "none",
});

const TooltipContent = styled(Tooltip.Content, {
zIndex: 2,
});

export {
DialogButtonRow,
FlexBody,
GenerativeAIDialogMessage,
GenerativeAIToggleWrapper,
TooltipContent,
TooltipTrigger,
};
51 changes: 26 additions & 25 deletions components/Search/GenerativeAIToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import {
CheckboxRoot as CheckboxRootStyled,
} from "@/components/Shared/Checkbox.styled";
import {
DialogButtonRow,
FlexBody,
GenerativeAIDialogMessage,
GenerativeAIToggleWrapper,
} from "@/components/Search/Search.styled";
TooltipContent,
TooltipTrigger,
} from "@/components/Search/GenerativeAI.styled";
import { TooltipArrow, TooltipBody } from "../Shared/Tooltip.styled";

import { Button } from "@nulib/design-system";
Expand All @@ -16,18 +20,8 @@ import { IconCheck } from "@/components/Shared/SVG/Icons";
import { IconInfo } from "@/components/Shared/SVG/Icons";
import React from "react";
import { generativeAIWarning } from "@/components/Chat/components/Answer/Information";
import { styled } from "@/stitches.config";
import useGenerativeAISearchToggle from "@/hooks/useGenerativeAISearchToggle";

const TooltipTrigger = styled(Tooltip.Trigger, {
background: "transparent",
border: "none",
});

const TooltipContent = styled(Tooltip.Content, {
zIndex: 2,
});

function GenerativeAITooltip() {
return (
<Tooltip.Provider delayDuration={20}>
Expand Down Expand Up @@ -74,20 +68,27 @@ export default function GenerativeAIToggle({
<GenerativeAITooltip />
</GenerativeAIToggleWrapper>

<GenerativeAIDialog
isOpen={dialog.isOpen}
title={dialog.title}
handleCloseClick={closeDialog}
>
<GenerativeAIDialogMessage>
You must be logged in with a Northwestern NetID to use the Generative
AI search feature.
</GenerativeAIDialogMessage>
<Button isPrimary onClick={handleLogin}>
Login
</Button>
<Button onClick={closeDialog}>Cancel</Button>
</GenerativeAIDialog>
<div style={{ display: "flex" }}>
<GenerativeAIDialog
isOpen={dialog.isOpen}
title={dialog.title}
handleCloseClick={closeDialog}
size="small"
>
<FlexBody>
<GenerativeAIDialogMessage>
You must be logged in with a Northwestern NetID to use the
Generative AI search feature.
</GenerativeAIDialogMessage>
<DialogButtonRow>
<Button isPrimary onClick={handleLogin}>
Login
</Button>
<Button onClick={closeDialog}>Cancel</Button>
</DialogButtonRow>
</FlexBody>
</GenerativeAIDialog>
</div>
</>
);
}
31 changes: 0 additions & 31 deletions components/Search/Search.styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,35 +100,6 @@ const Clear = styled("button", {
},
});

const GenerativeAIToggleWrapper = styled("div", {
color: "$black50",
fontSize: "$gr2",
display: "flex",
flexShrink: "0",
alignItems: "center",
marginRight: "$gr1",

"& label": {
cursor: "pointer",
//width: "120px",
flexShrink: "0",
marginLeft: "3px",
marginRight: "4px",
},

"& svg": {
position: "relative",
padding: "0 0 1px",
height: "$gr3",
width: "$gr3",
fill: "$black50",
},
});

const GenerativeAIDialogMessage = styled("p", {
marginBottom: "$gr4",
});

const ResultsMessage = styled("span", {
color: "$black50",
padding: "0 $gr4 $gr4",
Expand Down Expand Up @@ -173,8 +144,6 @@ const ResultsWrapper = styled("div", {
export {
Button,
Clear,
GenerativeAIDialogMessage,
GenerativeAIToggleWrapper,
Input,
NoResultsMessage,
ResultsMessage,
Expand Down
11 changes: 11 additions & 0 deletions components/Shared/Dialog.styled.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Dialog from "@radix-ui/react-dialog";

import { styled } from "@/stitches.config";

/* eslint sort-keys: 0 */
Expand Down Expand Up @@ -113,6 +114,16 @@ const DialogContent = styled(Dialog.Content, {

variants: {
size: {
small: {
top: "12rem",
left: "12rem",
width: "calc(100vw - 24rem)",
height: "calc(100vh - 24rem)",

[`& ${DialogBody}`]: {
display: "flex",
},
},
large: {
top: "5rem",
left: "5rem",
Expand Down
8 changes: 5 additions & 3 deletions components/Shared/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import * as Dialog from "@radix-ui/react-dialog";

import {
DialogBody,
DialogClose,
DialogContent,
DialogHeader,
DialogOverlay,
} from "@/components/Shared/Dialog.styled";

import { IconClear } from "@/components/Shared/SVG/Icons";
import { ReactNode } from "react";

interface SharedDialogProps {
children: ReactNode;
handleCloseClick: () => void;
isOpen: boolean;
large?: boolean;
size?: "small" | "large";
title: string;
}

const SharedDialog: React.FC<SharedDialogProps> = ({
children,
handleCloseClick,
large,
size,
isOpen,
title,
}) => {
Expand All @@ -30,7 +32,7 @@ const SharedDialog: React.FC<SharedDialogProps> = ({
<DialogOverlay />
<DialogContent
onInteractOutside={handleCloseClick}
{...(large && { size: "large" })}
{...(size ? { size } : {})}
>
<DialogHeader>
<Dialog.Title>{title}</Dialog.Title>
Expand Down
2 changes: 1 addition & 1 deletion components/Work/ActionsDialog/ActionsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const WorkActionsDialog: React.FC<WorkActionsDialogProps> = ({
<SharedDialog
handleCloseClick={close}
isOpen={!!activeDialog}
large
size="large"
title={renderTitle()}
>
{renderContent()}
Expand Down

0 comments on commit ddb5db3

Please sign in to comment.