Skip to content

Comments

Add support for numbers#20

Merged
v-volod merged 1 commit intomainfrom
14-add-support-for-number-tokens
Dec 18, 2025
Merged

Add support for numbers#20
v-volod merged 1 commit intomainfrom
14-add-support-for-number-tokens

Conversation

@v-volod
Copy link
Collaborator

@v-volod v-volod commented Dec 18, 2025

What

This change introduces explicit support for number type design tokens, enabling them to be correctly extracted and converted into SnappThemingDeclaration's metricsCache. A dedicated extractor for number values has been added, and the DesignTokensConverter has been updated to utilize it. Corresponding test cases and resources have also been updated to reflect this new functionality.

Why

Previously, number type design tokens were not explicitly handled and would result in an unsupported token error. By adding explicit support, the system can now correctly parse and utilize numerical design tokens, making the theming system more comprehensive and aligned with the DTCG standard for handling primitive value types. This enhances the utility and flexibility of the design token integration.

Changes

  • New File: Sources/SnappThemingDesignTokensSupport/Convertor/Extractor/DesignTokensNumberValueExtractor.swift was added to handle the extraction of number values.
  • DesignTokensConverter.swift: Updated to specifically handle number type tokens, routing them to the new extractor instead of marking them as unsupported.
  • design.tokens.json (test resource): Added a new number type token (number.aspect.square) for testing.
  • expected.snapptheming.json (test resource): Updated to include the expected output for the newly supported number token.
  • SnappThemingDesignTokensParserTests.swift: Modified a test case to reflect that number tokens are now supported, and fontWeight remains unsupported, ensuring correct error handling for other unhandled types.

@v-volod v-volod linked an issue Dec 18, 2025 that may be closed by this pull request
Copy link
Collaborator

@oleksiikolomiietssnapp oleksiikolomiietssnapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import SnappTheming

extension DesignTokensTokenValueExtractor {
static var number: Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, extractors are used internally.

@github-actions
Copy link

🛡️ Code Coverage Report

Target Lines Coverage
1 SnappThemingDesignTokensSupport 619 99.68%

Generated by Swift Coverage Action.

@v-volod v-volod merged commit df4cd14 into main Dec 18, 2025
1 of 2 checks passed
@v-volod v-volod deleted the 14-add-support-for-number-tokens branch December 18, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Number tokens

2 participants