Skip to content

Conversation

@Chidwan3578
Copy link

@Chidwan3578 Chidwan3578 commented Jan 13, 2026

Summary
Created documentation for conditional rendering in Stac. Created Documentation File
Location: docs/concepts/conditional_rendering.mdx
Content: Covers:
What conditional rendering is — overview of the conditional widget and its purpose Supported conditions and operators — tables for:
Comparison operators (==, !=, >, <, >=, <=)
Logical operators (&&, ||)
Mathematical operations (+, -, *, /, %)
Supported values (numbers, booleans, strings, null) How conditions are evaluated at runtime — explanation of the ExpressionResolver evaluation process Usage examples — including:
Basic boolean comparisons
String comparisons
Mathematical expressions
Logical operators
Nested conditionals
Real-world examples (authentication, feature flags) Updated Navigation
Added the new documentation page to docs/docs.json in the Concepts section The documentation includes:
Overview and explanation of how conditional rendering works Complete operator reference with examples
Multiple usage examples from simple to advanced
JSON schema reference
Best practices and limitations
Error handling information
The documentation is ready and integrated into the Stac documentation site. Users can find it in the Concepts section alongside other core concepts like theming, caching, and custom widgets.

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive Conditional Rendering guide covering expression evaluation, supported operators, value types, usage examples (basic to advanced), best practices, limitations, and error-handling behavior.
    • Added a Concepts navigation entry linking to the new conditional rendering guide.
    • Updated the package README with a Stac DSL/Dart example and a link to the new documentation.

✏️ Tip: You can customize this high-level summary in your review settings.

Summary
Created documentation for conditional rendering in Stac.
Created Documentation File
Location: docs/concepts/conditional_rendering.mdx
Content: Covers:
What conditional rendering is — overview of the conditional widget and its purpose
Supported conditions and operators — tables for:
Comparison operators (==, !=, >, <, >=, <=)
Logical operators (&&, ||)
Mathematical operations (+, -, *, /, %)
Supported values (numbers, booleans, strings, null)
How conditions are evaluated at runtime — explanation of the ExpressionResolver evaluation process
Usage examples — including:
Basic boolean comparisons
String comparisons
Mathematical expressions
Logical operators
Nested conditionals
Real-world examples (authentication, feature flags)
Updated Navigation
Added the new documentation page to docs/docs.json in the Concepts section
The documentation includes:
Overview and explanation of how conditional rendering works
Complete operator reference with examples
Multiple usage examples from simple to advanced
JSON schema reference
Best practices and limitations
Error handling information
The documentation is ready and integrated into the Stac documentation site. Users can find it in the Concepts section alongside other core concepts like theming, caching, and custom widgets.
@CLAassistant
Copy link

CLAassistant commented Jan 13, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

Adds new documentation for Stac's conditional rendering feature, updates docs navigation to include the new page, and extends the Stac package README with a DSL/Dart example. No code or runtime behavior changes.

Changes

Cohort / File(s) Summary
Conditional Rendering Documentation
docs/concepts/conditional_rendering.mdx
New comprehensive document describing the conditional widget, ExpressionResolver boolean evaluation, ifTrue/ifFalse rendering flow, supported operators and value types, expression features (parentheses, nesting, nulls), examples (JSON & Dart DSL), JSON schema, best practices, limitations, and error handling behavior.
Documentation Navigation
docs/docs.json
Added "concepts/conditional_rendering" entry under Overview → Concepts to surface the new doc in site navigation.
Stac README Example
packages/stac/README.md
Added "Stac DSL/Dart Example" subsection with a runnable Dart snippet demonstrating a conditional widget and a link to the new documentation.

Sequence Diagram(s)

(omitted — changes are documentation-only and do not modify runtime control flow)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Suggested reviewers

  • rahulbisht25

Poem

🐰
I hopped through specs with ears alert,
ifTrue and ifFalse in tidy spurt,
Expressions nested, logic bright,
Docs now guide the UI's light,
A carrot for clarity — hop, delight! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Added documentation for conditional rendering in Stac' directly and accurately describes the main change—adding comprehensive documentation for the conditional rendering feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.



📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7787a88 and c67c871.

