Files
2nd/10_Wiki/Topics/DevOps_and_Security/Figma.md
T
2026-05-10 22:08:15 +09:00

159 lines
5.3 KiB
Markdown

---
id: wiki-2026-0508-figma
title: Figma
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Figma Design, FigJam, Dev Mode]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [design, design-tool, collaboration, design-system]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
language: TypeScript
framework: Figma-Plugin-API/REST-API
---
# Figma
## 매 한 줄
> **"매 browser-native, multiplayer, vector design tool 의 매 default standard"**. Field & Wallace 2012 시작 — CRDT-based multiplayer + WebGL canvas + plugin ecosystem 으로 매 Sketch/XD 를 매 시장에서 displace. 매 2025 Adobe 인수 무산 후 independent, AI 기능 (Make Designs, Visual Search) 추가, Dev Mode 가 매 디자인-코드 핸드오프 표준.
## 매 핵심
### 매 architecture
- WebGL canvas (GPU-accelerated vector rendering).
- Multiplayer via OT/CRDT — sub-100ms cursor sync.
- File = node tree (Document → Page → Frame → ...).
- Component / variant / variable system.
### 매 핵심 primitive
- **Frame**: layout container (auto-layout = flexbox-like).
- **Component / Instance**: reusable + override.
- **Variable**: design token (color, number, string, boolean) — mode 별 (light/dark).
- **Style**: deprecated 추세, variable 로 대체.
### 매 응용
1. Design system 운영 (component library, token).
2. Prototyping (interactive flow).
3. Dev handoff (Dev Mode + code generation).
4. Whiteboard / brainstorming (FigJam).
## 💻 패턴
### Plugin: rename selection
```typescript
// manifest.json: { "main": "code.ts", "ui": "ui.html", "editorType": ["figma"] }
figma.showUI(__html__, { width: 240, height: 120 });
figma.ui.onmessage = (msg: { type: string; prefix: string }) => {
if (msg.type === 'rename') {
for (const node of figma.currentPage.selection) {
node.name = `${msg.prefix}_${node.name}`;
}
figma.notify(`Renamed ${figma.currentPage.selection.length}`);
}
};
```
### Variable mode swap (dark mode)
```typescript
const collection = figma.variables.getLocalVariableCollections()
.find(c => c.name === 'Theme')!;
const darkModeId = collection.modes.find(m => m.name === 'Dark')!.modeId;
figma.currentPage.setExplicitVariableModeForCollection(collection, darkModeId);
```
### REST API: export frames as PNG
```typescript
const FILE = 'abc123', TOKEN = process.env.FIGMA_TOKEN!;
const r = await fetch(`https://api.figma.com/v1/files/${FILE}`, {
headers: { 'X-Figma-Token': TOKEN }
});
const file = await r.json();
const frameIds = file.document.children.flatMap(p =>
p.children.filter(n => n.type === 'FRAME').map(n => n.id));
const exp = await fetch(
`https://api.figma.com/v1/images/${FILE}?ids=${frameIds.join(',')}&format=png&scale=2`,
{ headers: { 'X-Figma-Token': TOKEN } }
);
const { images } = await exp.json(); // { id: url }
```
### Token export → Style Dictionary
```typescript
// figma-token-bridge plugin output
const tokens = figma.variables.getLocalVariables().map(v => ({
name: v.name.replace(/\//g, '.'),
value: v.valuesByMode[defaultMode],
type: v.resolvedType,
}));
figma.ui.postMessage({ type: 'export', tokens });
// Then transform to Style Dictionary JSON → CSS / iOS / Android.
```
### Auto-layout (component definition)
```typescript
const frame = figma.createFrame();
frame.layoutMode = 'HORIZONTAL';
frame.primaryAxisAlignItems = 'CENTER';
frame.counterAxisAlignItems = 'CENTER';
frame.itemSpacing = 8;
frame.paddingLeft = frame.paddingRight = 16;
frame.paddingTop = frame.paddingBottom = 12;
frame.cornerRadius = 8;
```
### Webhook: sync to repo
```typescript
// Figma webhook → CI → token regenerate → PR
app.post('/figma-webhook', async (req, res) => {
if (req.body.event_type === 'FILE_UPDATE') {
await exec('npm run tokens:pull && npm run tokens:build');
await octokit.pulls.create({ /* ... */ });
}
res.sendStatus(200);
});
```
## 매 결정 기준
| 상황 | Approach |
|---|---|
| 디자인 시스템 신규 구축 | Variables + Component + auto-layout |
| 디자인-코드 sync | Webhook + Style Dictionary pipeline |
| Vector illustration | Figma 또는 매 Illustrator (Figma 충분 in 2026) |
| 3D/motion | Figma X — Spline / After Effects |
| Real-time whiteboard | FigJam |
**기본값**: Component + auto-layout + variable. Style 은 매 deprecated.
## 🔗 Graph
- 부모: [[Design Tool]] · [[Collaboration Software]]
- 변형: [[FigJam]] · [[Figma Slides]] · [[Sketch]] · [[Penpot]]
- 응용: [[Design System]] · [[Design Token]] · [[Dev Mode]]
- Adjacent: [[Style Dictionary]] · [[Storybook]] · [[Tokens Studio]]
## 🤖 LLM 활용
**언제**: Design system architecture, plugin authoring, design-code pipeline.
**언제 X**: Vector math 자체 — SVG/Skia primitive 학습 우선.
## ❌ 안티패턴
- **Detached instance 남발**: 매 component 의 의미 사라짐.
- **Style + Variable 혼용**: 매 variable 로 통일.
- **No naming convention**: `Frame 1234` 가 매 디자인 시스템 죽임.
- **Manual handoff (JPG export)**: Dev Mode 또는 매 token pipeline 사용.
- **Unversioned**: Branching feature (Org plan) 사용.
## 🧪 검증 / 중복
- Verified (Figma docs, Plugin API ref, Dev Mode 2024 release notes).
- 신뢰도 A.
## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Figma primitives + plugin/REST/token patterns |