How to Get the Icon Name from an Icon Instance in Figma Code Connect?

Đang mở
#343 1 bình luận 4 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
figma, typescript
Lĩnh vực
tooling

Hướng nghiên cứu

Start with the Code Connect API documentation and the implementation for figma.instance, which the issue uses in its TypeScript example. Check whether the instance exposes a supported name or SVG property and how examples serialize it. Done means documenting a supported way to read the icon name, or clarifying that Code Connect does not expose one.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

API question

Please provide:

Summary
I am trying to extract the icon name (SVG name) from an icon instance in Figma using Code Connect, but I am not sure which property of the icon instance holds the actual name.

Details

Given an icon instance with these properties in the component:

Property Value
Button True
Is Toggled False
Ix Background False
Size Medium
Icon home (Instance type)
Badge False
Keyboard Focus False

And the following code structure:

{
  props: {
    icon: figma.instance('Icon'),
    size: figma.enum('Size', {
      'Extra Small': 'xs',
      Small: 's',
      Medium: 'm',
      Large: 'l',
    }),
    badge: figma.boolean('Badge'),
    button: figma.boolean('Button'),
    
  },
  example: (props: {
    icon: any;
    size?: string;
    badge?: boolean;
    button?: boolean;
  }) => html`
    <ct-icon
      icon="${props.icon}"
      size="${props.size}"
      badge="${props.badge}"
      button="${props.button}"
    >
    </ct-icon>
  `,
}

after publishing above code to figma, code connect code looks like as below,

<sh-icon
**icon="Code Connect Error: Unsupported type 'object' for attribute"**
size="m"
button
></sh-icon>

Question

How do I get the icon name from the icon instance?
From the properties above, is the Icon property (with value home) the correct way to get the icon name?
If not, which property or method should I use to get the SVG/icon name from the icon instance programmatically?

Expected Outcome

  • Guidance on which property contains the actual icon name.
  • Example on how to extract or read the icon name from the instance for further use.

Thank you!

Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
126
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của figma/code-connect

Tất cả issue của figma/code-connect

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.