Skip to content

Commit a60d4b1

Browse files
committed
Allow <Card> to be used as a label, fix <CheckboxGroup> props
1 parent 39d5947 commit a60d4b1

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@near-pagoda/ui",
3-
"version": "3.0.3",
3+
"version": "3.0.4",
44
"description": "A React component library that implements the official NEAR design system.",
55
"license": "MIT",
66
"repository": {

src/components/Card.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { type ThemeColor } from '../utils/theme';
55
import s from './Card.module.scss';
66

77
type Props = ComponentPropsWithRef<'div'> & {
8+
as?: 'div' | 'label' | 'span';
89
animateIn?: boolean;
910
href?: string;
1011
target?: ComponentPropsWithRef<'a'>['target'];
@@ -21,6 +22,7 @@ type Props = ComponentPropsWithRef<'div'> & {
2122
export const Card = forwardRef<HTMLDivElement, Props>(
2223
(
2324
{
25+
as = 'div',
2426
animateIn,
2527
background = 'sand-0',
2628
backgroundHover,
@@ -37,7 +39,8 @@ export const Card = forwardRef<HTMLDivElement, Props>(
3739
ref,
3840
) => {
3941
const { Link } = usePagodaUi();
40-
const Element: any = props.href ? Link : 'div';
42+
const Tag = as;
43+
const Element: any = props.href ? Link : Tag;
4144

4245
return (
4346
<Element

src/components/Checkbox.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ export const Checkbox = forwardRef<HTMLInputElement, Props>(({ className = '', t
1818
});
1919
Checkbox.displayName = 'Checkbox';
2020

21-
export const CheckboxGroup = forwardRef<HTMLInputElement, Props>(({ className = '', ...props }, ref) => {
21+
type CheckboxGroupProps = ComponentPropsWithRef<'div'>;
22+
23+
export const CheckboxGroup = forwardRef<HTMLInputElement, CheckboxGroupProps>(({ className = '', ...props }, ref) => {
2224
return <div role="group" className={`${s.group} ${className}`} ref={ref} {...props} />;
2325
});
2426
CheckboxGroup.displayName = 'CheckboxGroup';

0 commit comments

Comments
 (0)