leafygreen-authoring

作者: mongodb

在具有package.json中包含@leafygreen-ui套件的專案中,撰寫或編輯React元件(.tsx/.ts)時自動觸發。提供元件對應、…

npx skills add https://github.com/mongodb/leafygreen-ui --skill leafygreen-authoring

LeafyGreen Authoring Conventions

Apply these conventions whenever writing or editing React components in a project that uses @leafygreen-ui/* packages.

Always prefer LeafyGreen components over plain HTML

When a user asks to add any UI element — in plain language, from a Figma design, or anywhere else — always check if a LeafyGreen component exists for it first. Never use a plain HTML element (<button>, <input>, <select>, etc.) when an @leafygreen-ui equivalent is available.

Common mappings:

User asks for…Use
Button, CTA@leafygreen-ui/buttonButton
Text input, text field@leafygreen-ui/text-inputTextInput
Dropdown, select@leafygreen-ui/selectSelect, Option
Searchable dropdown@leafygreen-ui/comboboxCombobox
Search box@leafygreen-ui/search-inputSearchInput
Number field@leafygreen-ui/number-inputNumberInput
Checkbox@leafygreen-ui/checkboxCheckbox
Radio button@leafygreen-ui/radio-groupRadioGroup, Radio
Toggle, switch@leafygreen-ui/toggleToggle
Icon button@leafygreen-ui/icon-buttonIconButton
Icon@leafygreen-ui/iconIcon
Heading, body text, label@leafygreen-ui/typographyH1H3, Body, Label, Subtitle
Modal, dialog@leafygreen-ui/modalModal
Tooltip@leafygreen-ui/tooltipTooltip
Tabs@leafygreen-ui/tabsTabs, Tab
Table@leafygreen-ui/tableTable, Row, Cell
Badge, tag, chip@leafygreen-ui/badgeBadge
Banner, alert@leafygreen-ui/bannerBanner
Toast, notification@leafygreen-ui/toastToast
Menu, context menu@leafygreen-ui/menuMenu, MenuItem
Card@leafygreen-ui/cardCard
Code block@leafygreen-ui/codeCode
Logo / logomark@leafygreen-ui/logoMongoDBLogoMark, MongoDBLogo
Stepper, progress steps@leafygreen-ui/stepperStepper, Step
Pipeline@leafygreen-ui/pipelinePipeline, Stage

If a package is not yet installed, install it before writing the component code:

npm install @leafygreen-ui/[package-name]

Component imports

Always use named imports for LG components:

import { H1, Body, Subtitle } from '@leafygreen-ui/typography'
import { Button } from '@leafygreen-ui/button'
import Icon from '@leafygreen-ui/icon'           // default import
import { MongoDBLogoMark } from '@leafygreen-ui/logo'

Styling approach

Always use design tokens from @leafygreen-ui/tokens for colors — never hard-coded hex values. Tokens are the single source of truth for color in the design system and automatically resolve to the correct value for dark or light mode.

import { palette } from '@leafygreen-ui/tokens'

// Correct: use a token
color: palette.gray.dark2

// Avoid: hard-coded hex
color: '#3D4F58'

Figma MCP → auto-install missing packages

When implementing a design from the Figma MCP, the component descriptions include the LeafyGreen package name, e.g.:

⚛️ React name: @leafygreen-ui/text-input
⚛️ React name: @leafygreen-ui/select

Before writing any component code:

  1. Scan all ⚛️ React name: entries in the Figma design context
  2. Cross-check each @leafygreen-ui/* package against package.json
  3. Install any that are missing: npm install @leafygreen-ui/[package-name]
  4. Never substitute plain HTML for a LeafyGreen component that is called out in the design spec

File structure

  • New components go in src/components/[ComponentName].tsx
  • One component per file
  • Name files and components in PascalCase: ProjectCard.tsx, not project-card.tsx
  • Ask before creating new folders outside of src/components/

TypeScript

  • Always define prop types explicitly using TypeScript interfaces
  • Do not use any as a type

General

  • Keep components focused. If a component is doing more than one thing, split it.

來自 mongodb 的更多技能

atlas-stream-processing
mongodb
管理 MongoDB Atlas Stream Processing (ASP) 工作流程。處理工作區佈建、資料來源/接收器連線、處理器生命週期操作等。
official
mongodb-atlas-stream-processing
mongodb
管理 MongoDB Atlas Stream Processing (ASP) 工作流程。處理工作區佈建、資料來源/接收器連線、處理器生命週期操作,…
official
mongodb-connection
mongodb
最佳化 MongoDB 用戶端連線設定(連線池、逾時、模式),適用於任何支援的驅動程式語言。在處理、更新或檢閱相關工作時使用此技能…
official
mongodb-mcp-setup
mongodb
引導使用者設定 MongoDB MCP 伺服器的關鍵選項。當使用者已安裝 MongoDB MCP 伺服器但尚未設定…時,請使用此技能。
official
mongodb-natural-language-querying
mongodb
使用自然語言生成唯讀的 MongoDB 查詢(find)或聚合管線,並搭配集合結構描述與範例文件作為上下文。使用此技能……
official
mongodb-query-optimizer
mongodb
協助 MongoDB 查詢優化與索引建立。僅在使用者要求優化或效能時使用:「我該如何優化這個查詢?」、「我該如何…」
official
mongodb-schema-design
mongodb
MongoDB 結構描述設計模式與反模式。適用於設計資料模型、審查結構描述、從 SQL 遷移,或疑難排解效能問題時…
official
mongodb-search-and-ai
mongodb
引導 MongoDB 使用者實作並最佳化 Atlas Search(全文檢索)、Vector Search(語意檢索)與 Hybrid Search(混合檢索)解決方案。當……時使用此技能。
official