MCPcopy Create free account
hub / github.com/dailydotdev/apps / classed

Function classed

packages/shared/src/lib/classed.ts:127–162  ·  view source on GitHub ↗
(
  type: ElementType,
  className: string | Record<string, string>,
  ...classes: string[]
)

Source from the content-addressed store, hash-verified

125): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<Component<P>>>;
126
127function classed<T, P extends Record<string, unknown>>(
128 type: ElementType,
129 className: string | Record<string, string>,
130 ...classes: string[]
131): ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>> {
132 return forwardRef<T, P>(function Classed(props, ref) {
133 if (typeof className === 'string') {
134 const inputClassName =
135 typeof props.className === 'string' ? props.className : undefined;
136
137 return React.createElement(type, {
138 ...props,
139 className: classNames(inputClassName, className, ...classes),
140 ref,
141 });
142 }
143
144 if (
145 !isNullOrUndefined(props.className) &&
146 typeof className !== typeof props.className
147 ) {
148 throw new Error('Incompatible className and parameter');
149 }
150
151 return React.createElement(type, {
152 ...props,
153 className: isNullOrUndefined(props.className)
154 ? className
155 : combineObjectStrings(
156 className,
157 props.className as Record<string, string>,
158 ),
159 ref,
160 });
161 });
162}
163
164export default classed;

Callers 15

Drawer.stories.tsxFile · 0.85
EmptyScreen.tsxFile · 0.85
RadialProgress.tsxFile · 0.85
AlertDot.tsxFile · 0.85
GiftPlusModal.tsxFile · 0.85
PlusPlus.tsxFile · 0.85
Button.tsxFile · 0.85
ButtonV2.tsxFile · 0.85
Toast.tsxFile · 0.85
utils.tsFile · 0.85
HeaderButtons.tsxFile · 0.85

Calls 2

isNullOrUndefinedFunction · 0.90
combineObjectStringsFunction · 0.85

Tested by

no test coverage detected