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

FigmaApply Issue #218

Open
amyleed2 opened this issue Dec 2, 2024 · 3 comments
Open

FigmaApply Issue #218

amyleed2 opened this issue Dec 2, 2024 · 3 comments
Labels
feature request under discussion The Code Connect team is currently discussing this request

Comments

@amyleed2
Copy link

amyleed2 commented Dec 2, 2024

Describe the feature you'd like:
I confirmed that the return type of figmaApply is view in SwiftUI.
The Code Connect document guides users to use figmaApply when expressing different property values or function for a component depending on a conditional statement.
However, when implementing components, they need to be implemented differently depending on various situations.
For example, there are several modifiers declared in a specific component, and each modifier may or may not be declared depending on each conditional statement.
However, because figmaApply returns a View, there is an issue of not being able to find the modifier for a specific component when there are multiple conditional statements.
If you check the code below, you will understand it faster.

plublic struct RightItem: View {
...
}

public extension RightItem {
func setTitle(_ title: String) -> RightItem {
...
return self
}
}

struct RightItem: FigmaConnect {

@FigmaEnum(“Theme”, mapping: [“Standard”:true])
var isStandard: Bool = false

@FigmaEnum(“Theme”, mapping: [“SubTle”:true])
var isSubtle: Bool = false
…
var body: some View {

	RightItem()
	.figmaApply(isStandard, { item in
		...
	})
	.figmaApply(isSubtle, { item in
		item**_.setTitle(“title")_**
	})
}

}

When using ‘setTitle’ function, the modifier is not found.
Shouldn't a feature be added so that figmaApply's Retrun type can return to a specific View, rather than a View?
I would like to ask you to consider this matter.

@rrabherufigma rrabherufigma added the under discussion The Code Connect team is currently discussing this request label Dec 11, 2024
@rrabherufigma
Copy link

Hi @amyleed2 . Thank you for your report. To unblock for now, have you tried a variant restriction on isSubtle ?

struct RightItem : FigmaConnect {
  let component = RightItem.self
  let variant = ["isSubtle": true]
  let figmaNodeUrl: String = "https://..."
  ...

   var body: some View {
      RightItem()
       .setTitle("title")
        ...
   }
}

@amyleed2
Copy link
Author

I already know that the problem will be solved if I use variants to use the function ’setTitle’.
However, Because Using Variants requires repetitive work like repeating code lines, I want to make simple code line using ‘figmaApply’.
But, no matter how much I read document about code-connect, there seems to be no way to implement it other than using variant.

@slees-figma
Copy link

Hi @amyleed2, thanks for the response! Unfortunately using variants is the only way to achieve this right now. We'll keep this open and will let you know if we make any changes here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request under discussion The Code Connect team is currently discussing this request
Projects
None yet
Development

No branches or pull requests

3 participants