29 Commits

Author SHA1 Message Date
Muhammad Hamza
c28a71e78e
Use nightly for Rustfmt (#2630)
* add rustfmt.toml, use nightly in CI, update contributing docs

* run `cargo +nightly fmt`
2022-04-21 23:21:15 +05:00
Kaede Hoshikawa
8bc2212716
#[cfg(feature = "render")] and yew::Renderer (#2498)
* Bring changes to this branch.

* Bring changes to this branch.

* Add feature render and renderer.

* Bring changes to this branch.

* Migrate examples to Renderer.

* Satisfy no any render.

* Satisfy ssr.

* Satisfy feature render.

* Lint feature soundness.

* Suppress tests.

* Fix pr-flow, update docs.

* Add a notice.

* Adjust visibility.

* Correctly feature gate tests.

* make test scope available under feature render.

* Fix CI.

* Fix CI.

* Restore tests module to its original place as well.

* Make bundles crate private.

* Make most bundle APIs private.

* Adjust docs.

* Adjust debug implementation.

* Replace start_app with Renderer.

* Adjust documentation.

* Remove unused lint.

* Remove start_app from docs.

* DomBundle -> ReconcileTarget.

* Adjust documentation.

* Once render, now csr.

* Fix docs as well.
2022-03-20 00:48:47 +09:00
Julius Lungys
3d9eec90d9
Fix nested list demo (#2208)
* Fix nested list demo

* remove id
2021-11-27 16:25:42 +00:00
mc1098
4e974dad92
Remove ShouldRender type alias (#2011)
Remove `ShouldRender` type alias for bool. In the Component trait an
extra comment has been added to explain what the returned bool
represents.
2021-08-25 17:52:09 +02:00
Muhammad Hamza
f50c8c3cba
Components v2 (2) (#1961)
* Start rewrite

* Rc > cloning props

* fmt + rm useless file

* move props inside `Context`

* router compiles

* fix boids example

* fix counter example

* fix crm example

* fix dyn_create_destroy_apps example

* fix file_upload example

* fix futures example

* fix game_of_life example

* fix inner_html example

* fix js_callback example

* fix mount_point example

* fix keyed_list example

* fix web_gl example

* fix two_apps example

* fix todomvc example

* fix timer example

* fix store example

* fix nested_list example

* fix node_refs example

* fix pub_sub example

* fix multi_thread example

* don't call `changed` if props weren't changed

* formatting

* fix doc tests, remove neq_assign

* update router example, fix neq_assign compile errors

* fix macro/rest of doc tests

* start updating documentation

* `Component`'s documentation

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Apply suggestions from code review (part 2)

* Apply suggestions from code review (part 3)

* fix context

* clippy

* post merge fixes

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-08-25 13:11:39 +01:00
Xavientois
c1226a2813
Add shorthand syntax for props (#1970)
* Allow shortened prop syntax

* Use new syntax where appropriate

* Apply suggestions from code review

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Add tests to hit newly added error messages

* Fix clippy lints

* Re-trigger CI

* Revert error text

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-07-31 23:01:02 +02:00
Xavientois
4a14d0f0a4
Add requirement for braces around most props (#1939)
* Limit the properties to literals and brace-enclosed expressions

* Update examples with new syntax

* Update packages/yew-macro/src/props/prop.rs

Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>

* Fix lints and strip braces around single expressions

* Update docs with new prop syntax

* Add some test cases for new syntax

* Ensure all tests are passing

* Clean up missed code

* Update tests

* Update reverted docs

* Revert versioned docs

* Fix optional attributes paragraph

* Remove accidentally added files

* Remove accidentally added french docs

* Update packages/yew-macro/src/props/prop.rs

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>

* Fix forgotten braces and test cases

* Revert i18n old docs

* Revert translated docs

* Remove suggested fix in favour of more succinct error message

* Update errors after rebase

* Remove files accidentally added while rebasing

* Fix merge conflicts

Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-07-18 18:54:21 +02:00
Simon
f17d370217 Implicit optional attributes (#1637) 2021-06-05 23:00:58 +02:00
Muhammad Hamza
991abab7e1
Update Rust version for macro tests to 1.51 & enable const generics tests (#1801)
* update rust version for macro test to 1.51

* enable const generic tests

* run integration tests using MSRV

* am blind

* clippy, fmt

* apply suggestion
2021-03-30 22:35:21 +02:00
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
Simon
c946b99610
Overhaul examples (#1559)
* remove old files

* update counter

* update crm example

* Add readme for counter

* update custom_components

* update webgl example

* update two_apps

* update todomvc

* mark special case multithread

* update dashboard

* update examples readme

* file_upload example

* fragments example

* futures example

* game_of_life example

* inner_html example

* js_callback example

* keyed_list example

* remove large_table

* remove minimal

* mount_point example

* I can't count apparently

* nested_list example

* node_refs example

* timer example

* store example

* pub_sub example

* rip npm_and_my_sanity

* use a title™️

* clean up multi_thread

* fix format

* boids part 1

* boids part 2

* add workflow

See: <https://github.com/siku2/yew/pull/13>

* remove my little scratchpad again

* add boids to examples table

* runtime-generated list in  nested_list example

* update workflow

* first batch of yewtil examples

* clippy "futures"

* remove old yew-router examples

* add a new router example to the main examples

* remove remaining yewtil examples

* more progress

* update for testing purposes

* author list

* improve content generation

* revert this mistake

I thought it would be great to use `unimplemented!()` in case the component doesn't have any properties.
This helps avoid the mistake of forgetting to update the change method when adding props later on.
What I didn't consider is that just because the props are () that doesn't mean that Yew isn't going to call it...
So yeah, it's still a good idea for update, but certainly not for change.

* missed a few

* turn router switch example into test

* seems to be working

* make it possible to host the router example on a sub-path

* create a 404 file for SPA

* remove the three examples and update table

* remove the 404 file because it isn't working anyway

* fix small router issue relating to the sub-path hack
2020-09-22 00:17:48 +02:00
Motoki saito
7301abea14
Clean up imports in nested_list example (#1532)
Co-authored-by: motoki saitou <stmtk@notepsace.jp>
2020-08-28 14:40:18 +02:00
Simon
deb8b57ff8
Improve macro error spans (#1516)
* make clippy happy

* improve spans

* improve error spans for components

* clippy got mad at me again
2020-08-22 18:45:01 +02:00
cljvm
f470df5cec
fix nested_list example (#1498)
* fix nested_list example

* fmt
2020-08-17 17:10:35 +08:00
Justin Starry
a8f1667332
Remove proc-macro-hack and bump MSRV to 1.45 (#1452)
* Remove proc-macro-hack and fix warnings

* Bump MSRV to 1.45

* Fix tests

* Add set_boolean_attribute method

* Fix component clippy warnings

* Feedback

* Suppress clippy warnings

* Fix new clippy warnings
2020-08-15 23:01:58 +08:00
Simon
d792e37bff
Unify and change children logic in the html macro (#1275)
* add test to assert iterators work

* update test

* a few minor adjustments

* remove redundant wrappers around htmltree

* we're going down the rabbit hole

* components are broken but everything else works

* we're getting there

* working prototype

* test vector as children method for all containers

* more appropriate names and some comments

* ChildrenRenderer handling

* update tests to include ChildrenRenderer

* trigger tests to re-run

* improve error messages for invaid iterables

* improve html_nested!
2020-06-09 09:34:23 +08:00
Justin Starry
d5bb263b84
Update props properly in nested list example (#1189) 2020-05-06 15:53:05 +08:00
Stig Johan Berggren
d7156eee99
Replace web_logger with wasm-logger in examples (#1181)
* Replace web_logger with wasm-logger in examples

Examples in yew-stdweb should still use web_logger

* Use hyphen in package name
2020-05-03 17:17:44 +08:00
Bill
6c16c8c134
Fix examples (#1093)
* ci: verify all examples build.

Using examples/showcase masked breakages in multiple examples.

* examples/future: add change implementation.

* examples/minimal: add change implementation.

* examples/nested_list: add change implementation.

* ci: add block lists to skip some examples.
2020-04-20 15:42:50 +08:00
AlephAlpha
afb5e9d7ac
Properties 2.0 (#975)
* Properties 2.0

* Fix problem when passing a closure to prop_or_else

* Update test names

* Add support for building with web-sys (#961)

* Enable travis

* `web-sys` general conversion (#826)

* Moved patches from different PRs.

* Add bits & pieces and some services.

* Rename `stdweb` feature to `std_web`.

* Move tests and examples to different PR.

* Revert some `cargo_web` handling removal.

* Missed something.

* Implement `console_error_panic_hook`.

* Update Cargo.toml

Co-authored-by: Justin Starry <justin.m.starry@gmail.com>

* Move document creation to util convenience method (#855)

* `web-sys` listener conversion (#813)

* `web-sys` listener initial try.

* Improve macros?

* Remove generic from `EventListenerHandle`.

* Fix build.

* A cleaner solution?

* Even cleaner.

* Fix `build.rs`.

* Minor improvements.

* Following the yew toml style.

* Fixing visibility.

* Fix `rustfmt`.

* Add `web-sys` re-exports.

* Move general changes to different PR.

* Remove compat.

* Actually remove `compat.rs`.

* Rename `stdweb` feature to `std_web`.

* Move to gloo's `EventListener` and some polish.

* Remove outdated comment.

* Change `EventHandler` to be cancelled on drop.

* `web-sys` html conversion (#817)

* Converting all `html` parts.

* Format.

* Move general changes to different PR.

* Removed compat.

* Rename `stdweb` feature to `std_web`.

* Remove redudant function copy.

* Some polish.

* Move to gloo's `EventListener`.

* Replace `unwrap`s with `expect`s.

* `web-sys` agent conversion (#818)

* Converting `agent`.

* Remove wrong `cfg` in imports.

* Move general changes to different PR.

* Some optimisations.

* Rename `stdweb` feature to `std_web`.

* Fix `ArrayBuffer` to `Uint8Array` conversions.

* Add js module worker.

* Use `cfg-if`` and `cfg-match` to make things clearer.

* Fix `std_web` build.

* Add some polish.

* Add build guards for invalid build configs (#866)

* `web_sys` cfg conversion (#862)

* Use `cfg-if` and `cfg-match` and some polish.

* Mistakes were made.

* Missed line during rebasing.

* Mistakes were undone.

* Remove global.

* Remove part of `global!`.

* `web-sys` services conversion (#827)

* Convert `console`.

* Finish services.

* Some polish.

* Fix `ArrayBuffer` to `Uint8Array` conversions.

* Fix aborting fetch leading to error and some polish.

* Replaced some `unwrap`s with `expect`s.

* Use `cfg_if` and `cfg_match` and do some polish.

* Proper scoping.

* Some fixes.

* Move fetch and reader services to different PR.

* Revert split.

* Fix CI builds (#877)

* Fix derive_props_test

* Move tests (#897) (#898)

* `web-sys` fetch service conversion (#867)

* Split implementation.

* Import global.

* Import global.

* Revert split.

* Make fetch available again.

* Revert "Revert split."

This reverts commit 6e3f101dbedde2142f041467a8ae40ef5e3920c5.

* Re-revert split.

* Some polish.

* Move to `wasm_bindgen_futures`.

* Switch to `thiserror`.

* wip

* Update src/services/fetch/web_sys.rs

Co-Authored-By: daxpedda <daxpedda@gmail.com>

* Some more polish.

Co-authored-by: Justin Starry <justin.m.starry@gmail.com>

* `web-sys` reader service conversion (#868)

* Split reader implementation.

* Revert split.

* Remove leftover files.

* Make reader available again.

* Revert "Revert split."

This reverts commit 8abdc9cf2b014ab61fef2c48d1af8927d9a5a330.

* Revert "Remove leftover files."

This reverts commit 188c6eb9693881c9987061de8deb29c6f4c613a4.

* Re-revert split.

* Polish.

* Forgot some part.

* Some polish.

* Some polish.

* `web-sys` examples/tests conversion (#841)

* Fix examples/tests to work with `web_sys`.

* Update `StorageService` usage.

* Split `stdweb` and `web-sys` examples.

* Fixing the shell script.

* Trying to reset file permissions.

* Update to new reader API.

* Update to new fetch API.

* Update to new fetch API.

* Re-enable examples CI.

* Deleted duplicate example.

* Some fixes.

* Fix rand build.

* Fix spawning workers in combination with `wasm-bindgen`. (#901)

* Fix component rendering process (#913)

* wip

* Fix component rendering process

* Simplify yew-macro a bit (#902)

* yew-macro: Simplify Properties validation

* Fix most clippy warnings

* Fix clippy warnings (#912)

* Import Task trait in dashboard example

* Remove duplicate vtag tests

* Fix prevent_default() by non-passive (#958)

* Fix prevent_default() by non-passive

* Fix cargo fmt

* Remove `Option` from most services.

* Remove `Option` from resize service.

* Apply fetch changes.

* Apply reader service changes.

* Fix `node_refs` example.

* Remove web-sys travis branch

Co-authored-by: daxpedda <daxpedda@gmail.com>
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
Co-authored-by: Jet Li <jing.i.qin@icloud.com>

* Fix vtag test warning (#978)

* Clean up exported apis and doc visibility (#977)

* Clean up exported apis and doc visibility

* Remove unused ScopeHolder

* Change ComponentLink to alias of Scope

* cargo fmt

* update new examples to Properties 2.0

* Fix a mistake when resolving conflicts

* Remove an outdated hack.

Co-authored-by: Justin Starry <justin.m.starry@gmail.com>
Co-authored-by: daxpedda <daxpedda@gmail.com>
Co-authored-by: Jonas Platte <jplatte@users.noreply.github.com>
Co-authored-by: Jet Li <jing.i.qin@icloud.com>
2020-03-01 10:43:54 +08:00
Justin Starry
84a9ed0e09
Make virtual dom cloneable (#786) 2019-12-28 20:53:29 -06:00
Justin Starry
f61667be97
Remove generics from virtual dom (#783)
* Fix tests

* Remove generics from virtual dom

* Prep for degenerify

* Fix examples

* Remove props cloning

* Fix tests
2019-12-08 10:47:51 -08:00
Justin Starry
c583f731c5
Support passing callbacks to elements (#777)
* Support passing callbacks to elements

* Fix tests
2019-12-07 13:42:19 -05:00
Zydnar
cb671ad4d2 nested_list example fix (#765) (#767)
Added missing parameter in two places
2019-12-02 09:32:30 -05:00
Justin Starry
43e9347269
Add render method to Component and auto implement Renderable (#563)
* Add render method to Component and auto implement Renderable

* More cleanup

* Rename Renderable method from view to render

* Doc fixes

* fix

* Update CHANGELOG.md
2019-09-30 22:23:25 -04:00
Justin Starry
563807a861 Implement Renderable trait and add docs 2019-09-04 21:26:36 -04:00
Justin Starry
527cb9865e Add is_empty and len methods to ChildrenRenderer 2019-09-04 20:16:37 -04:00
Justin Starry
23c23d74ec Cleanup 2019-08-25 18:28:51 -04:00
Justin Starry
0e78f7aafb Update example 2019-08-25 16:53:14 -04:00