Skip to content

Commit 67ea6d6

Browse files
committed
Fix multiple issues with Icon components classes
I don't know what the hell the previous implementer had thought, but Icons rootClasses and wrapperClasses were thrown all over the place. It's somekind of savant miracle that it worked before. The guy must've had some extra terrestial knowledge about something. So fix the class prop passing and fix the Thunderstorelogo in the Footer as non-fontawesome icons are not behaving nicely with accepting classes.
1 parent deff483 commit 67ea6d6

File tree

3 files changed

+67
-27
lines changed
  • apps/cyberstorm-remix/app/commonComponents/Footer
  • packages/cyberstorm/src

3 files changed

+67
-27
lines changed

apps/cyberstorm-remix/app/commonComponents/Footer/Footer.css

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@
4040
}
4141

4242
.footer__logo {
43-
flex-shrink: 0;
44-
height: var(--footer-info-leftside-company-icon-height);
43+
display: flex;
44+
justify-content: center;
45+
46+
> svg {
47+
height: var(--footer-info-leftside-company-icon-height);
48+
}
4549
}
4650

4751
.footer__icon-links {

packages/cyberstorm/src/newComponents/Icon/Icon.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ export const Icon = memo(function Icon(props: IconProps) {
1515
primitiveType="icon"
1616
{...forwardedProps}
1717
wrapperClasses={classnames(
18+
props.noWrapper ? undefined : props.wrapperClasses
19+
)}
20+
rootClasses={classnames(
1821
...componentClasses("icon", csVariant, undefined, undefined),
19-
rootClasses
22+
props.noWrapper ? rootClasses : undefined
2023
)}
2124
/>
2225
);

packages/cyberstorm/src/primitiveComponents/Frame/Frame.tsx

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -220,49 +220,82 @@ export const Frame = memo(function Frame(
220220

221221
const svgIconRef = ref as React.ForwardedRef<SVGElement>;
222222

223-
const clones = Children.map(children, (child) => {
224-
if (React.isValidElement(child)) {
225-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
226-
return cloneElement(child as React.ReactElement<any>, {
227-
className: classnames(
228-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
229-
(child.props as any).className,
230-
"icon",
231-
noWrapper && csMode === "inline" ? "icon--inline" : null,
232-
wrapperClasses
233-
),
234-
ref: noWrapper ? svgIconRef : null,
235-
...svgFProps,
236-
});
237-
} else {
238-
return null;
239-
}
240-
});
241-
242223
let content = null;
243224

244225
if (noWrapper) {
245-
content = <>{clones}</>;
226+
content = (
227+
<>
228+
{Children.map(children, (child) => {
229+
if (React.isValidElement(child)) {
230+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
231+
return cloneElement(child as React.ReactElement<any>, {
232+
className: classnames(
233+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
234+
(child.props as any).className,
235+
"icon",
236+
csMode === "inline" ? "icon--inline" : null,
237+
rootClasses
238+
),
239+
ref: svgIconRef,
240+
...svgFProps,
241+
});
242+
} else {
243+
return null;
244+
}
245+
})}
246+
</>
247+
);
246248
} else if (csMode === "inline") {
247249
const spanIconRef = ref as React.ForwardedRef<HTMLSpanElement>;
248250
content = (
249251
<span
250252
{...strippedForwardedProps}
251-
className={classnames("icon", "icon--inline", wrapperClasses)}
253+
className={wrapperClasses}
252254
ref={spanIconRef}
253255
>
254-
{clones}
256+
{Children.map(children, (child) => {
257+
if (React.isValidElement(child)) {
258+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
259+
return cloneElement(child as React.ReactElement<any>, {
260+
className: classnames(
261+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
262+
(child.props as any).className,
263+
"icon",
264+
"icon--inline",
265+
rootClasses
266+
),
267+
...svgFProps,
268+
});
269+
} else {
270+
return null;
271+
}
272+
})}
255273
</span>
256274
);
257275
} else {
258276
const divIconRef = ref as React.ForwardedRef<HTMLDivElement>;
259277
content = (
260278
<div
261279
{...strippedForwardedProps}
262-
className={classnames("icon", wrapperClasses)}
280+
className={wrapperClasses}
263281
ref={divIconRef}
264282
>
265-
{clones}
283+
{Children.map(children, (child) => {
284+
if (React.isValidElement(child)) {
285+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
286+
return cloneElement(child as React.ReactElement<any>, {
287+
className: classnames(
288+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
289+
(child.props as any).className,
290+
"icon",
291+
rootClasses
292+
),
293+
...svgFProps,
294+
});
295+
} else {
296+
return null;
297+
}
298+
})}
266299
</div>
267300
);
268301
}

0 commit comments

Comments
 (0)