Skip to content

[MBL-19905] NGC - InstUI Component Tokens#4002

Draft
vargaat wants to merge 22 commits intomasterfrom
feature/MBL-19905-InstUI-component-tokens
Draft

[MBL-19905] NGC - InstUI Component Tokens#4002
vargaat wants to merge 22 commits intomasterfrom
feature/MBL-19905-InstUI-component-tokens

Conversation

@vargaat
Copy link
Copy Markdown
Collaborator

@vargaat vargaat commented Apr 21, 2026

Add component-level design tokens (InstUI component layer)

Adds a third token layer to InstUI, sitting above Semantic and Primitive: Component. Each UI component from instructure-ui (Badge, TextInput, Checkbox, etc.) now has a typed Swift struct collecting all its design decisions — colors, sizes, spacing, typography — resolved against the active semantic theme.

What changed

New layer: InstUI.Component

  • 65+ component token JSON files bundled as package resources (Resources/Tokens/Component/)
  • One generated Swift file per component (Sources/Component/Generated/) with a typed struct and dot-syntax accessors
  • InstUI.Theme.Components aggregates all components; accessible via InstUI.Theme.default.components
  • InstUI.Component.Resolver resolves component token references through the semantic layer

Accessor API

  • Component tokens: .iui.<component>.<token> (e.g. .iui.badge.borderRadius, .iui.checkbox.borderColor)
  • Semantic tokens renamed for consistency: .iuiSemantic, .iuiSemanticSize, .iuiSemanticSpacing, etc.
  • Primitive tokens: .iuiPrimitive, .iuiPrimitiveSize, .iuiPrimitiveOpacity, etc.

Resolver improvements

  • SizeResolver now handles em and px units in addition to rem
  • FontWeightResolver now accepts direct CSS numeric weights ("400", "700", etc.)
  • Token key whitespace is trimmed before lookup

Code generation

  • build-instui.js fetches component JSONs from the GitHub API at the pinned INSTUI_VERSION
  • New sd.config.component.js generates all component Swift files; the Generated/ directory is wiped and rebuilt on each run to stay in sync with upstream

Intended use

// Component layer — preferred for implementing a specific component
RoundedRectangle(cornerRadius: .iui.badge.borderRadius)
    .fill(.iui.badge.color)

PR Info

refs: MBL-19905
builds: Student, Teacher, Parent
affects: Student, Teacher, Parent
release note: none

Test Plan

  • Since there are lot of copied / generated files in this PR, I suggest to check out the branch to take a look at the structure, and try out the various helpers.
  • There's no storybook for this layer. I think it would have been too much code with small benefits. When we create each actual SwiftUI component in the future we will create storybook entries for those entities.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

PR Checks

Commit: Code quality improvements. (6c9b317)
Built At: Apr 21 14:46 UTC (04/21 08:46 AM MDT)

❌ PR Description
- 'release note:' field is empty

Add [ignore-pr-lint] to the PR description to skip these checks.

✅ Copyright Headers
✅ SwiftLint
✅ Build CITests
✅ Unit Tests
✅ Code Coverage

@bitrise
Copy link
Copy Markdown
Contributor

bitrise Bot commented Apr 21, 2026

Builds

Commit: Code quality improvements. (6c9b317)
Build Number: 1869
Built At: Apr 21 15:59 CEST (04/21 07:59 AM MDT)

Student
Teacher
Parent

Copy link
Copy Markdown
Contributor

@suhaibabsi-inst suhaibabsi-inst left a comment

Choose a reason for hiding this comment

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

Looks good to me.
And perhaps, we can think of something to limit downloading (and code generation) to only those components that are relevant to Mobile. Apparently, a lot of those are tailored to Web.

petkybenedek
petkybenedek previously approved these changes Apr 22, 2026
Base automatically changed from feature/MBL-19905-InstUI-semantic-colors to master April 22, 2026 11:53
@vargaat vargaat dismissed stale reviews from petkybenedek and suhaibabsi-inst April 22, 2026 11:53

The base branch was changed.

@vargaat vargaat marked this pull request as draft April 23, 2026 13:47
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.

3 participants