dev.cds-web

作者: coinbase

dev.cds-web — 一個可安裝的 AI 代理技能,由 coinbase/cds 發布。

npx skills add https://github.com/coinbase/cds --skill dev.cds-web

CDS Web Package Guidelines

Component Config Adoption (Web)

Use this guidance when adding ComponentConfigProvider defaults for the specific component you are editing.

Required implementation pattern

  1. Register the component in packages/web/src/core/componentConfig.ts using its *BaseProps:
import type { MyComponentBaseProps } from '../category/MyComponent';

export type ComponentConfig = {
  MyComponent?: ConfigResolver<MyComponentBaseProps>;
};
  1. Adopt useComponentConfig in the component and destructure from merged props:
import { useComponentConfig } from '../hooks/useComponentConfig';

export const MyComponent = memo((_props: MyComponentProps) => {
  const mergedProps = useComponentConfig('MyComponent', _props);
  const { className, style, ...props } = mergedProps;

  return <Box className={className} style={style} {...props} />;
});

Rules to preserve behavior

  • Provider config supplies defaults only; local props must continue to win.
  • Use _props as the input variable and mergedProps as the configured output.
  • Type resolver entries with *BaseProps (not polymorphic/full *Props).
  • Keep scope to prop-level theming defaults; do not alter component behavior or control flow.
  • When practical during the same change, prefer arrow-function component declarations.

CSS with Linaria

Use Linaria for zero-runtime CSS. Always use CDS theme CSS variables for colors, spacing, typography, and other design tokens. Reference packages/web/src/core/theme.ts:53-119 for the CSS variable naming pattern.

import { css, cx } from '@linaria/core';

const containerCss = css`
  /* Spacing tokens */
  padding: var(--space-2);
  gap: var(--space-1);

  /* Color tokens */
  background: var(--color-bgPrimary);
  color: var(--color-fgPrimary);
  border: 1px solid var(--color-line);

  /* Border radius tokens */
  border-radius: var(--borderRadius-400);

  /* Typography tokens */
  font-size: var(--fontSize-body);

  &:hover {
    background: var(--color-bgPrimaryHover);
  }
`;

// Merge classNames with cx utility **in CORRECT ORDER**
<div
  className={cx(
    containerCss, // Base styles first
    isCompact && conditionClassToApply, // Conditional computed styles
    className, // User-provided className prop
    classNames.root, // granular overrides last
  )}
/>;

IMPORTANT: Using CSS variables ensures components respond correctly to theme changes (light/dark mode, brand themes).

CSS Variable Naming

Design tokens from packages/common/src/core/theme.ts map to CSS variables:

  • Colors: --color-{tokenName} (e.g., --color-bgPrimary, --color-fgMuted)
  • Spacing: --space-{scale} (e.g., --space-2 = 16px, --space-3 = 24px)
  • Typography: --fontSize-{font}, --fontWeight-{font}, --lineHeight-{font}, --fontFamily-{font}
  • Border: --borderRadius-{size}, --borderWidth-{size}
  • Sizing: --iconSize-{size}, --avatarSize-{size}, --controlSize-{name}
  • Shadows: --shadow-{level}

Responsive Breakpoints

Reference packages/web/src/styles/media.ts for breakpoint values:

  • phone: 0-767px
  • tablet: 768-1279px
  • desktop: 1280px+

Use the Box component's responsive prop API for responsive values:

<Box padding={{ base: 2, phone: 1, desktop: 3 }} />

Granular classNames

  • Components can expose a classNames object prop for granular overrides on child elements within the component.
  • Since the keys of the classNames object are specific to the component they should never be on the *BaseProps type

data-attributes

  • Use data attributes for state-based styling: data-active, data-disabled, data-variant, data-filled

Inline styles

  • Web components should all expose a style and styles object props for overriding inline styles.
  • As styling is a concern of that specific component, the style and styles props should never be on the *BaseProps type.
  • Styles should be merged into a single object with a useMemo hook and applied in the correct order (default styles => style prop => styles[ELEMENT_NAME] prop).

Example:

type ComponentProps = ComponentBaseProps & {
  style?: React.CSSProperties;
  styles?: { root?: React.CSSProperties; label?: React.CSSProperties };
};

Animation

Use Framer Motion for complex animations:

import { m as motion, AnimatePresence } from 'framer-motion';

