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

Add a prop like onToggle to Figma component? #216

Closed
1 of 5 tasks
JoshuaKGoldberg opened this issue Oct 12, 2023 · 0 comments · Fixed by #217
Closed
1 of 5 tasks

Add a prop like onToggle to Figma component? #216

JoshuaKGoldberg opened this issue Oct 12, 2023 · 0 comments · Fixed by #217
Labels
category: feature New feature or request

Comments

@JoshuaKGoldberg
Copy link

Is your feature request related to a problem? Please describe.

In a Storybook app, I'd like to be able to run a callback when a user shows or hides a <Figma /> component. It doesn't look like there's a natively supported way to do that right now based on the props?

export interface BlocksCommonProps {

Describe the solution you'd like

Could we please add a prop like onToggle or onShowOrHide that is called when the Hide/Show button is pressed?

  title: collapsed ? "Show" : "Hide",
-  onClick: () => setCollapsed((v) => !v),
+  onClick: () => {
+    setCollapsed((v) => {
+      onToggle(!v);
+      return !v;
+    });
+  },
},

Describe alternatives you've considered

I can't think of anything, sorry. The Figma component itself could store whether the user has toggled it. But -per the context below- this wouldn't be quite enough for my use case.

Design types

  • figma
  • figspec
  • link
  • image
  • iframe

Additional context

This would be useful for sites that want to store whether the Figma embed has been expanded. For example, gamut.codecademy.com today puts very large embeds to emphasize the designs for many components (example: https://gamut.codecademy.com/?path=/docs/atoms-button--cta-button). But non-Codecademy-employees get a file not found on that embed. And even for Codecademy employees, that's a lot of screen real estate. It'd be nice to be able to save the preference if the user saves one.

Corresponding Gamut PR: Codecademy/gamut#2795

I'd be happy to send this feature in myself. 🙂

@JoshuaKGoldberg JoshuaKGoldberg added the category: feature New feature or request label Oct 12, 2023
pocka added a commit that referenced this issue Oct 17, 2023
<#216>

This event callback enables users to save collapsed state and use it for
`defaultCollapsed` property. Having an event for changes is necessary as
the collapsed state is uncontrolled property.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant