Skip to content

Commit c3e92cc

Browse files
committed
fix(Menu): label props passing
1 parent bbec7bf commit c3e92cc

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/lib/form-field/label.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { flexCss, FlexVariants } from '../flex/flex';
77

88
import styles from './form-field.module.css';
99

10-
type LabelProps<C extends ElementType> = PolyProps<
10+
export type LabelProps<C extends ElementType> = PolyProps<
1111
C,
1212
FlexVariants & {
1313
label: ReactNode;
@@ -16,7 +16,7 @@ type LabelProps<C extends ElementType> = PolyProps<
1616
size?: 'sm' | 'md' | 'lg';
1717
}
1818
>;
19-
type LabelComponent = <C extends ElementType = 'label'>(props: LabelProps<C>) => ReactElement | null;
19+
export type LabelComponent = <C extends ElementType = 'label'>(props: LabelProps<C>) => ReactElement | null;
2020

2121
export const Label: LabelComponent = forwardRef(
2222
<C extends ElementType = 'label'>(

src/lib/menu/menu.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
ComponentProps,
3+
ElementType,
34
forwardRef,
45
ForwardRefExoticComponent,
56
ReactElement,
@@ -18,6 +19,8 @@ import { ListItem, ListItemVariants } from '../shared/list-item';
1819
import { useIsomorphicLayoutEffect } from '../utils/hooks';
1920
import { Presence } from '../shared/presence';
2021

22+
import type { LabelComponent, LabelProps } from '../form-field/label';
23+
import type { PolyRef } from '../utils/polymorphic';
2124
import styles from './menu.module.css';
2225

2326
interface MenuProps {
@@ -109,13 +112,15 @@ export const Separator = (props: ComponentProps<'div'>) => {
109112
return <div {...props} className={clsx(styles.separator, props.className)} />;
110113
};
111114

112-
const MenuLabel = forwardRef((props, ref) => {
113-
return (
114-
<RdxMenu.Label asChild>
115-
<Label {...props} ref={ref} />
116-
</RdxMenu.Label>
117-
);
118-
}) as typeof Label;
115+
const MenuLabel: LabelComponent = forwardRef(
116+
<C extends ElementType = 'label'>(props: LabelProps<C>, ref: PolyRef<C>) => {
117+
return (
118+
<RdxMenu.Label asChild>
119+
<Label {...props} ref={ref} />
120+
</RdxMenu.Label>
121+
);
122+
}
123+
);
119124

120125
MenuRoot.List = List;
121126
MenuRoot.Item = MenuItem;

src/pages-helpers/PaletteRenderer.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export const ColorBox = ({ color, className }: ColorBoxProps) => {
2222
return (
2323
<div className={`w-1/4 flex-1 grow-0 basis-1/4 p-2 last-of-type:grow ${className}`}>
2424
<Column className="h-full">
25-
<Text textStyle="label-sm" weight={600}>
26-
{color}
27-
</Text>
25+
<Text textStyle="label-sm">{color}</Text>
2826
<Text textStyle="mono-sm">{defaultTheme.colors[color]}</Text>
2927
<div className="self-end mt-auto">
3028
<CopyButton label="Copy color token" text={color} />

0 commit comments

Comments
 (0)