Skip to content

Commit 3fa2866

Browse files
MartinKavikDavid-OConnor
authored andcommitted
docs: industrial Seed logo
1 parent 30ca541 commit 3fa2866

File tree

3 files changed

+83
-53
lines changed

3 files changed

+83
-53
lines changed

README.md

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
[![docs.rs](https://docs.rs/seed/badge.svg)](https://docs.rs/seed)
55
[![Built with cargo-make](https://sagiegurari.github.io/cargo-make/assets/badges/cargo-make.svg)](https://sagiegurari.github.io/cargo-make)
66

7+
<p align="center">
8+
<img src="/seed_branding/seed_logo.svg" width="256" title="Seed logo">
9+
</p>
10+
711
# Quickstart
812

913
## Setup
14+
1015
This framework requires you to install [Rust](https://www.rust-lang.org/tools/install).
1116

1217
You'll need a recent version of Rust: `rustup update`
@@ -15,43 +20,43 @@ The wasm32-unknown-unknown target: `rustup target add wasm32-unknown-unknown`
1520

1621
And cargo-make: `cargo install --force cargo-make`
1722

18-
1923
## The theoretical minimum
20-
To start, clone [the quickstart repo](https://github.com/David-OConnor/seed-quickstart):
24+
25+
To start, clone [the quickstart repo](https://github.com/David-OConnor/seed-quickstart):
2126
`git clone https://github.com/david-oconnor/seed-quickstart.git`,
2227
run `cargo make all` in a terminal to build the app, and `cargo make serve` to start a dev server
2328
on `127.0.0.0:8000`.
2429

25-
2630
## A little deeper
27-
Alternatively, create a new lib with Cargo: `cargo new --lib appname`. Here and everywhere it appears in this guide, `
28-
appname` should be replaced with the name of your app.
31+
32+
Alternatively, create a new lib with Cargo: `cargo new --lib appname`. Here and everywhere it appears in this guide, `appname` should be replaced with the name of your app.
2933

3034
If not using the quickstart repo, create an Html file with a body that contains this:
35+
3136
```html
3237
<section id="app"></section>
3338

34-
<script src='/pkg/package.js'></script>
39+
<script src="/pkg/package.js"></script>
3540

3641
<script>
37-
const { render } = wasm_bindgen;
38-
function run() {
39-
render();
40-
}
41-
wasm_bindgen('/pkg/package_bg.wasm')
42-
.then(run)
43-
.catch(console.error);
42+
const { render } = wasm_bindgen;
43+
function run() {
44+
render();
45+
}
46+
wasm_bindgen("/pkg/package_bg.wasm")
47+
.then(run)
48+
.catch(console.error);
4449
</script>
4550
```
51+
4652
The first line above is an empty element with id: It's where your app will render.
4753
The subsequent ones load your app's wasm modules.
4854

49-
The quickstart repo includes this file. You will eventually need to modify it to
55+
The quickstart repo includes this file. You will eventually need to modify it to
5056
change the page's title, add a description, favicon, stylesheet etc.
5157

52-
`Cargo.toml`, which is a file created by Cargo that describes your app, needs `wasm-bindgen`, `web-sys`, and `
53-
seed` as depdendencies,
54-
and crate-type
58+
`Cargo.toml`, which is a file created by Cargo that describes your app, needs `wasm-bindgen`, `web-sys`, and `seed` as depdendencies,
59+
and crate-type
5560
of `"cdylib"`. The version in the quickstart repo has these set up already. Example:
5661

5762
```toml
@@ -71,12 +76,14 @@ web-sys = "^0.3.6"
7176
```
7277

7378
## A short example
79+
7480
Here's an example demonstrating structure and syntax; it can be found in working form
75-
in the [counter example](https://github.com/David-OConnor/seed/tree/master/examples/counter)
81+
in the [counter example](https://github.com/David-OConnor/seed/tree/master/examples/counter)
7682
Descriptions of its parts are in the
7783
Guide section below. Its structure follows [The Elm Architecture](https://guide.elm-lang.org/architecture/).
7884

79-
*lib.rs*:
85+
_lib.rs_:
86+
8087
```rust
8188
#[macro_use]
8289
extern crate seed;
@@ -177,16 +184,19 @@ pub fn render() {
177184
.run();
178185
}
179186
```
187+
180188
For a truly minimimal example, see [lib.rs in the quickstart repo](https://github.com/David-OConnor/seed-quickstart/blob/master/src/lib.rs)
181189

182190
## Building and running
191+
183192
To build your app run `cargo make all`, and to host on a dev server, run `cargo make serve`.
184193

185194
For a more robust starting setup, check out Martin Kavik's [seed-quickstart-webpack repo](https://github.com/MartinKavik/seed-quickstart-webpack).
186195

187196
## Running included examples
197+
188198
To run an example located in the [examples folder](https://github.com/David-OConnor/seed/tree/master/examples),
189-
run `cargo make start example_name`, where you replace `example_name` with the example name. Eg:
199+
run `cargo make start example_name`, where you replace `example_name` with the example name. Eg:
190200
`cargo make start counter`.
191201

192202
Some examples also require to run API server in another terminal window - `cargo make start_server example_name`.
@@ -195,63 +205,62 @@ When server(s) are running, open [127.0.0.1:8000](http://127.0.0.1:8000) in your
195205

196206
# About
197207

198-
199208
## Goals
209+
200210
- Learning the syntax, creating a project, and building it should be easy - regardless
201-
of your familiarity with Rust.
211+
of your familiarity with Rust.
202212

203213
- Complete documentation that always matches the current version. Getting examples working, and
204-
starting a project should be painless, and require nothing beyond this guide.
205-
206-
- Expressive, flexible view syntax that's easy to read and write.
214+
starting a project should be painless, and require nothing beyond this guide.
207215

216+
- Expressive, flexible view syntax that's easy to read and write.
208217

209218
## A note on view syntax
219+
210220
This project uses an unconventional approach to describe how to display DOM elements.
211221
It neither uses completely natural (ie macro-free) Rust code, nor
212-
an HTML-like abstraction (eg JSX or templates). My intent is to make the code close
213-
to natural Rust, while streamlining the syntax in a way suited for creating
222+
an HTML-like abstraction (eg JSX or templates). My intent is to make the code close
223+
to natural Rust, while streamlining the syntax in a way suited for creating
214224
a visual layout with minimal repetition. The macros used are thin wrappers
215225
for constructors, and don't conceal much. Specifically, the element-creation macros
216-
allow for accepting a variable number of parameters, and the attrs/style marcros are
226+
allow for accepting a variable number of parameters, and the attrs/style marcros are
217227
essentially HashMap literals, with wrappers that let element macros know how to distinguish
218228
them.
219229

220230
The lack of resemblance to HTML be offputting, but the learning
221-
curve is shallow, and I think the macro syntax is close-enough to normal Rust that it's
231+
curve is shallow, and I think the macro syntax is close-enough to normal Rust that it's
222232
easy to reason about how to build views, without compartmentalizing it into logic code and display code.
223-
This lack of separation in particular is a controversial decision, but I think the benefits
233+
This lack of separation in particular is a controversial decision, but I think the benefits
224234
are worth it.
225235

226-
227236
## Where to start if you're familiar with existing frontend frameworks
237+
228238
The [todomvc example](https://github.com/David-OConnor/seed/tree/master/examples/todomvc) is an implementation of the [TodoMVC project](http://todomvc.com/),
229239
which has example code in other frameworks that produce identitcal apps. Compare the example in this
230240
project to one on that page that uses a framework you're familiar with.
231241

232-
233242
## Influences
243+
234244
This project is strongly influenced by Elm, React, and Redux. The overall structure
235245
of Seed apps mimicks that of The Elm Architecture.
236246

237-
238247
## There are already several Rust/WASM frameworks; why add another?
239248

240-
I'm distinguishing Seed through clear examples and documentation, and using `wasm-bindgen`/`web-sys` internally. I started this
249+
I'm distinguishing Seed through clear examples and documentation, and using `wasm-bindgen`/`web-sys` internally. I started this
241250
project after being unable to get existing frameworks working
242-
due to lack of documented examples, and inconsistency between documentation and
251+
due to lack of documented examples, and inconsistency between documentation and
243252
published versions. My intent is for anyone who's proficient in a frontend
244-
framework to get a standalone app working in the browser within a few minutes, using just the
253+
framework to get a standalone app working in the browser within a few minutes, using just the
245254
quickstart guide.
246255

247-
Seed's different approach to view syntax also distinguishes it:
248-
rather than use an HTML-like markup similar to JSX,
256+
Seed's different approach to view syntax also distinguishes it:
257+
rather than use an HTML-like markup similar to JSX,
249258
it uses Rust builtin types, thinly-wrapped by macros that allow flexible composition.
250259
This decision will not appeal to everyone, but I think it integrates more naturally with
251260
the language.
252261

253-
254262
## Why build a frontend in Rust over Elm, or Javascript-based frameworks?
263+
255264
You may prefer writing in Rust, and using packages from Cargo vice npm. Getting started with
256265
this framework will in most cases be easier, and require less config and setup overhead than
257266
with JS frameworks. You may appreciate Rust's compile-time error-checking, and built-in testing.
@@ -265,48 +274,47 @@ no distinction between components and normal functions. The API is
265274
flexible, and avoids OOP boilerplate. Its integrated routing and message system
266275
avoids the dependency glue-code associated with Redux and React-Router.
267276

268-
Seed has a *batteries-included* approach, which you may appreciate.
269-
277+
Seed has a _batteries-included_ approach, which you may appreciate.
270278

271279
## Why not to use this, and stick with JS
280+
272281
Seed's under rapid development, and breaking changes are likely. Finding Rust/WASM-help,
273282
both in person, and in online communities will be difficult, and finding help for Seed
274-
even more so. Seed doesn't have the wealth of existing reusable *components* that other frameworks
283+
even more so. Seed doesn't have the wealth of existing reusable _components_ that other frameworks
275284
have, so you will need to implement solved problems (eg date-pickers) yourself, or adapt them
276285
from existing solutions. There are no existing tutorials or guides outside the official one, and
277286
few examples.
278287

279288
Seed doesn't have a track-record of production apps. Finding developers experienced with Rust/wasm-bindgen,
280289
or Seed specifically will be much more difficult than popular JS/compile-to-JS frameworks. Seed's feature-set
281-
is incomplete compared to JS frameworks. Seed hasn't been benchmarked, and its performance may
290+
is incomplete compared to JS frameworks. Seed hasn't been benchmarked, and its performance may
282291
be lower than JS frameworks.
283292

284293
Seed's view syntax is non-standard compared to HTML-templates, or HTML-mockup languages like
285294
`JSX`.
286295

287-
288296
## What about Gloo ?
289-
We're working closely with the `rustwasm` team on [Gloo](https://github.com/rustwasm/gloo), and
297+
298+
We're working closely with the `rustwasm` team on [Gloo](https://github.com/rustwasm/gloo), and
290299
intend to incorporate `Gloo` crates into Seed as appropriate, as well as contribute Seed
291300
code into `Gloo` crates. Seed's a cohesive, high-level framework, while `Gloo` will
292301
be a versatile, standardized toolkit.
293302

294-
295-
296303
### Shoutouts
304+
297305
- The [WASM-Bindgen](https://github.com/rustwasm/wasm-bindgen) team,
298-
for building the tools this project relies on
306+
for building the tools this project relies on
299307
- Alex Chrichton, for being extraodinarily helpful in the Rust / WASM community
300308
- The [Elm](https://elm-lang.org/) team, for creating and standardizing the Elm architecture
301309
- Mozilla, for excellent DOM documentation
302310
- Denis Kolodin, for creating the inspirational [Yew framework](https://github.com/DenisKolodin/yew)
303-
- Utkarsh Kukreti, for through his [Draco repo](https://github.com/utkarshkukreti/draco),
304-
helping me understand how wasm-bindgen's
305-
closure system can be used to update state.
311+
- Utkarsh Kukreti, for through his [Draco repo](https://github.com/utkarshkukreti/draco),
312+
helping me understand how wasm-bindgen's
313+
closure system can be used to update state.
306314
- Tim Robinson, for being very helpful on the [Rust Gitter](https://gitter.im/rust-lang/rust).
307315

308-
309316
## Reference
317+
310318
- [wasm-bindgen guide](https://rustwasm.github.io/wasm-bindgen/introduction.html)
311319
- [Mozilla MDN web docs](https://developer.mozilla.org/en-US/)
312320
- [web-sys api](https://rustwasm.github.io/wasm-bindgen/api/web_sys/) (A good partner for the MDN docs - most DOM items have web-sys equivalents used internally)
@@ -315,4 +323,3 @@ be a versatile, standardized toolkit.
315323
- [Seed's API docs](https://docs.rs/seed)
316324
- [Learn Rust](https://www.rust-lang.org/learn)
317325
- [Testing in Headless Browsers](https://rustwasm.github.io/wasm-bindgen/wasm-bindgen-test/browsers.html)
318-

seed_branding/seed_logo.svg

Lines changed: 16 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)