Skip to content

Commit

Permalink
Minor theming (#2993)
Browse files Browse the repository at this point in the history
* ensure functionality

* naming

* ensure tailwind theme updated

* add comments

* nit

* remove pr

* enforce colors

* update our tailwind config
  • Loading branch information
pablonyx authored Oct 30, 2024
1 parent 7384ca8 commit f318e30
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 31 deletions.
6 changes: 4 additions & 2 deletions web/src/app/assistants/SidebarWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ export default function SidebarWrapper<T extends object>({
/>

<div
className={`mt-4 w-full ${size == "lg" ? "max-w-4xl" : "max-w-3xl"} mx-auto`}
className={`mt-4 w-full ${
size == "lg" ? "max-w-4xl" : "max-w-3xl"
} mx-auto`}
>
{children}
</div>
</div>
</div>
<FixedLogo />
<FixedLogo backgroundToggled={toggledSidebar || showDocSidebar} />
</div>
);
}
2 changes: 1 addition & 1 deletion web/src/app/chat/ChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ export function ChatPage({
)}
</div>
</div>
<FixedLogo chat />
<FixedLogo backgroundToggled={toggledSidebar || showDocSidebar} />
</div>
</div>
<DocumentSidebar
Expand Down
6 changes: 3 additions & 3 deletions web/src/app/chat/sessionSidebar/ChatSessionDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function ChatSessionDisplay({
);
}}
>
<BasicSelectable chat padding="extra" fullWidth selected={isSelected}>
<BasicSelectable padding="extra" fullWidth selected={isSelected}>
<>
<div className="flex relative">
{isRenamingChat ? (
Expand All @@ -144,8 +144,8 @@ export function ChatSessionDisplay({
className={`absolute right-0 top-0 h-full w-8 bg-gradient-to-r from-transparent
${
isSelected
? "to-background-chat-hover"
: " to-background-chat-selected group-hover:to-background-chat-hover"
? "to-background-chat-selected"
: "group-hover:to-background-chat-hover"
} `}
/>
</p>
Expand Down
1 change: 0 additions & 1 deletion web/src/app/chat/shared/[chatId]/SharedChatDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function BackToDanswerButton() {
Back to {enterpriseSettings?.application_name || "Danswer Chat"}
</Button>
</div>
pr
</div>
);
}
Expand Down
13 changes: 10 additions & 3 deletions web/src/app/chat/shared_chat_search/FixedLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import Link from "next/link";
import { useContext } from "react";
import { FiSidebar } from "react-icons/fi";

export default function FixedLogo({ chat }: { chat?: boolean }) {
export default function FixedLogo({
// Whether the sidebar is toggled or not
backgroundToggled,
}: {
backgroundToggled?: boolean;
}) {
const combinedSettings = useContext(SettingsContext);
const settings = combinedSettings?.settings;
const enterpriseSettings = combinedSettings?.enterpriseSettings;
Expand All @@ -28,15 +33,17 @@ export default function FixedLogo({ chat }: { chat?: boolean }) {
<div className="w-full">
{enterpriseSettings && enterpriseSettings.application_name ? (
<div>
<HeaderTitle chat={chat}>
<HeaderTitle backgroundToggled={backgroundToggled}>
{enterpriseSettings.application_name}
</HeaderTitle>
{!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && (
<p className="text-xs text-subtle">Powered by Danswer</p>
)}
</div>
) : (
<HeaderTitle chat={chat}>Danswer</HeaderTitle>
<HeaderTitle backgroundToggled={backgroundToggled}>
Danswer
</HeaderTitle>
)}
</div>
</div>
Expand Down
10 changes: 2 additions & 8 deletions web/src/components/BasicClickable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,12 @@ export function BasicSelectable({
children,
selected,
hasBorder,
chat,
fullWidth = false,
padding = "normal",
}: {
children: string | JSX.Element;
selected: boolean;
hasBorder?: boolean;
chat?: boolean;
fullWidth?: boolean;
padding?: "none" | "normal" | "extra";
}) {
Expand All @@ -104,12 +102,8 @@ export function BasicSelectable({
${hasBorder ? "border border-border" : ""}
${
selected
? chat
? "bg-background-chat-selected"
: "bg-hover"
: chat
? "bg-background-chat-hover"
: "hover:bg-hover"
? "bg-background-chat-selected"
: "hover:bg-background-chat-hover"
}
${fullWidth ? "w-full" : ""}`}
>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/admin/ClientLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function ClientLayout({
return (
<div className="h-screen overflow-y-hidden">
<div className="flex h-full">
<div className="flex-none text-text-settings-sidebar bg-background-settings-sidebar w-[250px] z-20 pt-4 pb-8 h-full border-r border-border miniscroll overflow-auto">
<div className="flex-none text-text-settings-sidebar bg-background-sidebar w-[250px] z-20 pt-4 pb-8 h-full border-r border-border miniscroll overflow-auto">
<AdminSidebar
collections={[
{
Expand Down
6 changes: 3 additions & 3 deletions web/src/components/admin/connectors/AdminSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function AdminSidebar({ collections }: { collections: Collection[] }) {
<div className="flex-grow min-w-0 my-auto">
{enterpriseSettings && enterpriseSettings.application_name ? (
<div className="w-full">
<HeaderTitle>
<HeaderTitle backgroundToggled={true}>
{enterpriseSettings.application_name}
</HeaderTitle>
{!NEXT_PUBLIC_DO_NOT_USE_TOGGLE_OFF_DANSWER_POWERED && (
Expand All @@ -65,7 +65,7 @@ export function AdminSidebar({ collections }: { collections: Collection[] }) {
)}
</div>
) : (
<HeaderTitle>Danswer</HeaderTitle>
<HeaderTitle backgroundToggled={true}>Danswer</HeaderTitle>
)}
</div>
</div>
Expand All @@ -74,7 +74,7 @@ export function AdminSidebar({ collections }: { collections: Collection[] }) {
</div>
<div className="flex w-full justify-center">
<Link href={"/chat"}>
<button className="text-sm flex items-center block w-52 py-2.5 flex px-2 text-left bg-background-200 hover:bg-background-200/80 cursor-pointer rounded">
<button className="text-sm flex items-center block w-52 py-2.5 flex px-2 text-left text-text-back-button bg-background-back-button hover:bg-opacity-80 cursor-pointer rounded">
<BackIcon className="my-auto" size={18} />
<p className="ml-1 break-words line-clamp-2 ellipsis leading-none">
Back to{" "}
Expand Down
8 changes: 5 additions & 3 deletions web/src/components/header/HeaderTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ import React from "react";

export function HeaderTitle({
children,
chat,
backgroundToggled,
}: {
children: JSX.Element | string;
chat?: boolean;
backgroundToggled?: boolean;
}) {
const isString = typeof children === "string";
const textSize = isString && children.length > 10 ? "text-xl" : "text-2xl";

return (
<h1
className={`${textSize} ${
chat ? "text-text-sidebar-header" : "text-text-header"
backgroundToggled
? "text-text-sidebar-toggled-header"
: "text-text-sidebar-header"
} break-words line-clamp-2 ellipsis text-strong leading-none font-bold`}
>
{children}
Expand Down
12 changes: 8 additions & 4 deletions web/src/components/header/LogoType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export default function LogoType({

return (
<div
className={`${hideOnMobile && "mobile:hidden"} z-[100] mb-auto shrink-0 flex items-center text-xl font-bold`}
className={`${
hideOnMobile && "mobile:hidden"
} z-[100] mb-auto shrink-0 flex items-center text-xl font-bold`}
>
{toggleSidebar && page == "chat" ? (
<button
Expand All @@ -55,7 +57,9 @@ export default function LogoType({
</div>
)}
<div
className={`cursor-pointer ${showArrow ? "desktop:invisible" : "invisible"} break-words inline-block w-fit ml-2 text-text-700 text-xl`}
className={`cursor-pointer ${
showArrow ? "desktop:invisible" : "invisible"
} break-words inline-block w-fit ml-2 text-text-700 text-xl`}
>
<div className="max-w-[175px]">
{enterpriseSettings && enterpriseSettings.application_name ? (
Expand Down Expand Up @@ -111,9 +115,9 @@ export default function LogoType({
}}
>
{!toggled && !combinedSettings?.isMobile ? (
<RightToLineIcon />
<RightToLineIcon className="text-sidebar-toggle" />
) : (
<LeftToLineIcon />
<LeftToLineIcon className="text-sidebar-toggle" />
)}
</button>
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/search/SearchSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ export const SearchSection = ({
</div>
</div>
</div>
<FixedLogo chat />
<FixedLogo backgroundToggled={toggledSidebar || showDocSidebar} />
</>
);
};
12 changes: 11 additions & 1 deletion web/tailwind-themes/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,30 @@ module.exports = {

// colors for sidebar in chat, search, and manage settings
"background-sidebar": "var(--background-100)",
"background-settings-sidebar": "var(--background-100)",
"background-chatbar": "var(--background-100)",
"text-sidebar": "var(--text-500)",

"toggled-background": "var(--background-400)",
"untoggled-background": "var(--background-200)",

"background-back-button": "var(--background-200)",
"text-back-button": "var(--text-800)",

// Settings
"text-sidebar-subtle": "var(--text-500)",
"icon-settings-sidebar": "var(--text-600)",
"text-settings-sidebar": "var(--text-600)",
"text-settings-sidebar-strong": "var(--text-900)",
"background-settings-hover": "var(--background-200)",

"background-chat-hover": "var(--background-200)",
"background-chat-selected": "var(--background-200)",

// Background for chat messages (user bubbles)
user: "var(--user-bubble)",

"background-toggle": "var(--background-100)",

// Colors for the search toggle buttons
"background-agentic-toggled": "var(--light-success)",
"background-agentic-untoggled": "var(--undo)",
Expand Down

0 comments on commit f318e30

Please sign in to comment.