Command Palette

Search for a command to run...

Назад к скиллам
скилл № 44076

spark-component-token

Create or update a token file in the Token folder in Sources of a spark-ios-component-XXX and add or update unit tests.

БесплатноБез исполняемых скриптов
leboncoinот leboncoin★ 22 звезды на GitHub

Установить spark-component-token в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Add Repository Skill

Overview & Prerequisites

This skill guides you to implement/update a token in spark component.

Component Selection

Parameter Handling:

  • If the skill is invoked with a parameter (e.g., /spark-component-token button):

    • Use the parameter as the component name
    • Verify the folder exists in Modules/Components/{component-name}/
    • If found, use that component and skip the selection step
  • If no parameter is provided:

    • List all folders in the Modules/Components/ directory
    • Use AskUserQuestion to let the user select ONE component from the list
    • Format: Display folder names as options (e.g., "button", "card", "checkbox")

Once the component is selected, all operations must be performed in Modules/Components/{component-name}/ folder.

Use the files in the template folder as reference to manage the token and the unit tests. See Modules/Components/InputOTP/Sources/Core/Token for a full real-world example.

The template uses Border, Size, Typography and Animation purely as illustrations of recurring patterns (see Rules below). A real component's token categories are whatever it actually needs — e.g. Colors, Opacity, Layout, Spacing, Icon, Animation, ... Determine the category names and count from the component's design/usage, not from the template names.

The token is exposed publicly through theme.component.xxx (ComponentToken+XXX.swift) and consumed by the SwiftUI views through EnvironmentTheme+XXXToken.swift. Theses two files are managed by the skill spark-component-migrate-token.

Rules

The Token file must respect theses rules :

  • must be located in Sources/Core/Token and in Tests/UnitTests/Token.
  • the root file is named XXXToken.swift and contains a public struct XXXToken: Equatable with one property per token category the component actually needs (there is no fixed list or fixed count — could be one category or a dozen), plus a public init(theme: any Theme) that forwards the theme to every category that needs it.
  • each token category lives in its own file named XXXToken+CategoryName.swift (e.g. XXXToken+Opacity.swift), containing a public extension XXXToken with a nested struct CategoryName: Equatable.
  • a category that depends on the theme (illustrated by Border and Typography in the template):
    • stores the theme in an internal let theme: any Theme (no explicit init, the internal memberwise init(theme:) is used by the root struct).
    • exposes its values as public computed properties (public var radius: CGFloat { ... }) reading self.theme.
    • exposes the values depending on a state/configuration (intent, isEnabled, isSelected, onError, ...) as public methods (public func width(isSelected: Bool) -> CGFloat). Theses methods replace the old styling use cases.
    • implements a manual static func == comparing the themes: lhs.theme.equals(rhs.theme).
    • is assigned in the root init(theme:).
  • a category that only exposes fixed constants (no theme-dependent values, illustrated by Size in the template) contains only public let constants. On the root struct, its property is a stored default value (public let size = Size()), not assigned in the root init(theme:) body.
  • the animation values (durations, curves) are tokens, not constants: they replace the XXXConstants.Animation enum / XXXConstants.animationDuration. They live in an Animation category (illustrated by Animation in the template):
    • it is a constant category (public let animation = Animation() on the root struct, no theme).
    • the file imports SwiftUI and, since the nested struct shadows the SwiftUI type, refers to it as SwiftUI.Animation.
    • exposes each duration as a public let xxxDuration: TimeInterval (used by the UIKit views and by delays such as DispatchQueue.main.asyncAfter).
    • exposes the matching SwiftUI animation as a public computed property built from the duration (public var fast: SwiftUI.Animation { .easeInOut(duration: self.fastDuration) }), used by the views (.animation(token.animation.fast, value:), withAnimation(token.animation.fast)).
    • when migrating, move the animation values from XXXConstants.swift to the token, update every usage (XXXConstants.animationDuration -> self.theme.component.xxx.animation... in the ViewModifiers / views), remove them from the constants (and delete the constants file and its tests if it becomes empty).
  • every public struct, property and method must be documented with a doc comment (///).
  • use // MARK: - Properties, // MARK: - Methods and // MARK: - Equatable in the categories.
  • the root XXXToken.swift file must have a top-level doc comment that:
    • starts with "Contains all token values for the XXX component, grouped like the Theme."
    • lists every category actually present, each with a doc link (e.g. XXXToken/Categ
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • template/XXXToken+Animation.swift
  • template/XXXToken+AnimationTests.swift
  • template/XXXToken+Border.swift
  • template/XXXToken+BorderTests.swift
  • template/XXXToken+Size.swift
  • template/XXXToken+SizeTests.swift
  • template/XXXToken+Typography.swift
  • template/XXXToken+TypographyTests.swift
  • template/XXXToken.swift
  • template/XXXTokenTests.swift

FAQ

Что делает скилл spark-component-token?

Create or update a token file in the Token folder in Sources of a spark-ios-component-XXX and add or update unit tests.

Как установить скилл spark-component-token?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл spark-component-token запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить spark-component-token с