41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
'use client';
|
|
import * as React from 'react';
|
|
import { getIntrinsicElementProps, slot } from '@fluentui/react-utilities';
|
|
/**
|
|
* Returns the props and state required to render the component
|
|
*/ export const useBadge_unstable = (props, ref)=>{
|
|
const { shape = 'circular', size = 'medium', appearance = 'filled', color = 'brand', ...badgeProps } = props;
|
|
const state = useBadgeBase_unstable(badgeProps, ref);
|
|
return {
|
|
...state,
|
|
shape,
|
|
size,
|
|
appearance,
|
|
color
|
|
};
|
|
};
|
|
/**
|
|
* Base hook for Badge component, which manages state related to slots structure and ARIA attributes.
|
|
*
|
|
* @param props - User provided props to the Badge component.
|
|
* @param ref - User provided ref to be passed to the Badge component.
|
|
*/ export const useBadgeBase_unstable = (props, ref)=>{
|
|
const { iconPosition = 'before' } = props;
|
|
return {
|
|
iconPosition,
|
|
components: {
|
|
root: 'div',
|
|
icon: 'span'
|
|
},
|
|
root: slot.always(getIntrinsicElementProps('div', {
|
|
ref,
|
|
...props
|
|
}), {
|
|
elementType: 'div'
|
|
}),
|
|
icon: slot.optional(props.icon, {
|
|
elementType: 'span'
|
|
})
|
|
};
|
|
};
|