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

[Request] Add MinimalEffectsMixin interface for consistency #291

Open
andreincu opened this issue May 1, 2024 · 4 comments
Open

[Request] Add MinimalEffectsMixin interface for consistency #291

andreincu opened this issue May 1, 2024 · 4 comments

Comments

@andreincu
Copy link

andreincu commented May 1, 2024

This is a feature request for adding MinimalEffectsMixin for being consistent with the rest, plus adding the ability to extract nodes that support effects.

Before:
interface BlendMixin extends MinimalBlendMixin {
  isMask: boolean
  maskType: MaskType
  effects: ReadonlyArray<Effect>
  effectStyleId: string
  setEffectStyleIdAsync(styleId: string): Promise<void>
}
After:
interface MinimalEffectsMixin {
  effects: ReadonlyArray<Effect>
  effectStyleId: string
  setEffectStyleIdAsync(styleId: string): Promise<void>
}
  
interface BlendMixin extends MinimalBlendMixin, MinimalEffectsMixin {
  isMask: boolean
  maskType: MaskType
}

This will allow doing the following:

type NodeWithEffects = Extract<SceneNode, MinimalBlendMixin>
// Output: type NodeWithEffects = FrameNode | GroupNode | ComponentSetNode | ComponentNode | InstanceNode | BooleanOperationNode | VectorNode | StarNode | LineNode | EllipseNode | PolygonNode | RectangleNode | TextNode | StampNode | HighlightNode | WashiTapeNode

https://github.com/figma/plugin-typings/blob/67cdb4a189db19caa1d4e5f87971e7a3931e273b/plugin-api.d.ts#L1626C1-L1627C24

@rohitchouhan8
Copy link
Contributor

Will flag internally! Seems like a good improvement overall.

@andreincu
Copy link
Author

Should I create another ticket for layoutGrids as well?

Or is sufficient to leave it here in the comments:

type MinimalLayoutGridMixin = Pick<BaseFrameMixin, 'layoutGrids' | 'gridStyleId' | 'setGridStyleIdAsync'>;

Ofc, in your case, you'll need to define and extend the BaseFrameMixin.

@jefflee-figma
Copy link
Contributor

@andreincu Could you clarify what the purpose of this change is? It seems like after this change, BlendMixin would be the only interface to inherit from MinimalEffectsMixin, which seems like it could be a premature abstraction.

@andreincu
Copy link
Author

andreincu commented Jun 2, 2024

Hi @jefflee-figma,

I proposed this change for mainly 2 reasons:

  1. [consistency] since these properties seems to be similar with MinimalFillsMixin, MinimalStrokesMixin, then for me, it made sense to have an interface for Effects as well
  2. [extensiveness/modularity] similar to fills, strokes, autolayout, to allow us, the people consuming the types, to extend them with ease without redefined them locally. e.g.: Exclude<SceneNode, MinimalEffectsMixin> this way I can quickly verify the scenarios where effects do not exists.

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

No branches or pull requests

3 participants