# Examples

On this page, you will find example widgets that are created as you follow the chapters. You can download the widgets and then import them into your own library to take a look. You can even use and modify them to your liking if you wish.

Please note that the widgets created in the widget chapters are being updated to comply with CSP (Content Security Policy) standards. They are also being modified to prevent any collisions in the global scope.

## Basics

Below are the widgets that you will create as you follow the basics module.

### Hello, You!

A simple widget that demonstrates the use of the text property, HTML-encoded to output a name.

{% file src="<https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FC5KuSFohVe9aZD9Y2wqO%2FHello%2C%20You!.zip?alt=media&token=39b73790-c74f-43b4-b298-4a636ccf111c>" %}

### Six-Sided Die

A widget that simulates a six-sided die. To ensure that this widget is CSP (Content Security Policy) compliant, it utilizes the `startupscript` to add a click listener to the "Roll Again" button, which refreshes the page.

{% file src="<https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F5MRihP0zyp5abvBZ5yYa%2FSix-Sided%20Die.zip?alt=media&token=8ffeec61-0f5d-4a69-9181-090fe74f466a>" %}

### Message - Example 1

This widget is similar to the Alert component in Bootstrap. You can expand or collapse the message by clicking on it, demonstrating how the WEM view state fields functions.

{% file src="<https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FNPtmVLEv5IWT0lhJcIEP%2FMessage%20-%20Example%201.zip?alt=media&token=04b453cc-c837-43d0-8678-87cdf931c8ad>" %}

### Message - Example 2

This widget functions similarly to Example 1, but it utilizes the WEM `Runtime.viewState` JavaScript API instead.

{% file src="<https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FJ9wzHlq5sbWuxDNx2RZm%2FMessage%20-%20Example%202.zip?alt=media&token=274321f3-4936-4941-85e8-0c3fae411a74>" %}

### Message - Example 3

This message widget uses `sessionStorage` to store the view state and employs an ES module that utilizes Shadow DOM to prevent global scope collisions.

{% file src="<https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F0qBzYA8nvWqqLtPJpTnA%2FMessage%20-%20Example%203.zip?alt=media&token=4ad68894-20b9-4ea8-83d8-650a823b2c8a>" %}

### Tickle

This widget demonstrates how to use the `import()` function to dynamically load script modules, preventing collisions in the *global scope*. It also utilizes the Shadow DOM to style the widget, further avoiding CSS conflicts.

{% file src="<https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F6NFzeC2IYmCcTcohrl0s%2FTickle.zip?alt=media&token=f9aa91ce-0066-4c7b-aec3-0d3f7d380289>" %}

### Information Card

This widget demonstrates how easy it is to implement placeholders and highlights their powerful capabilities. It also provides an example of how to create a Template Editor Script.

{% file src="<https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F9A1xvEJ0MtNZGoO6aSTz%2FInformation%20Card.zip?alt=media&token=d24a03a9-6a1b-4854-a0de-db14c6b81577>" %}

## Other Examples

More coming soon.
