figma

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorToHex

func ColorToHex(c figmaColor) string

ColorToHex converts a Figma RGBA color to a hex string like "#FF5733".

func FillsToStrings

func FillsToStrings(fills []figmaPaint) []string

FillsToStrings converts a list of fills to human-readable color strings.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Figma API client.

func New

func New(baseURL, token string) *Client

New creates a Figma client with the given base URL and personal access token.

func (*Client) ExportImages

func (c *Client) ExportImages(ctx context.Context, fileKey string, nodeIDs []string, format string) ([]ImageExport, error)

ExportImages exports nodes as images and returns temporary URLs.

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, fileKey string) (*FileSummary, error)

GetFile fetches file metadata and page listing.

func (*Client) GetFileComments

func (c *Client) GetFileComments(ctx context.Context, fileKey string) ([]FileComment, error)

GetFileComments lists comments on a file.

func (*Client) GetFileComponents

func (c *Client) GetFileComponents(ctx context.Context, fileKey string) ([]Component, error)

GetFileComponents lists published components in a file.

func (*Client) GetNodes

func (c *Client) GetNodes(ctx context.Context, fileKey string, nodeIDs []string) ([]NodeSummary, error)

GetNodes fetches specific nodes and returns summaries.

func (*Client) ListProjectFiles

func (c *Client) ListProjectFiles(ctx context.Context, projectID string) ([]ProjectFile, error)

ListProjectFiles lists files in a project.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context, teamID string) ([]Project, error)

ListProjects lists projects for a team.

func (*Client) SetHTTPDoer

func (c *Client) SetHTTPDoer(doer apiclient.HTTPDoer)

SetHTTPDoer replaces the HTTP client used for API requests.

type Component

type Component struct {
	Key         string `json:"key"`
	NodeID      string `json:"node_id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Page        string `json:"page"`
	Frame       string `json:"frame"`
}

Component represents a published component.

type Config

type Config struct {
	Name        string `mapstructure:"name"`
	URL         string `mapstructure:"url"`
	Token       string `mapstructure:"token"`
	Description string `mapstructure:"description"`
}

Config holds the configuration for a single Figma instance.

func LoadConfigs

func LoadConfigs(dir string) ([]Config, error)

LoadConfigs reads a .humanconfig YAML file from dir and returns the list of configured Figma instances. Returns nil and no error if the file does not exist.

type FileComment

type FileComment struct {
	ID        string `json:"id"`
	Author    string `json:"author"`
	Message   string `json:"message"`
	CreatedAt string `json:"created_at"`
	Resolved  bool   `json:"resolved"`
	NodeID    string `json:"node_id,omitempty"`
	ParentID  string `json:"parent_id,omitempty"`
}

FileComment represents a comment on a file.

type FileSummary

type FileSummary struct {
	Name           string        `json:"name"`
	LastModified   string        `json:"last_modified"`
	ThumbnailURL   string        `json:"thumbnail_url"`
	Version        string        `json:"version"`
	Pages          []PageSummary `json:"pages"`
	ComponentCount int           `json:"component_count"`
}

FileSummary is the output for file get.

type ImageExport

type ImageExport struct {
	NodeID string `json:"node_id"`
	URL    string `json:"url"`
}

ImageExport represents an exported node image.

type Instance

type Instance struct {
	Name        string
	URL         string
	Description string
	Client      *Client
}

Instance represents a configured Figma workspace ready for use.

func LoadInstances

func LoadInstances(dir string) ([]Instance, error)

LoadInstances reads config, applies env overrides, creates clients, and returns ready-to-use Figma instances.

type NodeSummary

type NodeSummary struct {
	ID          string        `json:"id"`
	Name        string        `json:"name"`
	Type        string        `json:"type"`
	Size        *Size         `json:"size,omitempty"`
	Text        string        `json:"text,omitempty"`
	Typography  *Typography   `json:"typography,omitempty"`
	Fills       []string      `json:"fills,omitempty"`
	Children    []NodeSummary `json:"children,omitempty"`
	ComponentID string        `json:"component_id,omitempty"`
}

NodeSummary is a clean representation of a Figma node.

func SummarizeNode

func SummarizeNode(node figmaNode, maxDepth int) NodeSummary

SummarizeNode converts a raw Figma node into a clean NodeSummary. maxDepth controls how deep to recurse into children (0 = no children).

type PageSummary

type PageSummary struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	ChildCount int    `json:"child_count"`
}

PageSummary describes a top-level page in a Figma file.

type Project

type Project struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Project represents a Figma team project.

type ProjectFile

type ProjectFile struct {
	Key          string `json:"key"`
	Name         string `json:"name"`
	ThumbnailURL string `json:"thumbnail_url"`
	LastModified string `json:"last_modified"`
}

ProjectFile represents a file in a project.

type Size

type Size struct {
	Width  float64 `json:"width"`
	Height float64 `json:"height"`
}

Size represents width/height dimensions.

type Typography

type Typography struct {
	FontFamily string  `json:"font_family"`
	FontSize   float64 `json:"font_size"`
	FontWeight float64 `json:"font_weight"`
}

Typography holds font properties for text nodes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL