Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix(frontend): Consistent buttons and their styles throughout the app #6835

Merged
merged 11 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,20 @@ describe("BrandButton", () => {

expect(screen.getByText("Test Button")).toBeDisabled();
});

it("should pass a start content", () => {
render(
<BrandButton
type="button"
variant="primary"
startContent={
<div data-testid="custom-start-content">Start Content</div>
}
>
Test Button
</BrandButton>,
);

screen.getByTestId("custom-start-content");
});
});
2 changes: 1 addition & 1 deletion frontend/src/assets/branding/github-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ModalButton } from "#/components/shared/buttons/modal-button";
import {
BaseModalTitle,
BaseModalDescription,
Expand All @@ -7,6 +6,7 @@ import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";
import { ModalBody } from "#/components/shared/modals/modal-body";
import { useCurrentSettings } from "#/context/settings-context";
import { handleCaptureConsent } from "#/utils/handle-capture-consent";
import { BrandButton } from "../settings/brand-button";

interface AnalyticsConsentFormModalProps {
onClose: () => void;
Expand Down Expand Up @@ -40,7 +40,7 @@ export function AnalyticsConsentFormModal({
onSubmit={handleSubmit}
className="flex flex-col gap-2"
>
<ModalBody>
<ModalBody className="border border-tertiary">
<BaseModalTitle title="Your Privacy Preferences" />
<BaseModalDescription>
We use tools to understand how our application is used to improve
Expand All @@ -53,12 +53,14 @@ export function AnalyticsConsentFormModal({
Send anonymous usage data
</label>

<ModalButton
<BrandButton
testId="confirm-preferences"
type="submit"
text="Confirm Preferences"
className="bg-primary text-white w-full hover:opacity-80"
/>
variant="primary"
className="w-full"
>
Confirm Preferences
</BrandButton>
</ModalBody>
</form>
</ModalBackdrop>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/features/chat/chat-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function ChatMessage({
className={cn(
"rounded-xl relative",
"flex flex-col gap-2",
type === "user" && " max-w-[305px] p-4 bg-neutral-700 self-end",
type === "user" && " max-w-[305px] p-4 bg-tertiary self-end",
type === "assistant" && "mt-6 max-w-full bg-tranparent",
)}
>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/features/chat/chat-suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function ChatSuggestions({ onSuggestionsClick }: ChatSuggestionsProps) {

return (
<div className="flex flex-col gap-6 h-full px-4 items-center justify-center">
<div className="flex flex-col items-center p-4 bg-neutral-700 rounded-xl w-full">
<div className="flex flex-col items-center p-4 bg-tertiary rounded-xl w-full">
<BuildIt width={45} height={54} />
<span className="font-semibold text-[20px] leading-6 -tracking-[0.01em] gap-1">
{t(I18nKey.LANDING$TITLE)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function InteractiveChatBox({
<div
className={cn(
"flex items-end gap-1",
"bg-neutral-700 border border-neutral-600 rounded-lg px-2",
"bg-tertiary border border-neutral-600 rounded-lg px-2",
"transition-colors duration-200",
"hover:border-neutral-500 focus-within:border-neutral-500",
)}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/features/chat/typing-indicator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function TypingIndicator() {
return (
<div className="flex items-center space-x-1.5 bg-neutral-700 px-3 py-1.5 rounded-full">
<div className="flex items-center space-x-1.5 bg-tertiary px-3 py-1.5 rounded-full">
<span
className="w-1.5 h-1.5 bg-gray-400 rounded-full animate-[bounce_0.5s_infinite] translate-y-[-2px]"
style={{ animationDelay: "0ms" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function ContextMenu({
<ul
data-testid={testId}
ref={ref}
className={cn("bg-[#404040] rounded-md w-[140px]", className)}
className={cn("bg-tertiary rounded-md w-[140px]", className)}
>
{children}
</ul>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ModalButton } from "#/components/shared/buttons/modal-button";
import {
BaseModalDescription,
BaseModalTitle,
} from "#/components/shared/modals/confirmation-modals/base-modal";
import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";
import { ModalBody } from "#/components/shared/modals/modal-body";
import { BrandButton } from "../settings/brand-button";

interface ConfirmDeleteModalProps {
onConfirm: () => void;
Expand All @@ -17,7 +17,7 @@ export function ConfirmDeleteModal({
}: ConfirmDeleteModalProps) {
return (
<ModalBackdrop>
<ModalBody className="items-start">
<ModalBody className="items-start border border-tertiary">
<div className="flex flex-col gap-2">
<BaseModalTitle title="Are you sure you want to delete this project?" />
<BaseModalDescription description="All data associated with this project will be lost." />
Expand All @@ -26,16 +26,22 @@ export function ConfirmDeleteModal({
className="flex flex-col gap-2 w-full"
onClick={(event) => event.stopPropagation()}
>
<ModalButton
<BrandButton
type="button"
variant="primary"
onClick={onConfirm}
className="bg-danger font-bold"
text="Confirm"
/>
<ModalButton
className="w-full"
>
Confirm
</BrandButton>
<BrandButton
type="button"
variant="secondary"
onClick={onCancel}
className="bg-neutral-500 font-bold"
text="Cancel"
/>
className="w-full"
>
Cancel
</BrandButton>
</div>
</ModalBody>
</ModalBackdrop>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function ExitConversationModal({
<ModalButton
text="Cancel"
onClick={onClose}
className="bg-neutral-700 flex-1"
className="bg-tertiary flex-1"
/>
</div>
</ModalBody>
Expand Down
27 changes: 16 additions & 11 deletions frontend/src/components/features/feedback/feedback-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
import { I18nKey } from "#/i18n/declaration";
import { Feedback } from "#/api/open-hands.types";
import { useSubmitFeedback } from "#/hooks/mutation/use-submit-feedback";
import { ModalButton } from "#/components/shared/buttons/modal-button";
import { BrandButton } from "../settings/brand-button";

const FEEDBACK_VERSION = "1.0";
const VIEWER_PAGE = "https://www.all-hands.dev/share";
Expand Down Expand Up @@ -121,18 +121,23 @@ export function FeedbackForm({ onClose, polarity }: FeedbackFormProps) {
</div>

<div className="flex gap-2">
<ModalButton
disabled={isPending}
<BrandButton
type="submit"
text={t(I18nKey.FEEDBACK$SHARE_LABEL)}
className="bg-[#4465DB] grow"
/>
<ModalButton
disabled={isPending}
text={t(I18nKey.FEEDBACK$CANCEL_LABEL)}
variant="primary"
className="grow"
isDisabled={isPending}
>
{t(I18nKey.FEEDBACK$SHARE_LABEL)}
</BrandButton>
<BrandButton
type="button"
variant="secondary"
className="grow"
onClick={onClose}
className="bg-[#737373] grow"
/>
isDisabled={isPending}
>
{t(I18nKey.FEEDBACK$CANCEL_LABEL)}
</BrandButton>
</div>
</form>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function FeedbackModal({

return (
<ModalBackdrop onClose={onClose}>
<ModalBody>
<ModalBody className="border border-tertiary">
<BaseModalTitle title="Feedback" />
<BaseModalDescription description="To help us improve, we collect feedback from your interactions to improve our prompts. By submitting this form, you consent to us collecting this data." />
<FeedbackForm onClose={onClose} polarity={polarity} />
Expand Down
16 changes: 12 additions & 4 deletions frontend/src/components/features/file-explorer/file-explorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { useListFiles } from "#/hooks/query/use-list-files";
import { cn } from "#/utils/utils";
import { FileExplorerHeader } from "./file-explorer-header";
import { useVSCodeUrl } from "#/hooks/query/use-vscode-url";
import { OpenVSCodeButton } from "#/components/shared/buttons/open-vscode-button";
import { BrandButton } from "../settings/brand-button";
import VSCodeIcon from "#/assets/vscode-alt.svg?react";

interface FileExplorerProps {
isOpen: boolean;
Expand Down Expand Up @@ -77,10 +78,17 @@ export function FileExplorer({ isOpen, onToggle }: FileExplorerProps) {
</div>
)}
{isOpen && (
<OpenVSCodeButton
onClick={handleOpenVSCode}
<BrandButton
testId="open-vscode-button"
type="button"
variant="secondary"
className="w-full"
isDisabled={RUNTIME_INACTIVE_STATES.includes(curAgentState)}
/>
onClick={handleOpenVSCode}
startContent={<VSCodeIcon width={20} height={20} />}
>
{t(I18nKey.VSCODE$OPEN)}
</BrandButton>
)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router";
import { I18nKey } from "#/i18n/declaration";
import { SuggestionBox } from "#/components/features/suggestions/suggestion-box";
import GitHubLogo from "#/assets/branding/github-logo.svg?react";
import { GitHubRepositorySelector } from "./github-repo-selector";
import { ModalButton } from "#/components/shared/buttons/modal-button";
import { useAppRepositories } from "#/hooks/query/use-app-repositories";
import { useSearchRepositories } from "#/hooks/query/use-search-repositories";
import { useUserRepositories } from "#/hooks/query/use-user-repositories";
import { sanitizeQuery } from "#/utils/sanitize-query";
import { useDebounce } from "#/hooks/use-debounce";
import { BrandButton } from "../settings/brand-button";
import GitHubLogo from "#/assets/branding/github-logo.svg?react";

interface GitHubRepositoriesSuggestionBoxProps {
handleSubmit: () => void;
Expand Down Expand Up @@ -62,13 +62,16 @@ export function GitHubRepositoriesSuggestionBox({
userRepositories={repositories}
/>
) : (
<ModalButton
<BrandButton
testId="connect-to-github"
text={t(I18nKey.GITHUB$CONNECT)}
icon={<GitHubLogo width={20} height={20} />}
className="bg-[#791B80] w-full"
type="button"
variant="secondary"
className="w-full"
onClick={handleConnectToGitHub}
/>
startContent={<GitHubLogo width={20} height={20} />}
>
{t(I18nKey.GITHUB$CONNECT)}
</BrandButton>
)
}
/>
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/features/settings/brand-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface BrandButtonProps {
isDisabled?: boolean;
className?: string;
onClick?: () => void;
startContent?: React.ReactNode;
}

export function BrandButton({
Expand All @@ -17,6 +18,7 @@ export function BrandButton({
isDisabled,
className,
onClick,
startContent,
}: React.PropsWithChildren<BrandButtonProps>) {
return (
<button
Expand All @@ -30,9 +32,11 @@ export function BrandButton({
"w-fit p-2 rounded disabled:opacity-30 disabled:cursor-not-allowed",
variant === "primary" && "bg-primary text-[#0D0F11]",
variant === "secondary" && "border border-primary text-primary",
startContent && "flex items-center justify-center gap-2",
className,
)}
>
{startContent}
{children}
</button>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface SuggestionItemProps {
export function SuggestionItem({ suggestion, onClick }: SuggestionItemProps) {
const { t } = useTranslation();
return (
<li className="list-none border border-neutral-600 rounded-xl hover:bg-neutral-700 flex-1">
<li className="list-none border border-neutral-600 rounded-xl hover:bg-tertiary flex-1">
<button
type="button"
data-testid="suggestion"
Expand Down
21 changes: 12 additions & 9 deletions frontend/src/components/features/waitlist/waitlist-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from "react";
import GitHubLogo from "#/assets/branding/github-logo.svg?react";
import AllHandsLogo from "#/assets/branding/all-hands-logo.svg?react";
import { JoinWaitlistAnchor } from "./join-waitlist-anchor";
import { WaitlistMessage } from "./waitlist-message";
import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";
import { ModalButton } from "#/components/shared/buttons/modal-button";
import { ModalBody } from "#/components/shared/modals/modal-body";
import { TOSCheckbox } from "./tos-checkbox";
import { handleCaptureConsent } from "#/utils/handle-capture-consent";
import { BrandButton } from "../settings/brand-button";
import GitHubLogo from "#/assets/branding/github-logo.svg?react";

interface WaitlistModalProps {
ghTokenIsSet: boolean;
Expand All @@ -29,20 +29,23 @@ export function WaitlistModal({

return (
<ModalBackdrop>
<ModalBody>
<ModalBody className="border border-tertiary">
<AllHandsLogo width={68} height={46} />
<WaitlistMessage content={ghTokenIsSet ? "waitlist" : "sign-in"} />

<TOSCheckbox onChange={() => setIsTosAccepted((prev) => !prev)} />

{!ghTokenIsSet && (
<ModalButton
disabled={!isTosAccepted}
text="Connect to GitHub"
icon={<GitHubLogo width={20} height={20} />}
className="bg-[#791B80] w-full"
<BrandButton
isDisabled={!isTosAccepted}
type="button"
variant="primary"
onClick={handleGitHubAuth}
/>
className="w-full"
startContent={<GitHubLogo width={20} height={20} />}
>
Connect to GitHub
</BrandButton>
)}
{ghTokenIsSet && <JoinWaitlistAnchor />}
</ModalBody>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/layout/nav-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export function NavTab({ to, label, icon, isBeta }: NavTabProps) {
to={to}
className={({ isActive }) =>
cn(
"px-2 border-b border-r border-neutral-600 bg-base flex-1",
"px-2 border-b border-r border-neutral-600 bg-base-secondary flex-1",
"first-of-type:rounded-tl-xl last-of-type:rounded-tr-xl last-of-type:border-r-0",
"flex items-center gap-2",
isActive && "bg-base-secondary",
isActive && "text-primary",
)
}
>
Expand Down
Loading
Loading