📒 Files selected for processing (1)
  • docs/docs.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/docs.json

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @docs/concepts/conditional_rendering.mdx:
- Around line 308-312: The "Limitations" section currently claims conditions
cannot access app state, which contradicts the examples using user.isLoggedIn ==
true and featureFlags.newUI == true; update the Limitations paragraph to clarify
that condition expressions can reference variables from the evaluation context
(e.g., user.isLoggedIn, featureFlags.newUI) and describe the
substitution/evaluation behavior (what scope is available and any restrictions),
or alternatively change the examples to show explicit variable substitution
before evaluation — ensure you mention the example patterns user.isLoggedIn ==
true and featureFlags.newUI == true so readers see the clarified behavior.
- Line 99: Update the example so the "condition" property uses quoted string
operands consistent with the documented format: inside the condition string wrap
each string operand in quotes (double or single) rather than leaving them
unquoted, so the expression follows the documented `"hello"`/`'world'` style;
change the example value assigned to the "condition" key accordingly and keep
the surrounding JSON string syntax intact.
🧹 Nitpick comments (1)
docs/concepts/conditional_rendering.mdx (1)

311-311: Clarify "built-in math functions" statement.

The parenthetical "(except built-in math functions)" is vague. If there are built-in functions available, they should be documented in the "Supported Conditions and Operators" section. If there are none, consider removing this exception clause.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df4a034 and 830ca54.

📒 Files selected for processing (2)
  • docs/concepts/conditional_rendering.mdx
  • docs/docs.json
🧰 Additional context used
🪛 LanguageTool
docs/concepts/conditional_rendering.mdx

[style] ~298-~298: To elevate your writing, try using a synonym here.
Context: ...ns simple**: Complex expressions can be hard to debug. Consider breaking them into n...

(HARD_TO)

🔇 Additional comments (2)
docs/concepts/conditional_rendering.mdx (1)

1-328: Overall documentation is comprehensive and well-structured.

The documentation covers the essential aspects of conditional rendering including operators, usage examples, JSON schema, best practices, and error handling. The examples progress logically from basic to advanced usage.

docs/docs.json (1)

41-41: Navigation entry correctly added.

The new page entry aligns with the documentation file path and is logically placed in the Concepts group after the rendering widgets concept.

@divyanshub024
Copy link
Member

Hey @Chidwan3578!! Thank you for the quick contribution 🎉
Can you please sign the CLA?

@Chidwan3578
Copy link
Author

Done ;)

Copy link
Member

@divyanshub024 divyanshub024 left a comment

Choose a reason for hiding this comment

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

Hey @Chidwan3578!!

Thank you for this amazing PR. Can you please check my suggestions.

Also, can you please update the PR title and a proper description.

