Cecile Tonglet 9737fe77db
Extract Classes to a separate macro (#1601)
* Initial commit

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* Add feature flag for now

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* Add macro classes!()

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* rustfmt

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* rustfmt

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* Not sure why there is a prelude.rs file here...

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* Revert example changes

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* WIP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* CLEANUP

Forked at: 7e6d6c43f0aa98d78ae34654d49e1cf84d252cce
Parent branch: yewstack/master

* Revert back to e2717ae6281691f9563079ef07b56b24b6431ff1

* Put back original class behavior in html!

* Store span and use quote_spanned!

* Deprecation warning

* Better error message

* cargo fmt & fix conflict leftover oops

* Fix clippy: missing import

* What have I done

* Use Token! instead of Comma

* Apply suggestion

* Renamed HtmlClasses to Classes

* Remove clippy attribute & add dedicated tests

* Remove span from Single variant

* Spacing stuff with quote_spanned!

* Removed "use" and use path to Classes

* Some doc

* Replace Vec<Expr> with ExprTuple

* rustfmt

* Move classes to its own module

* Move tests from vtag to classes

* Update classes-fail.stderr

* Check for spaces in string literals

* Use unchecked_push for string literals

* Fixed tests

* More doc

* Tested doc in browser and make boolinator import visible

* Improve doc a tad bit

* Stuff

* Fix due to change with string literal

* Typo

* Moved classes to html

* Update macro new path for Classes

* Test fix

* Example fix

* Update classes-fail.stderr

* Fixed weird error

* Update yew/src/lib.rs

Co-authored-by: Simon <simon@siku2.io>

* Update yew/Cargo.toml

* Update yew/src/html/classes.rs

Co-authored-by: Simon <simon@siku2.io>

* Update docs/concepts/html/classes.md

Co-authored-by: Simon <simon@siku2.io>

* I blame GitHub

* Use syn::Result

* Apply suggestions

* Update yew-macro/src/classes/mod.rs

Co-authored-by: Simon <simon@siku2.io>

* Update yew-macro/tests/macro_test.rs

Co-authored-by: Simon <simon@siku2.io>

* Replaced html! by classes!

* Moved classes tests

* Renamed doc title

* Apply suggestion

* Update yew-macro/src/html_tree/html_element.rs

Co-authored-by: Simon <simon@siku2.io>

* Fixed span badly handled in macro

* no implicit prelude

* Update yew/src/lib.rs

Co-authored-by: Simon <simon@siku2.io>

* Improve documentation

* Yeah... OK

* OMG clippy

* Please squash merge and don't keep my commit messages

* Safety notice

* Change "Yew's macros" to "HTML"

* Unneeded closure

* Boxing stuff 🥊

* Indentation issue

* Removed unneeded block & removed duplicated code

* Renamed "macros" to "html_macro"

* Better span

* Doc: advice to use `classes!`

* Doc: fix error and remove one "and"

* Removed interpolated example

* Remove unnecessary tests and add test for deprecated syntax

* Link to classes!

* Update yew-macro/tests/html_macro_test.rs

Co-authored-by: Simon <simon@siku2.io>

* Renamed fail test

* Apply suggestion

* WIP

* WIP

* cargo make pr-flow passes locally, let's try again

Co-authored-by: Simon <simon@siku2.io>
2020-11-25 16:32:53 +01:00
..
2020-09-22 00:17:48 +02:00
2020-10-10 23:58:34 +02:00
2020-09-22 00:17:48 +02:00

Router Example

Demo

A blog all about yew. The best way to figure out what this example is about is to just open it up. It's mobile friendly too!

Running

While not strictly necessary, this example should be built in release mode:

trunk serve --release

Content generation can take up quite a bit of time in debug builds.

Concepts

This example involves many different parts, here are just the Yew specific things:

The example automatically adapts to the --public-url value passed to Trunk. This allows it to be hosted on any path, not just at the root. For example, our demo is hosted at /router.

This is achieved by adding <base data-trunk-public-url /> to the index.html file. Trunk rewrites this tag to contain the value passed to --public-url which can then be retrieved at runtime. Take a look at PublicUrlSwitch for the implementation.

Improvements

  • Use a special image component which shows a progress bar until the image is loaded.
  • Scroll back to the top after switching route
  • Run content generation in a dedicated web worker
  • Use longer Markov chains to achieve more coherent results
  • Make images deterministic (the same seed should produce the same images)
  • Show posts by the author on their page (this is currently impossible because we need to find post seeds which in turn generate the author's seed)
  • Show other posts at the end of a post ("continue reading")
  • Home (/) should include links to the post list and the author introduction
  • Detect sub-path from --public-url value passed to Trunk. See: thedodd/trunk#51