feat(ui): standardize responsive control sizing (#3563)
This commit is contained in:
@@ -15,6 +15,8 @@ import { useGitLabActionPresets } from "@/hooks/domains/gitlab/use-gitlab-action
|
||||
import type { GitLabActionPreset, GitLabActionPresets } from "@/lib/types/gitlab";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import type { TFunction } from "i18next";
|
||||
import { controlSizingClassName } from "@kandev/ui/control-sizing";
|
||||
import { settingsActionClassName } from "@/components/settings/settings-control";
|
||||
|
||||
function actionPromptPlaceholders(t: TFunction) {
|
||||
return [
|
||||
@@ -84,7 +86,7 @@ function PresetList({
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-11 w-11 cursor-pointer text-destructive sm:h-8 sm:w-8"
|
||||
className={controlSizingClassName("icon", "cursor-pointer text-destructive")}
|
||||
aria-label={t("gitlab:remove", { label: preset.label })}
|
||||
onClick={() => onChange(presets.filter((_, current) => current !== index))}
|
||||
>
|
||||
@@ -103,9 +105,8 @@ function PresetList({
|
||||
))}
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 w-full cursor-pointer sm:h-8 sm:w-auto"
|
||||
className={settingsActionClassName("w-full cursor-pointer sm:w-auto")}
|
||||
onClick={() => onChange([...presets, newPreset()])}
|
||||
>
|
||||
<IconPlus className="h-4 w-4" />
|
||||
@@ -193,9 +194,8 @@ export function GitLabActionPresetsSection({ workspaceId }: { workspaceId: strin
|
||||
action={
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 cursor-pointer sm:h-8"
|
||||
className={settingsActionClassName("cursor-pointer")}
|
||||
disabled={loading}
|
||||
aria-label={t("gitlab:resetQuickActionsToDefaults")}
|
||||
onClick={() => void resetDefaults()}
|
||||
|
||||
@@ -55,6 +55,7 @@ import { MRDiscussionsSection } from "./mr-discussions-section";
|
||||
import { MRReviewerControl } from "./mr-reviewer-control";
|
||||
import { SubscriptionToggle } from "./subscription-toggle";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { controlSizingClassName } from "@kandev/ui/control-sizing";
|
||||
|
||||
type MRKeyInput = Pick<TaskMR, "host" | "project_path" | "mr_iid">;
|
||||
const EMPTY_LABELS: string[] = [];
|
||||
@@ -114,9 +115,8 @@ function LabelsControl({
|
||||
aria-label={t("gitlab:mergeRequestLabels")}
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 shrink-0 cursor-pointer sm:h-9"
|
||||
className={controlSizingClassName("standard", "shrink-0 cursor-pointer")}
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
onSave(
|
||||
@@ -159,27 +159,27 @@ function PanelHeader({
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
size="icon-sm"
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-10 w-10 cursor-pointer sm:h-8 sm:w-8"
|
||||
className={controlSizingClassName("icon", "cursor-pointer")}
|
||||
aria-label={t("gitlab:refreshMergeRequest")}
|
||||
onClick={onRefresh}
|
||||
>
|
||||
<IconRefresh className={`h-4 w-4 ${loading ? "animate-spin" : ""}`} />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon-sm"
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-10 w-10 cursor-pointer sm:h-8 sm:w-8"
|
||||
className={controlSizingClassName("icon", "cursor-pointer")}
|
||||
aria-label={t("gitlab:openMergeRequestInGitlab")}
|
||||
onClick={() => void openExternalLink(mr.mr_url).catch(() => undefined)}
|
||||
>
|
||||
<IconExternalLink className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
size="icon-sm"
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="h-10 w-10 cursor-pointer text-destructive sm:h-8 sm:w-8"
|
||||
className={controlSizingClassName("icon", "cursor-pointer text-destructive")}
|
||||
aria-label={t("gitlab:unlinkMergeRequest")}
|
||||
onClick={onUnlink}
|
||||
>
|
||||
@@ -210,26 +210,26 @@ function MRActionButtons({
|
||||
return (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
className="h-11 cursor-pointer gap-1.5 bg-green-600 text-white hover:bg-green-700 sm:h-8"
|
||||
className={controlSizingClassName(
|
||||
"standard",
|
||||
"cursor-pointer gap-1.5 bg-green-600 text-white hover:bg-green-700",
|
||||
)}
|
||||
disabled={disabled}
|
||||
onClick={() => void run("approve", () => approveMR(identity))}
|
||||
>
|
||||
<IconCheck className="h-4 w-4" /> {t("gitlab:approve")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 cursor-pointer sm:h-8"
|
||||
className={controlSizingClassName("standard", "cursor-pointer")}
|
||||
disabled={disabled}
|
||||
onClick={() => void run("unapprove", () => unapproveMR(identity))}
|
||||
>
|
||||
{t("gitlab:unapprove")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 cursor-pointer gap-1.5 sm:h-8"
|
||||
className={controlSizingClassName("standard", "cursor-pointer gap-1.5")}
|
||||
disabled={disabled || hasConflicts}
|
||||
onClick={onMerge}
|
||||
>
|
||||
@@ -330,7 +330,11 @@ function FeedbackPlaceholder({ error, onRetry }: { error: string | null; onRetry
|
||||
return (
|
||||
<div className="p-4 text-sm text-destructive">
|
||||
{error}
|
||||
<Button variant="outline" size="sm" className="ml-2 cursor-pointer" onClick={onRetry}>
|
||||
<Button
|
||||
variant="outline"
|
||||
className={controlSizingClassName("standard", "ml-2 cursor-pointer")}
|
||||
onClick={onRetry}
|
||||
>
|
||||
{t("gitlab:retry")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Textarea } from "@kandev/ui/textarea";
|
||||
import type { GitLabMRDiscussion } from "@/lib/types/gitlab";
|
||||
import { CollapsibleSection, formatTimeAgo, PRMarkdownBody } from "@/components/github/pr-shared";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { controlSizingClassName } from "@kandev/ui/control-sizing";
|
||||
|
||||
function discussionLocation(discussion: GitLabMRDiscussion): string {
|
||||
if (!discussion.path) return "";
|
||||
@@ -78,9 +79,9 @@ function Discussion({
|
||||
</Badge>
|
||||
)}
|
||||
<Button
|
||||
size="icon-sm"
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="ml-auto h-9 w-9 shrink-0 cursor-pointer sm:h-7 sm:w-7"
|
||||
className={controlSizingClassName("icon", "ml-auto shrink-0 cursor-pointer")}
|
||||
aria-label={t("gitlab:addDiscussionToTaskContext")}
|
||||
onClick={() => onAddContext(buildDiscussionContext(discussion, mrUrl))}
|
||||
>
|
||||
@@ -111,9 +112,8 @@ function Discussion({
|
||||
<div className="flex gap-2">
|
||||
{discussion.resolvable && !discussion.resolved && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 flex-1 cursor-pointer gap-1 sm:h-9"
|
||||
className={controlSizingClassName("standard", "flex-1 cursor-pointer gap-1")}
|
||||
disabled={busy}
|
||||
onClick={() => void onResolve(discussion.id)}
|
||||
>
|
||||
@@ -121,8 +121,7 @@ function Discussion({
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
className="h-11 flex-1 cursor-pointer gap-1 sm:h-9"
|
||||
className={controlSizingClassName("standard", "flex-1 cursor-pointer gap-1")}
|
||||
disabled={busy || !reply.trim()}
|
||||
onClick={() => void submitReply()}
|
||||
>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { listProjectMembers } from "@/lib/api/domains/gitlab-api";
|
||||
import type { GitLabMRUser, GitLabProjectMember } from "@/lib/types/gitlab";
|
||||
import { isCurrentIdentityRequest } from "@/hooks/domains/gitlab/request-identity";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { controlSizingClassName } from "@kandev/ui/control-sizing";
|
||||
|
||||
export function toggleMemberId(ids: number[], id: number): number[] {
|
||||
return ids.includes(id) ? ids.filter((candidate) => candidate !== id) : [...ids, id];
|
||||
@@ -49,7 +50,7 @@ function SelectedMemberBadges({
|
||||
{member.username}
|
||||
<button
|
||||
type="button"
|
||||
className="flex h-11 w-11 cursor-pointer items-center justify-center sm:h-6 sm:w-6"
|
||||
className={`${controlSizingClassName("icon")} cursor-pointer`}
|
||||
aria-label={t(
|
||||
kind === "reviewers" ? "gitlab:removeFromReviewers" : "gitlab:removeFromAssignees",
|
||||
{ username: member.username },
|
||||
@@ -146,9 +147,8 @@ export function MRReviewerControl({
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<h4 className="text-xs font-semibold">{sectionLabel}</h4>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 cursor-pointer sm:h-8"
|
||||
className={controlSizingClassName("standard", "cursor-pointer")}
|
||||
disabled={busy || !changed}
|
||||
onClick={() => void onSave(selectedIds)}
|
||||
>
|
||||
@@ -178,7 +178,7 @@ export function MRReviewerControl({
|
||||
<Button
|
||||
size="icon"
|
||||
variant="outline"
|
||||
className="h-11 w-11 shrink-0 cursor-pointer sm:h-9 sm:w-9"
|
||||
className={controlSizingClassName("icon", "shrink-0 cursor-pointer")}
|
||||
aria-label={searchLabel}
|
||||
disabled={searching}
|
||||
onClick={() => void search()}
|
||||
|
||||
@@ -84,7 +84,7 @@ function MilestoneFilterInput({
|
||||
}}
|
||||
placeholder={t("gitlab:eGSprint42")}
|
||||
aria-label={t("gitlab:milestoneFilterLabel")}
|
||||
className="h-11 w-full md:h-8 md:w-[180px]"
|
||||
className="w-full md:w-[180px]"
|
||||
data-testid="gitlab-milestone-filter"
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -135,9 +135,8 @@ export function SubscriptionToggle(identity: SubscriptionIdentity) {
|
||||
const Icon = subscribed ? IconBellOff : IconBell;
|
||||
return (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="h-11 cursor-pointer gap-1.5 sm:h-8"
|
||||
className="cursor-pointer gap-1.5"
|
||||
disabled={loading}
|
||||
aria-label={label}
|
||||
title={label}
|
||||
|
||||
@@ -440,17 +440,13 @@ export function GitLabWatchDialog({
|
||||
<ScheduleFields kind={kind} form={form} setForm={setForm} />
|
||||
</div>
|
||||
<DialogFooter className="gap-2 sm:gap-0">
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => onOpenChange(false)}
|
||||
className="min-h-11 cursor-pointer sm:min-h-9"
|
||||
>
|
||||
<Button variant="outline" onClick={() => onOpenChange(false)} className="cursor-pointer">
|
||||
{t("common:cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => void save()}
|
||||
disabled={!payload || saving}
|
||||
className="min-h-11 cursor-pointer sm:min-h-9"
|
||||
className="cursor-pointer"
|
||||
>
|
||||
{saveLabel}
|
||||
</Button>
|
||||
|
||||
@@ -39,11 +39,7 @@ function ActionError({ message }: { message: string }) {
|
||||
function NewWatchButton({ onClick }: { onClick: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={onClick}
|
||||
className="min-h-11 w-full cursor-pointer sm:min-h-8 sm:w-auto"
|
||||
>
|
||||
<Button onClick={onClick} className="w-full cursor-pointer sm:w-auto">
|
||||
<IconPlus className="mr-1 h-4 w-4" />
|
||||
{t("gitlab:newWatch")}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user