Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize S2 icon wrapper #7113

Merged
merged 1 commit into from
Sep 27, 2024
Merged

Centralize S2 icon wrapper #7113

merged 1 commit into from
Sep 27, 2024

Conversation

devongovett
Copy link
Member

Realized we had a bug in the S2 icon transformer: it generated imports for SkeletonWrapper and useSkeletonIcon internal utilities that weren't exported, so couldn't be used in custom icons. Instead of exporting these, I added a single createIcon helper function that centralizes all of the icon logic in one place. This has the benefit that we export fewer internals, and also reduces bundle size since we aren't duplicating the same code in every icon.

return (props: IconProps) => {
let ref = useRef<SVGElement>(null);
let ctx;
// TODO: remove this default once we release RAC and use DEFAULT_SLOT.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from old transformer. We should actually change this but not right before release.

@rspbot
Copy link

rspbot commented Sep 27, 2024

@rspbot
Copy link

rspbot commented Sep 27, 2024

## API Changes

@react-spectrum/s2

/@react-spectrum/s2:createIcon

+createIcon {
+  Component: ComponentType<SVGProps<SVGSVGElement>>
+  context: Context<ContextValue<IconContextValue, SVGElement>>
+  returnVal: undefined
+}

@devongovett devongovett merged commit e60fb42 into main Sep 27, 2024
30 of 31 checks passed
@devongovett devongovett deleted the s2-icon-wrapper branch September 27, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants