Skip to content

Commit

Permalink
clean up examples and fix instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Acepie committed Apr 20, 2024
1 parent 40edb86 commit b8791ed
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
6 changes: 3 additions & 3 deletions examples/ball_spawner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

Simple example of using the library to create a ball spawner. Balls are spawned on click at the clicked location with a random direction and color.

### Bundling the app
## Bundling the app

This example uses [esgleam](https://hexdocs.pm/esgleam/) to bundle the main gleam module for use in a static site.

To install esbuild run the following command. You should only need to run it once.

```bash
gleam run -m esgleam/bundle
gleam run -m esgleam/install
```

To bundle the app run the following command after making code changes.
Expand All @@ -18,7 +18,7 @@ To bundle the app run the following command after making code changes.
gleam run -m esgleam/bundle
```

### Serving the app
## Serving the app

You can use any static site server to host the app but for development you can continue to use esgleam by running

Expand Down
6 changes: 3 additions & 3 deletions examples/ball_spawner/src/ball_spawner.gleam
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import p5js_gleam.{type P5, SketchConfig}
import p5js_gleam/bindings as p5
import gleam/option
import gleam/float
import gleam/io
import gleam/list
import gleam/option
import p5js_gleam.{type P5, SketchConfig}
import p5js_gleam/bindings as p5

type Vector {
Vector(x: Float, y: Float)
Expand Down
32 changes: 17 additions & 15 deletions examples/minimal/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# minimal

[![Package Version](https://img.shields.io/hexpm/v/minimal)](https://hex.pm/packages/minimal)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/minimal/)
Bare minimum example rendering a hello message to the screen.

```sh
gleam add minimal
## Bundling the app

This example uses [esgleam](https://hexdocs.pm/esgleam/) to bundle the main gleam module for use in a static site.

To install esbuild run the following command. You should only need to run it once.

```bash
gleam run -m esgleam/install
```
```gleam
import minimal

pub fn main() {
// TODO: An example of the project in use
}
To bundle the app run the following command after making code changes.

```bash
gleam run -m esgleam/bundle
```

Further documentation can be found at <https://hexdocs.pm/minimal>.
## Serving the app

## Development
You can use any static site server to host the app but for development you can continue to use esgleam by running

```sh
gleam run # Run the project
gleam test # Run the tests
gleam shell # Run an Erlang shell
```bash
gleam run -m esgleam/serve
```
2 changes: 1 addition & 1 deletion examples/minimal/src/minimal.gleam
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import gleam/option
import p5js_gleam.{type P5, SketchConfig}
import p5js_gleam/bindings as p5
import gleam/option

fn setup(p: P5) -> String {
p5.create_canvas(p, 800.0, 600.0)
Expand Down

0 comments on commit b8791ed

Please sign in to comment.