Comment on lines +79 to +91
```json
{
"type": "conditional",
"condition": "5 > 3",
"ifTrue": {
"type": "text",
"data": "5 is greater than 3"
},
"ifFalse": {
"type": "text",
"data": "5 is not greater than 3"
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you also add the Stac DSL/Dart example as well. Since it's the recommended way for Stac.

Copy link
Author

Choose a reason for hiding this comment

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

added an example for DSL/Dart.

Copy link
Member

Choose a reason for hiding this comment

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

Can we add the Dart example for all JSONs?

},
"body": {
"type": "conditional",
"condition": "user.isLoggedIn == true",
Copy link
Member

Choose a reason for hiding this comment

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

The variables in stac are used like this {{user.isLoggedIn}}


## Limitations

- **No variable access**: Currently, conditions cannot access app state or variables directly. They evaluate static expressions only.
Copy link
Member

Choose a reason for hiding this comment

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

This is not fully true. It can access variables from the network request.

Copy link
Author

Choose a reason for hiding this comment

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

Updated the documentation to clarify that conditions can access variables from resolved data sources (e.g. network responses), while still not supporting local widget state or arbitrary Dart variables.


- **No variable access**: Currently, conditions cannot access app state or variables directly. They evaluate static expressions only.
- **No function calls**: Custom functions cannot be called within conditions (except built-in math functions).
- **String operations**: String concatenation is supported, but other string operations are limited.
Copy link
Member

Choose a reason for hiding this comment

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

Can you please eleborate on this?

Copy link
Author

Choose a reason for hiding this comment

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

Added more detailed explanations for each limitation to clarify what is and isn’t supported in conditional expressions.

Changed according to requests
@Chidwan3578 Chidwan3578 changed the title Added documentation for Added documentation for conditional rendering in Stac Jan 15, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/stac/README.md`:
- Around line 40-62: Move the entire "Stac DSL/Dart Example" section (the
heading "## Stac DSL/Dart Example" and its Dart code block plus the "For more
details..." line) out of the middle of the Features list and place it after the
existing feature bullets (i.e., after the block that continues on line ~66) so
all feature bullets remain contiguous under "Features" and the example becomes
its own standalone section; update surrounding spacing so the Features list is
uninterrupted and the relocated section has a blank line before and after.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 830ca54 and 7787a88.

📒 Files selected for processing (2)
  • docs/concepts/conditional_rendering.mdx
  • packages/stac/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/concepts/conditional_rendering.mdx

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment on lines +40 to +62

## Stac DSL/Dart Example

The Stac DSL allows you to define widgets directly in Dart, which is then compiled to JSON. Here's a simple example:

```dart
import 'package:stac/stac.dart';
@StacWidget()
class MyButton extends StatelessWidget {
const MyButton({super.key});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {},
child: const Text('Click me'),
);
}
}
```

For more details, see the [documentation](https://docs.stac.dev/).
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Relocate section to fix document structure.

The "Stac DSL/Dart Example" section is inserted in the middle of the Features list, breaking the document's logical flow. Lines 37-39 contain feature bullets, this section interrupts them, and lines 63-66 continue with more feature bullets.

📝 Suggested relocation

Move this entire section (lines 40-62) to appear after line 66, so all feature bullets remain together under the Features heading:

 ## Features
 
 - 🚀 Instant updates: Ship UI without app store releases.
 - 🧩 JSON‑driven UI: Define widgets in JSON; render natively.
 - 📦 Dart to JSON: Write Stac widgets in Dart and deploy to Stac Cloud.
-
-## Stac DSL/Dart Example
-
-The Stac DSL allows you to define widgets directly in Dart, which is then compiled to JSON. Here's a simple example:
-
-```dart
-import 'package:stac/stac.dart';
-
-@StacWidget()
-class MyButton extends StatelessWidget {
-  const MyButton({super.key});
-
-  `@override`
-  Widget build(BuildContext context) {
-    return ElevatedButton(
-      onPressed: () {},
-      child: const Text('Click me'),
-    );
-  }
-}
-```
-
-For more details, see the [documentation](https://docs.stac.dev/).
 - 🎛 Actions & navigation: Control routes and API calls from the backend.
 - 📝 Forms & validation: Built-in form state and validation rules.
 - 🎨 Theming: Brand and layout via JSON with Stac Theme.
 - 🔌 Extensible: Add custom widgets, actions, and native integrations.
+
+## Stac DSL/Dart Example
+
+The Stac DSL allows you to define widgets directly in Dart, which is then compiled to JSON. Here's a simple example:
+
+```dart
+import 'package:stac/stac.dart';
+
+@StacWidget()
+class MyButton extends StatelessWidget {
+  const MyButton({super.key});
+
+  `@override`
+  Widget build(BuildContext context) {
+    return ElevatedButton(
+      onPressed: () {},
+      child: const Text('Click me'),
+    );
+  }
+}
+```
+
+For more details, see the [documentation](https://docs.stac.dev/).
🤖 Prompt for AI Agents
In `@packages/stac/README.md` around lines 40 - 62, Move the entire "Stac DSL/Dart
Example" section (the heading "## Stac DSL/Dart Example" and its Dart code block
plus the "For more details..." line) out of the middle of the Features list and
place it after the existing feature bullets (i.e., after the block that
continues on line ~66) so all feature bullets remain contiguous under "Features"
and the example becomes its own standalone section; update surrounding spacing
so the Features list is uninterrupted and the relocated section has a blank line
before and after.

Comment on lines +40 to +62

## Stac DSL/Dart Example

The Stac DSL allows you to define widgets directly in Dart, which is then compiled to JSON. Here's a simple example:

```dart
import 'package:stac/stac.dart';
@StacWidget()
class MyButton extends StatelessWidget {
const MyButton({super.key});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {},
child: const Text('Click me'),
);
}
}
```

For more details, see the [documentation](https://docs.stac.dev/).
Copy link
Member

Choose a reason for hiding this comment

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

Hey, this change is not required.

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