Overview
Review is a production-ready review resource included in the sunpeak framework. It provides a flexible confirmation dialog that adapts to various use cases including purchase reviews, code change approvals, social media post previews, booking confirmations, and generic action reviews.
The resource uses useWidgetProps() for configuration data and useWidgetState() to persist the user’s decision across sessions.
Data Structure
ReviewData
The resource expects data in the following format viauseWidgetProps():
Main title displayed in the header.
Optional description displayed below the title.
Content sections to display. See Section Types below.
Alert messages to display at the top of the content area.
Label for the accept/confirm button.
Label for the reject/cancel button.
Use danger styling for the accept button (for destructive actions).
Message shown after the user accepts.
Message shown after the user rejects.
Optional tool configuration to call when the user makes a decision.
Section Types
Sections support multiple display types for different content:Details Section
Key-value pairs for displaying structured information:Items Section
Items with optional images and metadata (for purchases, lists):Changes Section
Code or file change entries with type indicators:Preview Section
Simple text content display (content is a string).Summary Section
Compact key-value display, typically used for totals (uses Detail[] format).Alert Types
ReviewTool
Configure a tool call to execute when the user makes a decision:State Management
The resource usesuseWidgetState to persist the user’s decision:
Features
Flexible Content Sections
Supports five section types that can be combined:- Details: Key-value pairs with optional emphasis
- Items: Card-style list with images and badges
- Changes: Code-review style change indicators
- Preview: Text content preview
- Summary: Compact totals display
Alert Banners
Display contextual alerts with four severity levels:- Info: Blue styling for informational messages
- Warning: Yellow styling for cautions
- Error: Red styling for problems
- Success: Green styling for positive confirmations
Fullscreen Support
Includes a fullscreen toggle button usinguseDisplayMode() and useWidgetAPI() for expanded viewing of complex reviews.
Responsive Button Sizing
Detects touch capabilities usinguseUserAgent() and automatically adjusts button sizes for easier interaction on touch devices.
Safe Area Support
Respects device safe areas usinguseSafeArea() to ensure proper padding on devices with notches or rounded corners.
Height Constraints
UsesuseMaxHeight() to adapt to available screen space and prevent overflow.
Common Use Cases
- Purchase confirmations with item lists and totals
- Code change reviews with file diffs
- Social media post previews before publishing
- Booking confirmations with date and price details
- Generic approve/reject workflows
- Destructive action confirmations (with danger styling)