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

Function classed

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

Source from the content-addressed store, hash-verified

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

Callers 15

kit.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
common.tsxFile · 0.85

Calls 2

isNullOrUndefinedFunction · 0.90
combineObjectStringsFunction · 0.85

Tested by

no test coverage detected