Icon instance type not being respected

未关闭
#314 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react, typescript

调研方向

Start by tracing how figma.instance<React.FunctionComponent> is rendered in the Code Connect preview, then compare it with the handling of icon instances passed as props. The issue does not name source files or tests, so locate the relevant preview and instance handling first. Done means the nested icon is shown as {ArrowRightMedium} instead of <ArrowRightMedium />.

由索引模型根据 Issue 内容生成。

描述

API question

Hello,

I've setup my icon's example code to be react components. In the majority of my connections when icon's are being used in a prop it shows correctly as a react component but when its a child of a component it shows as a JSX element. I need it to always show as a react component not jsx.

Icon:

figma.connect(
    'https://www.figma.com/design/OMITTED/%E2%9D%96-00-Assets?node-id=OMITTED',
    {
        variant: {
            size: 'medium-24px',
            direction: '← left',
        },
        example: () => ArrowLeftMedium,
    }
);

Component connection:

figma.connect(
    IconButton,
    'https://www.figma.com/design/OMITTED/%E2%9D%96-02-Elements?node-id=OMITTED,
    {
        props: {
            ...other code,
            children: figma.nestedProps('icon-label-icon', {
                IconPrefix: figma.boolean('show-icon-L', {
                    true: figma.instance<React.FunctionComponent>('icon-left'),
                    false: undefined,
                }),
                IconSuffix: figma.boolean('show-icon-R', {
                    true: figma.instance<React.FunctionComponent>('icon-right'),
                    false: undefined,
                }),
            }),
        },
        example: ({ children, ...props }) => (
            <IconButton {...props}>
                {children.IconPrefix}
                {children.IconSuffix}
            </IconButton>
        ),
    }
);

In the code connect preview window:

Image

What I would like to be shown based on this example is the icon as {ArrowRightMedium} not <ArrowRightMedium />

Could I be directed on how to correct this? Thank you

主要语言
TypeScript
星标
1.6k
派生
126
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

figma/code-connect 的其他 Issue

查看 figma/code-connect 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。