-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a dedicated page with an introduction to the `ui` module: <img width="1482" alt="Screenshot 2024-09-13 at 3 25 46 PM" src="https://github.com/user-attachments/assets/6c108b32-a91b-4007-acce-c3a0e2f967e0"> ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [ ] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
- Loading branch information
Showing
12 changed files
with
66 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
label: ui | ||
collapsible: true | ||
collapsed: true | ||
link: | ||
type: generated-index |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: "ui module" | ||
id: ui | ||
--- | ||
|
||
The `ui` module lets you create tools for interacting with resources in the Wing Console. | ||
|
||
Using components like `ui.Button`, `ui.Field`, or `ui.Table`, it's possible to trigger actions in Wing apps or display important information to the user. | ||
|
||
Here's an example of a class which has a button and field showing the internal state of the resource: | ||
|
||
```js playground example | ||
bring cloud; | ||
bring ui; | ||
|
||
class WidgetService { | ||
data: cloud.Bucket; | ||
counter: cloud.Counter; | ||
new() { | ||
this.data = new cloud.Bucket(); | ||
this.counter = new cloud.Counter(); | ||
|
||
// a button lets you invoke any inflight function | ||
new ui.Button("Add widget", inflight () => { this.addWidget(); }); | ||
|
||
// a field displays a labeled value | ||
new ui.Field( | ||
"Total widgets", | ||
inflight () => { return this.countWidgets(); }, | ||
refreshRate: 5s, | ||
); | ||
} | ||
|
||
inflight addWidget() { | ||
let id = this.counter.inc(); | ||
this.data.put("widget-{id}", "my data"); | ||
} | ||
|
||
inflight countWidgets(): str { | ||
return "{this.data.list().length}"; | ||
} | ||
} | ||
|
||
new WidgetService(); | ||
``` | ||
|
||
Here is what the UI looks like in the Wing Console: | ||
|
||
![](./widget-service-example.png) | ||
|
||
--- | ||
|
||
```mdx-code-block | ||
import DocCardList from '@theme/DocCardList'; | ||
<DocCardList /> | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
This file contains 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