<AnimatePresence>
  {visible && (
    <motion.div
      initial={{ opacity: 0, y: -8 }}
      animate={{ opacity: 1, y: 0 }}
      exit={{ opacity: 0, y: -8 }}
    />
  )}
</AnimatePresence>;

For simple transitions, prefer CSS transitions in Linaria.

Accessibility

Use ARIA attributes:

<div role="group" aria-roledescription="carousel" aria-live="polite">
  <button aria-pressed={isActive} tabIndex={isVisible ? 0 : -1} />
</div>
  • Implement keyboard navigation (Arrow keys, Home, End) for interactive components.
  • Provide descriptive labels for all interactive elements
  • Associate form inputs with helper text using aria-describedby
  • Use semantic HTML elements whenever possible
  • Follow WCAG 2.1 AA standards for color contrast
  • Support screen readers by providing descriptive labels and instructions

Web-Specific Props

  • className?: string - CSS class always applied to root element
  • style?: React.CSSProperties - inline styles always applied to root element
  • Polymorphic as prop for element type (where applicable e.g. see Box)

Reference Components

  • Carousel: compound components, imperative handle, context pattern
  • Select (alpha/): generics, controlled/uncontrolled
  • RollingNumber: animation config, measurement patterns

來自 coinbase 的更多技能

git.repo-manager
coinbase
git.repo-manager — 一個可安裝的AI代理技能,由coinbase/cds發布。
official
agentic-wallet
coinbase
透過 awal CLI 進行加密錢包操作 — 登入、查詢餘額、發送 USDC/ETH/POL/SOL、交易代幣、為錢包充值,以及使用 x402 支付協議來…
official
authenticate-wallet
coinbase
基於電子郵件OTP的錢包驗證,包含驗證與狀態檢查。兩步驟登入流程:先透過電子郵件發起請求以接收6位數OTP,再使用flowId與驗證碼完成驗證。內建電子郵件、flowId及OTP的輸入驗證規則,防止在執行指令前發生Shell注入。提供狀態檢查、餘額查詢、地址擷取及透過配套CLI指令存取錢包視窗等功能。所有指令皆支援--json輸出,以利機器讀取...
official
fund
coinbase
透過 Coinbase Onramp 或直接轉帳將 USDC 存入錢包。開啟輔助介面,用戶可選擇預設金額(10 美元、20 美元、50 美元)或自訂數值,並從 Apple Pay、簽帳卡、銀行轉帳或 Coinbase 帳戶資金中選擇付款方式。支援多種付款方式,結算時間各異:卡片與 Apple Pay 即時到帳,ACH 銀行轉帳需 1–3 天。資金以 Base 網路上的 USDC 存入;用戶亦可透過 npx awal@2.0.3... 直接將 USDC 發送至錢包地址。
official
monetize-service
coinbase
部署一個付費API端點,其他代理可透過x402協議發現並付費使用。基於HTTP 402支付協議,在Base鏈上按請求收取USDC;客戶端使用簽名交易支付,無需API金鑰或帳戶。當您聲明發現擴展時,自動將端點註冊至x402 Bazaar供代理發現。支援多種定價層級、萬用路由,以及透過Express中介軟體為每個端點設定多種支付選項。基於@x402/express和@x402/core建置...
official
pay-for-service
coinbase
在Base上透過x402協議自動以USDC支付來呼叫付費API。執行HTTP請求(GET、POST等)至支援x402的端點,自動處理原子化USDC支付。支援透過方法、JSON主體、查詢參數及自訂標頭進行請求自訂。包含支付控制:設定每次請求的最大USDC金額,並使用關聯ID分組相關操作。需要錢包驗證及足夠的USDC餘額;驗證所有使用者輸入以防止shell...
official
query-blockchain-data
coinbase
透過 CDP SQL API 與 x402 查詢 Base 上的鏈上區塊鏈數據。當您或用戶想查看關於已解碼區塊的鏈上資訊時使用…
official
query-onchain-data
coinbase
使用SQL在Base上查詢鏈上數據,每次查詢需支付x402費用。透過CoinbaseQL(基於ClickHouse的SQL方言)存取解碼事件、交易與區塊,支援JOIN、CTE、子查詢及標準函數。主要提供三個資料表:base.events(解碼的智能合約日誌)、base.transactions(完整交易數據)及base.blocks(區塊元數據)。查詢事件時需對索引欄位(event_signature、address、block_timestamp)進行過濾,以避免掃描完整資料表...
official