feat(tss): add nesting and mixins support (Issue #1617)#1917
feat(tss): add nesting and mixins support (Issue #1617)#1917Anushreer22 wants to merge 3 commits into
Conversation
|
Hi @Anushreer22 👋 ⭐ Star this repo before your PR merges. Why? GSSoC 2026 contributors who star get priority review and points credit. After you star, push any commit (or re-run this check). The Thanks for your contribution to TermUI. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe tss engine now wraps ChangesMixin compilation and public exports
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant compileWithMixins
participant mixinRegistry
participant origCompile
Caller->>compileWithMixins: compile(styles)
compileWithMixins->>mixinRegistry: resolve mixins
mixinRegistry-->>compileWithMixins: resolved styles
compileWithMixins->>compileWithMixins: flatten styles
compileWithMixins->>origCompile: __origCompile(flattenedStyles)
origCompile-->>compileWithMixins: compiled rules
compileWithMixins-->>Caller: compiled rules
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🎉 Thanks for your first PR to TermUI, @Anushreer22.
Before your PR merges:
- ⭐ Star the repo. Required. The
star-checkjob blocks your merge otherwise. - ✅ All checks green:
build,test,typecheck. - 🏷 PR title follows
type: short description. Example:fix: handle empty list. - 🔗 Link your closing issue in the description.
GSSoC 2026 points come from labels after merge:
gssoc:approved. +50 base points.level:beginner/intermediate/advanced/critical. +20 / +35 / +55 / +80.quality:clean/exceptional. x 1.2 / x 1.5.type:*. Stackable bonus.
Your reviewer responds within 48 hours. Ping @Karanjot786 on Discord for urgent help.
🚀 Welcome to the cohort.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/tss/src/engine.ts`:
- Line 270: The compileWithMixins function currently uses unqualified any types
for styles and mixins, which violates the TypeScript guideline. Update the
compileWithMixins signature to use the parser’s stylesheet type (such as
TSSStylesheet) for styles and a proper mixin record type for mixins, and keep
the implementation aligned with those stronger types rather than relying on any.
In `@packages/tss/src/index.ts`:
- Line 60: The export in index.ts should use the ESM-compatible path with the
.js suffix. Update the re-export from the engine module so it points to
./engine.js instead of ./engine, keeping the existing exported symbols
defineMixin and mixinRegistry unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 529577ee-b68f-4982-b4fb-d874c9cf678b
📒 Files selected for processing (2)
packages/tss/src/engine.tspackages/tss/src/index.ts
| const __origCompile = (typeof compile !== 'undefined') ? compile : (module.exports?.compile); | ||
|
|
||
| // Our new compile | ||
| function compileWithMixins(styles: any, mixins: any = {}): any { |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
any used without inline justification comment.
Both styles: any and mixins: any = {} use any with no inline comment explaining why, violating the project's TypeScript guideline. Type these against the parser's stylesheet type (e.g. TSSStylesheet) and a mixin record type instead.
As per coding guidelines, "No any without an inline comment explaining why."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/tss/src/engine.ts` at line 270, The compileWithMixins function
currently uses unqualified any types for styles and mixins, which violates the
TypeScript guideline. Update the compileWithMixins signature to use the parser’s
stylesheet type (such as TSSStylesheet) for styles and a proper mixin record
type for mixins, and keep the implementation aligned with those stronger types
rather than relying on any.
Source: Coding guidelines
|
@Karanjot786 ✅ All feedback addressed – ready for merge! |
Closes #1617
Summary
Added SCSS-like nesting and mixin system to the TSS styling engine, allowing developers to write cleaner, more maintainable terminal stylesheets.
Changes
flattenStyles()– recursively expands nested selectors (supports&and child selectors)resolveMixins()– inlines predefined mixins referenced via@mixindefineMixin(name, obj)– API to register reusable style blockscompile()to preprocess styles before renderingdefineMixinandmixinRegistryfrompackages/tss/src/index.tsFiles Modified
packages/tss/src/engine.ts– added helper functions and wrappedcompilepackages/tss/src/index.ts– exports new APIsUsage Example