Skip to content

armgit / ui

Public Imported from GitHub
0
TypeScript

Align registry UI primitives and preserve consumer dialog footer styles

Andrew Luoe10852a209e9
diff --git a/apps/v4/components/extend/pdf-editor.tsx b/apps/v4/components/extend/pdf-editor.tsx
index cbe7393..34f7e1e 100644
--- a/apps/v4/components/extend/pdf-editor.tsx
+++ b/apps/v4/components/extend/pdf-editor.tsx
@@ -1745,7 +1745,7 @@ function PanelTabStrip<T extends string>({
<div className="flex shrink-0 items-center justify-between gap-1 border-b px-1.5 py-1">
<TooltipProvider delay={TOOLTIP_DELAY_MS}>
<div
- className="flex min-w-0 items-center gap-0.5 overflow-x-auto"
+ className="flex min-w-0 items-center gap-0.5 overflow-x-auto overflow-y-hidden"
role="tablist"
aria-label={label}
>
diff --git a/apps/v4/components/ui/color-picker.tsx b/apps/v4/components/ui/color-picker.tsx
index bd801a9..38ec5a2 100644
--- a/apps/v4/components/ui/color-picker.tsx
+++ b/apps/v4/components/ui/color-picker.tsx
@@ -37,7 +37,7 @@ import {
Select,
SelectContent,
SelectItem,
- SelectPrimitive,
+ SelectTrigger,
} from "@/components/ui/select"
import {
Tooltip,
@@ -1035,26 +1035,21 @@ export function ColorPicker({
}
}}
>
- <SelectPrimitive.Trigger
- render={
- <Button
- type="button"
- variant="outline"
- size="icon-sm"
- aria-label="Color format"
- className="size-8! shrink-0"
- />
- }
+ <SelectTrigger
+ aria-label="Color format"
+ className="size-8! min-h-0 min-w-0 shrink-0 justify-center p-0 [&>[data-slot=select-icon]]:hidden [&>svg]:hidden"
>
- <IconPlaceholder
- lucide="ChevronsUpDown"
- tabler="IconSelector"
- hugeicons="UnfoldMoreIcon"
- phosphor="CaretUpDownIcon"
- remixicon="RiExpandUpDownLine"
- className="size-3.5"
- />
- </SelectPrimitive.Trigger>
+ <span className="flex items-center justify-center">
+ <IconPlaceholder
+ lucide="ChevronsUpDown"
+ tabler="IconSelector"
+ hugeicons="UnfoldMoreIcon"
+ phosphor="CaretUpDownIcon"
+ remixicon="RiExpandUpDownLine"
+ className="size-3.5"
+ />
+ </span>
+ </SelectTrigger>
<SelectContent
alignItemWithTrigger={false}
align="end"
diff --git a/apps/v4/scripts/registry-source.mts b/apps/v4/scripts/registry-source.mts
index 3f8ef02..7cbe2d3 100644
--- a/apps/v4/scripts/registry-source.mts
+++ b/apps/v4/scripts/registry-source.mts
@@ -253,11 +253,6 @@ export function transformRegistrySource(
}
}
if (name === "DialogFooter") {
- classes(
- value("variant") === '"bare"'
- ? '"pt-3"'
- : '"border-t bg-muted/72 pt-4"'
- )
remove("variant")
}
if (name === "DropdownMenuCheckboxItem") {
diff --git a/apps/v4/scripts/registry-source.test.mts b/apps/v4/scripts/registry-source.test.mts
index e6295b4..b0e4595 100644
--- a/apps/v4/scripts/registry-source.test.mts
+++ b/apps/v4/scripts/registry-source.test.mts
@@ -194,6 +194,36 @@ test("The icon-only color select uses popup positioning", () => {
assert.doesNotMatch(source, /RiColorPickerLine/)
})
+test("Color picker select parts share the consumer primitive context", () => {
+ const source = readFileSync(
+ new URL("../components/ui/color-picker.tsx", import.meta.url),
+ "utf8"
+ )
+ for (const family of ["base", "radix"] as const) {
+ const output = transformRegistrySource(source, family)
+ assert.match(
+ output,
+ /import \{ Select, SelectContent, SelectItem, SelectTrigger \} from "@\/components\/ui\/select"/
+ )
+ assert.match(output, /<SelectTrigger\s+aria-label="Color format"/)
+ assert.doesNotMatch(
+ output,
+ /SelectPrimitive|@radix-ui\/react-select|@base-ui\/react\/select/
+ )
+ }
+})
+
+test("Dialog footers retain consumer spacing and explicit class overrides", () => {
+ for (const family of ["base", "radix"] as const) {
+ const output = transformRegistrySource(
+ 'const footer = <><DialogFooter /><DialogFooter variant="bare" /><DialogFooter className="gap-4" /></>',
+ family
+ )
+ assert.match(output, /<DialogFooter className="gap-4"/)
+ assert.doesNotMatch(output, /variant=|pt-3|pt-4|border-t|bg-muted/)
+ }
+})
+
test("Editor loading keeps the normal controls without a document-keyed remount", () => {
const source = readFileSync(
new URL("../components/extend/pdf-editor.tsx", import.meta.url),