Add stencilBoolean function to SCSS compiler#156
Open
34638a wants to merge 6 commits into
Open
Conversation
Functional as a number returned 1 for truthy 0 for falsy. This is a RFC proposal and not a fully complete Pull Request to begin the conversation about adding this function into the SASS system.
This is an RFC proposal and a fully complete Pull Request to begin the conversation about adding this function into the SASS system.
# Conflicts: # lib/ScssCompiler.js
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1f01fcf. Configure here.
…nge was not intended.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

#RFC Proposal: Support for Stencil Boolean values in SASS.
What/Why?
Current state of stencil helpers does not support the processing of
trueorfalsevalues fromconfig.json. These boolean states are configurable via UI and therefore should be importable into SCSS if required, not just into Handlebars.Rollout/Rollback
Unknown as this is a outside contribution, in theory it would be to merge and bump all required packages to the new version downstream.
Testing
Tests are included, cloned from structure for
stencilNumber(...)and contents replaced to reflect testing for truthiness.Documentation:
The following values are considered
truefor the purposes of usage ofstencilBoolean(...)as per the Javascript Truthy:Any value not in the list above is considered
falsewhen injected into SASS. Once this state has been transferred fromconfig.jsonto SASS, the way that SASS handles Booleans applies.See Mozilla Truthy Glossary documentation for more information on Javascript Truthy: https://developer.mozilla.org/en-US/docs/Glossary/Truthy
See SASS documentation on Boolean values: https://sass-lang.com/documentation/values/booleans/
Implementation Warning:
CSS does not have a value representation of
trueandfalseand therefore cannot be directly translated from SCSS to CSS. One way to handle this is to use numeric1for true and numeric0for false, but implementation like this is up to the developer. What follows is a function that can be used in SCSS to perform a cast from SASS truthy to1else0.Note
Low Risk
Additive SCSS helper following existing stencil* patterns; no auth or data-path changes, with unit tests covering lookup and coercion behavior.
Overview
Adds
stencilBoolean($name)to the SCSS compiler’s theme-setting helpers so boolean (and other truthy/falsy) values fromconfig.jsoncan drive Sass@ifand similar logic, alongside existing helpers likestencilNumber.The function resolves the setting key (including nested paths via
_.get), applies JavaScript truthy coercion withBoolean(...), and returnsSass.types.Boolean.TRUEorFALSE. Missing or invalid keys evaluate to false.Tests mirror the
stencilNumbersuite (flat/nested keys, bad key, Sass type). Fixture settings and a samplecastSASSBooleanForCSS1And0SCSS helper document mapping booleans to1/0for CSS output.Reviewed by Cursor Bugbot for commit 2cf456c. Bugbot is set up for automated code reviews on this repo. Configure here.