-
Notifications
You must be signed in to change notification settings - Fork 1
Add examples sidebar to playground #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Sander-Toonen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an Example with the following expression:
map(f(row) = {_id: row.rowId} + flatten(row.data, ''), $event)
And the following context:
{
"$event":[
{"rowId": 1, "state": "saved", "data": { "InventoryId": 1256, "Description": "Bal", "Weight": { "Unit": "g", "Amount": 120 } }},
{"rowId": 2, "state": "new", "data": { "InventoryId": 2344, "Description": "Basket", "Weight": { "Unit": "g", "Amount": 300 } }},
{"rowId": 3, "state": "unchanged", "data": { "InventoryId": 9362, "Description": "Wood", "Weight": { "Unit": "kg", "Amount": 18 } }}
]
}
Also add a way to preselect an example with a query parameter
Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Added in 36913fe:
Available example IDs: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds an interactive examples sidebar to the playground that allows users to quickly load pre-configured expression and context examples. Users can select examples by clicking sidebar items or by using URL query parameters (e.g., ?example=math).
Changes:
- Added sidebar with 6 example cases covering mathematical operations, arrays, objects, functional programming, and data transformation
- Refactored syntax highlighting to use a cleaner array-based approach with
deltaDecorations - Updated server to handle URLs with query parameters
- Added CSS styling for sidebar with light/dark theme support
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/functions/string/operations.ts | Removed trailing whitespace |
| samples/language-service-sample/styles.css | Added CSS for sidebar layout, theming, and token highlighting for constants |
| samples/language-service-sample/serve-sample.cjs | Added query string stripping to support URL-based example selection |
| samples/language-service-sample/index.html | Added sidebar HTML structure and adjusted leftPane width calculation |
| samples/language-service-sample/app.js | Added example data, sidebar rendering, example loading logic, URL query parameter support, and refactored syntax highlighting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| threshold: 3 | ||
| } |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'threshold' variable in the context is not used in the expression. The expression hardcodes the value '3' in the filter predicate. Consider either removing 'threshold' or updating the expression to use it, such as 'sum(map(filter(items, item => item > threshold), x => x * 2))'.
| <!-- Main Content --> | ||
| <main id="mainContent"> | ||
| <!-- Examples Sidebar --> | ||
| <aside id="examplesSidebar" class="w-64 bg-gray-50 dark:bg-[#252526] border-r border-gray-200 dark:border-[#3c3c3c] flex-shrink-0 flex flex-col"> |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sidebar width is specified in two places: the Tailwind class 'w-64' (which equals 256px/16rem) in the HTML and 'width: var(--sidebar-width)' in the CSS. While both currently resolve to 256px, having two sources of truth can lead to inconsistencies if one is changed. Consider removing the 'w-64' class and relying solely on the CSS variable for width control.
|
|
||
| <!-- Expression Editor Pane --> | ||
| <div id="leftPane" class="pane bg-white dark:bg-[#1e1e1e]" style="width: 60%;"> | ||
| <div id="leftPane" class="pane bg-white dark:bg-[#1e1e1e]" style="width: calc(60% - var(--sidebar-width));"> |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The leftPane width calculation is incorrect. Using "calc(60% - var(--sidebar-width))" treats percentages as relative to the parent container width. If the container is 1000px wide and --sidebar-width is 256px, this would calculate to 600px - 256px = 344px, but the sidebar already takes up 256px, leaving only 744px for both panes and the resizer. The correct calculation should subtract the sidebar width proportionally or use a different approach, such as "calc((100% - var(--sidebar-width)) * 0.6)" to get 60% of the remaining space after the sidebar.
| <div id="leftPane" class="pane bg-white dark:bg-[#1e1e1e]" style="width: calc(60% - var(--sidebar-width));"> | |
| <div id="leftPane" class="pane bg-white dark:bg-[#1e1e1e]" style="width: calc((100% - var(--sidebar-width)) * 0.6);"> |
| numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | ||
| values: [15, 25, 35] |
Copilot
AI
Jan 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'values' array in the context is not used in the expression. The expression only references 'numbers'. Consider removing 'values' from the context or updating the expression to demonstrate its usage.
| numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], | |
| values: [15, 25, 35] | |
| numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] |
Extends the playground with a collapsible sidebar showing clickable example cases. Selecting an example populates both the expression and context editors. Examples can also be preselected via URL query parameter.
Examples included
sqrt()sum(),min(),max()operationsflatten()functionChanges
index.html: Added<aside>sidebar before editor panesapp.js: AddedexampleCasesdata,renderExamplesSidebar(),loadExample()click handler, and URL query parameter support vialoadExampleFromUrl()styles.css: Added sidebar styles with CSS variable--sidebar-widthfor consistent layout, light/dark theme supportserve-sample.cjs: Updated server to handle URLs with query stringsUsage
URL Query Parameter
Preselect an example by appending
?example=<id>to the URL:?example=math— Mathematical Expression?example=arrays— Working with Arrays?example=objects— Object Manipulation?example=map-filter— Map and Filter Functions?example=complex— Complex Objects?example=data-transform— Data TransformationOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.