為編碼助手提供設計簡報,而不只是截圖
Give your coding assistant a design brief, not just a screenshot
這篇教程示範如何為編碼助手準備設計簡報,從參考頁提取實際色彩、字體和間距,提供可用的設計值。使用 DevTools 的 Computed 面板核對最終樣式,可避免只按選擇器特異性複製錯誤值。靜態 HTML/CSS 匯出不包含應用程式狀態、JavaScript 互動或所有響應式規則。
A screenshot can show a coding assistant the shape of a design. A short brief with actual colors, typography and spacing gives it values it can work with. You can collect those values with browser DevTools; a CSS inspection extension can reduce some of the clicking.
Disclosure: I'm working on Stylegrab, the extension used in the accompanying demo. The workflow below also works manually.
Editorial disclosure: this article was prepared with AI assistance. The examples and product demo use our own sample page; the extension does not call an AI model.
Choose the part of the reference that matters
Start with a page you own or have permission to reuse. Pick one component and a small set of visual rules: a page background, text and accent colors, body and heading type, common spacing and corner radii. Keep your own product's content and identity.
Read rendered values as well as source rules
The declaration with the highest selector specificity doesn't always win. Cascade layers, importance and other parts of the cascade come first. In DevTools, use the Computed panel to check the final value before copying it. For a tool, this is a useful regression test:
@layer base, overrides;
@layer base { #example { color: red; } }
@layer overrides { .example { color: blue; } }
For <div id="example" class="example">, the normal declaration in the later layer wins: blue. A copier that sorts only by selector specificity will give you the wrong starting point.
Write a compact brief
Use these reference values for our settings panel:
Background #0E1016; surface #171B24.
Text #E7E9EE; secondary text #A6ACBA; accent #7C6CFF.
Body: system sans-serif, 16px, line-height 1.5.
Heading: 28px, weight 700.
Spacing: 8px / 16px / 24px. Cards: 12px radius.
Keep our own copy and product identity.
Verify contrast and keyboard focus.
Check the result at 390px and 1280px widths.
These are illustrative values. Replace them with the values you actually need, and compare them with your project's existing design tokens.
Export a component as a starting point
A static HTML/CSS export can help with a button or card. It doesn't bring along the application's state, JavaScript interactions or all responsive rules. Check asymmetric borders and radii too: four different corners cannot be represented by one uniform rounded class.
Verify in the destination page
Check the narrow layout, focus and hover states, text contrast, and the influence of your own theme. With Tailwind, make sure the generated classes are included in your build and that your theme hasn't changed the meaning of a named utility.
The Stylegrab guide includes the workflow and demo. Its free inspection tools and Pro trials are being prepared for the Chrome Web Store release; the page shows the current installation and payment availability.
來源:DEV Community · dev.to