79 Commits

Author SHA1 Message Date
Kaede Hoshikawa
485a1b8c4a
Function Components & Hooks V2 (#2401)
* Make a use_hook hook with the new Hook trait.

* Implement Lifetime.

* Rewrites function signature.

* Only apply lifetime if there're other lifetimes.

* Cleanup signature rewrite logic.

* Rewrite hook body.

* Port some built-in hooks.

* Finish porting all built-in hooks.

* Port tests.

* Fix tests.

* Migrate to macro-based hooks.

* Fix HookContext, add tests on non-possible locations.

* Fix stderr for trybuild.

* Add 1 more test case.

* Adjust doc location.

* Pretty print hook signature.

* Fix Items & std::ops::Fn*.

* Add use_memo.

* Optimise Implementation of hooks.

* Use Box to capture function value only.

* Detect whether needs boxing.

* Add args if boxing not needed.

* Enforce hook number.

* Deduplicate use_effect.

* Optimise Implementation.

* Update documentation.

* Fix website test. Strip BoxedHook implementation from it.

* Allow doc string.

* Workaround doc tests.

* Optimise codebase & documentation.

* Fix website test.

* Reduce implementation complexity.

* Destructor is no more.

* Documentation and macros.

* Reduce heap allocation and hook complexity.

* Remove Queue as well.

* Prefer Generics.

* Fix typo.

* Remove more allocations.

* Add comments.

* Remove outdated comment.

* Bare Function Pointer for better code size.
2022-01-28 11:51:37 +02:00
Teymour Aldridge
c7599c54d8
Tidy up the documentation. (#2404)
- fix a number of typos/grammatical errors
- also includes some stylistic changes
2022-01-25 23:14:36 +02:00
Allan
31afa9de49
Editing fixes on Editor Setup page (#2397)
* Editing fixes on Editor Setup page

- "Jetbrains" fixed to "Jetbrains"
- fixed some typos and grammatical errors
- improved sentence flow

* Space before ignore attribute
2022-01-24 08:56:14 +05:00
Muhammad Hamza
a8f7113d4a
Documentation Improvements (#2391)
* the app crashes

* update the button

* API button

* Tutorial button

* Tutorial sidebar on next

* blog

* write-translations
2022-01-20 18:53:33 +05:00
Muhammad Hamza
d1f050e892
Add community page using docs multi-instance (#2390)
* use docs multi-instance

* Add awesome yew

This content is taken from https://github.com/jetli/awesome-yew/blob/master/README.md

* remove "Official" - We are official
2022-01-20 14:14:08 +05:00
Shivam
01a259431d
resolve some dead links as mentioned in issue #2379 (#2380)
* resolve some dead links as mentioned in issue #2379

* done the required changes
2022-01-19 18:20:24 +02:00
Matt
6669d1873e
Optimize CI caching and path filtering (#2340)
* fix docs.rs logo url

* fix formatting

* bump docusaurus to beta14

* bring back the semicolon

* cache npm for build-website workflow

* Add prebuilt cargo-sweep binary

* Optimize website CI

* per-job caching, stale cache invalidation

* extract fmt job as workflow
move website test as a prerequisite for publish

* fix typo in cargo-sweep executable path

* chmod +x

* rename to main-checks.yml

* --exclude has to be used with --workspace

* revert accidental revert

* Switch from cargo-sweep to rust-cache

* link to this related issue of extra brackets

* remove blanks

* exclude website-test in main tests

* rename suffixes from .mdx to .md

* replace actions-rs/install with wasm-pack-action

fixes #2351

* shouldn't ignore .md because website snippet tests depends on .md files and there can be
#[doc(include("../some.md"))] in the code

* restore accidentally deleted mdx files

* include tools/website-test (for real this time)
2022-01-18 10:49:11 +01:00
Kaede Hoshikawa
d8c2550fc7
Server-side Rendering (without hydration) (#2335)
* Basic render to html implementation.

* Remove HtmlWriter.

* Escape html content.

* Add non-suspense tests.

* Add Suspense tests.

* Gated "ssr" feature.

* Add example.

* Fix tests.

* Fix docs.

* Fix heading size.

* Remove the unused YewRenderer.

* Remove extra comment.

* unify naming.

* Update docs.

* Update docs.

* Update docs.

* Isolate spawn_local.

* Add doc flags.

* Add ssr feature to docs.

* Move ServerRenderer into their own file.

* Fix docs.

* Update features and docs.

* Fix example.

* Adjust comment position.

* Fix effects being wrongly called when a component is suspended.

* Fix clippy.

* Uuid & no double boxing.

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2022-01-12 18:43:09 +05:00
Jonathan Bailey
923f6434df
Support named wildcards when deriving Routable. (#2345) 2022-01-12 18:27:14 +05:00
Kaede Hoshikawa
1c367a7b6f
Remove start_app_as_body. (#2346)
* Remove start_app_as_body.

* Add migration guide.

* Update website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2022-01-10 22:12:22 +05:00
Allan
b3f8ca1920
Replace Model with App or MyComponent (#2336)
`Model` is ambiguous and not a user-friendly name.
Some of the newer docs are already referring to the root component as
`App`.

This PR follows this naming scheme:
 - `App` for a root component
 - `MyComponent` for an arbitrary component

This naming is inspired by the React docs.

i18n references were not changed. They need a larger rewrite which will
go in a separate PR.
2022-01-07 20:50:21 +05:00
Muhammad Hamza
f6f0e34d0f
Overhaul Documentation (#2321)
* Reorganize docs

* delete wasm-build-tools.mdx

* more small updates

* i hate versioned docs

* seems like I've got the traits of the certain owl who guards over the civilization when it comes to `;`

* just work please

* Update website/docs/concepts/components/lifecycle.mdx

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

* little things

* post merge fixes

* npm update

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2022-01-05 17:49:26 +02:00
Kaede Hoshikawa
ac3af0a9bc
Suspense Support (#2212)
* Make Html a Result.

* Fix tests.

* Implement Suspense.

* Schedule render when suspension is resumed.

* Shift children into a detached node.

* styled example.

* Update wording a little bit.

* Move hint to hint.

* Add some tests.

* Fix clippy.

* Add docs.

* Add to sidebar.

* Fix syntax highlight.

* Component -> BaseComponent.

* Html -> VNode, HtmlResult = RenderResult<Html>.

* Suspendible Function Component.

* Add a method to create suspension from futures.

* Revert extra changes.

* Fix tests.

* Update documentation.

* Switch to custom trait to make test reliable.

* Fix file permission.

* Fix docs.

* Remove log.

* Fix file permission.

* Fix component name error.

* Make Suspension a future.
2022-01-05 18:16:34 +05:00
Kaede Hoshikawa
6f6519dab4
Implement PrivateAgent (#2318)
* Implement PrivateAgent, Separate Threaded into PublicAgent & PrivateAgent.

* Add migration docs.

* Update docs.
2022-01-01 19:45:11 +01:00
Kaede Hoshikawa
7d52858d01
Remove context & job agent (#2295)
* Remove context and job agent.

* Revert "Remove context and job agent."

This reverts commit 408f6fcdf062800c9e9852e6662a55ff3eef4533.

* Revert "Revert "Remove context and job agent.""

This reverts commit 44a42dfb313c111ceaa654163c8aa610a88e6a95.

* Update example.

* Fix docs.

* Fix test.

* Rename examples.

* Fix examples & docs.

* Update website/docs/concepts/function-components/custom-hooks.mdx

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

* Examples in alphabetical order.

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2021-12-29 17:15:26 +05:00
Muhammad Hamza
3758e6d077
Refactor and simplify Callback (#2301)
* yeet Callback::once

* yeet Callback::reform

* remove passive overrides

Event's passive state will be determined by sane defaults set by Yew

* clippy

* docs

* make CI happy

* Revert "yeet Callback::reform"

This reverts commit 33e7770d

* why?

I literally tick-marked reformat before commit. Does it not use rustfmt???

* Update packages/yew/src/callback.rs

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-12-28 21:27:31 +02:00
Muhammad Hamza
73b5f6b4c1
Allow function_component creation based on function name (#2292)
* function_component without name

* fmt

* fc

* update docs

* remove fc
2021-12-23 13:30:17 +01:00
Matt
75864e8ae5
Use themed SVG for Agent lifecycle (#2287)
* remove backticks on wasm-bindgen

* make themed svg for agent life cycle

* wording

* Revert "make themed svg for agent life cycle"

This reverts commit 3b3a892bd36dc9da4b1d8d756b2964a8be707f7c.

* Revert "Revert "make themed svg for agent life cycle""

This reverts commit 5ac75821a15db6063227c4f10557899f07b847a7.

* wording

* jetbrains tips update
2021-12-21 20:12:15 +05:00
Matt
90b4e55ebc
Docusaurus Overhaul (#2275)
* change suffixes from md to mdx
fix broken links for English locale
tree shake and update docusaurus
add docusaurus ideal image plugin
use svg and themed image
delete unused static asset

* move localized landing page

* change GitLocalize project page

* nit pick

* remove ignore to have the block checked
2021-12-20 12:10:45 +02:00
Kaede Hoshikawa
d8ec50150e
Add HashRouter, basename and use gloo-history (#2239)
* Migrate to gloo-history.

* Fix docs wording.

* Add basename handling to navigator.

* Fix basename handling.

* Add lints and tests.

* Fix wording.

* Fix docs.

* Fix pr-flow.

* Fix some documentation.

* Add Navigator Kind.

* Remove history.rs

* Add documentation for navigator & Concrete Router Props.

* Update website/docs/concepts/router.md

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

* Add docs about basename.

* Update documentation.

* Fix docs.

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-12-19 20:38:33 +05:00
Leon
5c5642782f
docs: fix functional and struct components links (#2258)
* docs: fix functional and struct components links

* docs: fix link to func comp in rs

Co-authored-by: Leon Minasyan <leon-minasyan@yandex-team.ru>
2021-12-11 19:14:11 +01:00
Julius Lungys
5897eef03b
Fix router cargo version in docs (#2234)
* Fix router cargo version in docs

* Update website/docs/concepts/router.md

* Update website/docs/concepts/router.md

* fix according to comments
2021-12-06 11:48:24 +01:00
Matt
338dcd8869
Router docs about set-only components (#2214)
* Use From<Cow> of AttrValue in Link component

* docs about `BrowserHistory::default()`

* remove unused cow import

* remove unused cow import

* lint

* More accurate `BrowserHistory::default()` tips

* Update website/docs/concepts/router.md

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>

* Update website/docs/concepts/router.md

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

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
Co-authored-by: Simon <simon@siku2.io>
2021-12-05 16:15:37 +02:00
Kaede Hoshikawa
c73c6bb60b
Fix docs hooks naming (#2228)
* Fix hooks naming.

* Fix 0.19 docs as well.
2021-12-04 19:44:50 +05:00
Muhammad Hamza
996bf5b41a
Final documentation touch ups & tag 0.19.0 (#2220)
* some documentation fixes

* more fixes

* why it didn't work before is beyond me

* next redirect

* change 0.18 docs folder structure to make it inline with next

* move docs to /docs

now that home is its own page, docs should be under `/docs/`

* tag 0.19.0 version on website
2021-11-30 00:06:51 +05:00
Julius Lungys
a588f77738
Add migration guide for 0.19 (#2210)
* add migration guide for 0.19

* fix tests

* update 1

* fix tests?

* fix link
2021-11-29 14:15:32 +00:00
Franz Dietrich
2bc47b4882
Those slashes do not work (#2221)
I had an error in my code that was rather cryptic and I finally found that in the router example there are no closing slashes in the "type of Link"
2021-11-29 14:53:31 +02:00
Julius Lungys
399a5e8790
Update docosaurus to v2 beta 9 (#2215)
* Update docosaurus to v2 beta 9
- Also fix tabs
- Add toml language highlighting

* move around introduction files

* fix link
2021-11-29 14:19:29 +05:00
Luis Orbaiceta
48a83641bd
add missing text (#2203)
seems that copying from v0.18 to current some text got missing
2021-11-26 17:17:59 +00:00
Matt
fd92ab8948
Add missing router docs: Redirect, Nested Router, and Path Segament capturing (#2192)
* nested router structure diagram

* add Redirect, nested router documentation.

* add reminder

* fix the comment, duh

* snippets get tested too unless ignored

* fix inconsistent var name in snippet

* Add redirect to nested router example
normal component -> struct component

* Document about acceptable types for path segment
Document about router behaviour at fail to parse

* add missing ignore to snippet

* typo

* normal -> struct

* reformat codeblock and the markdown
functional comp -> function comp
consistent code snippet style
removed two ignores

* add back ignores

* typo, snippet correction. grammar.

* correction

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-11-26 10:00:13 +02:00
Kaede Hoshikawa
c348a2358e
Fix router docs. (#2188) 2021-11-23 21:06:41 +05:00
Kaede Hoshikawa
bb36725dc2
Add stylist to docs. (#2190) 2021-11-23 14:50:13 +02:00
Julius Lungys
8d674c5fda
Add key docs and Move fragments docs (#2178)
* Add key docs

* add frogments to sodebar

* remove duplicate title

* Apply suggestions from code review

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

* Apply suggestions from code review

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

* remove html comments

Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>
2021-11-23 09:01:58 +05:00
Cecile Tonglet
3858aededd
Add the ability to add child nodes conditionally in html! (#1609)
* Initial commit

Forked at: 66d506e13329a06f7dce0b55a9427972b8aad3ff
Parent branch: origin/master

* Add the ability to add child nodes conditionally in html!

* WIP

Forked at: 66d506e13329a06f7dce0b55a9427972b8aad3ff
Parent branch: origin/master

* CLEANUP

Forked at: 66d506e13329a06f7dce0b55a9427972b8aad3ff
Parent branch: origin/master

* Experiment

* Failing test

* More tests

* More tests

* Add new HtmlIterable with syntax `for {...}` instead of `{for ...}`

* Remove HtmlIf from HtmlRoot (already done in HtmlTree)

* WIP

* WIP

* WIP

* WIP

* Revert

* CLEANUP

* WIP

* CLEANUP

* Remove IterableNew

* Renamed HtmlBranch to HtmlRootBraced and moved to mod.rs

* Update yew-macro/tests/html_macro/html-if-pass.rs

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

* Suggestion

* Oops

* Added ToNodeIterator to HtmlIf

* Improve error spans

* More html!()

* Move tests to not use browser

* Multiple children in if-expr

* Clippy fix

* Clippy fix again

* Re-trigger CI

* Apply suggestions from code review

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

* Replacing ParseResult by syn::Result everywhere

* Remove unnecessary &mut

* Attempt to add test on ToNodeIterator

* Clippy fixes

* Still works for some reason

* Revert "Attempt to add test on ToNodeIterator"

This reverts commit 75b1a85c28df36ad8bf61344eef56e06667da3b6.

* fix CI

* add docs on website

* Apply suggestions from code review

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

* apparently I can't hide lines on website

* update stderr file

* will this work?

* fix bug where conditions can't be expressions

* better error message

* clippy & fmt

Co-authored-by: Simon <simon@siku2.io>
Co-authored-by: Hamza <muhammadhamza1311@gmail.com>
Co-authored-by: mc1098 <m.cripps1@uni.brighton.ac.uk>
2021-11-22 20:13:03 +02:00
Julius Lungys
3e656ddc8c
Fix router docs (#2173) 2021-11-22 07:55:32 +05:00
lausek
f5496482ca
Improve documentation of the router (#2166)
* docs: how to add parameters on route

* docs: how to listen for route changes

* docs: how to link to parameterized routes

* docs: router polish

* docs: make router tests pass
2021-11-21 19:50:28 +02:00
Teymour Aldridge
7e2542cbf8
Add basic lints to the HTML macro. (#1748)
* Add basic lints to the HTML macro.

* f

* Fix the examples.

* Fix nightly warning message tests.

* apply code review suggestions

* update error message

* rebase onto master

* remove unused props

* remove console log

* remove js void

* fix according to PR comments

Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com>
2021-11-21 19:54:49 +05:00
mc1098
071f1b28df
Refactor use ref hooks (#2093)
* Refactor use ref hooks

`use_ref` has been renamed to `use_mut_ref` and `use_ref` has become a
similar hook for immutable reference.

This is different from React but I think lines up nicely with Rust as a
reference is immutable unless specified to be a mut ref.

* fix CI

Co-authored-by: Hamza <muhammadhamza1311@gmail.com>
2021-11-21 16:20:19 +02:00
WorldSEnder
aa9b9b266c
Implementation of portals (#2147)
* initial poc implementation of portals

* add new_before

* add portals example

* add shadow dom example

* add english website documentation
2021-11-16 16:48:04 +01:00
Kaede Hoshikawa
fb9c398048
use_bridge hook for agents (#2125)
* Add Redirect Comp.

* Fix router behaviour.

* Fix output.

* Fix pr-flow.

* Remove Redirect.

* Readd 77b46bf.

* Add use_bridge hook.

* Add documentation.
2021-11-12 09:04:03 +01:00
Muhammad Hamza
dd2db93996
Use functions from gloo_utils instead of re-implementing them (#2124)
* Use functions from `gloo_utils` instead of re-implementing them

* Remove `anyhow` dependency

* fix errors

* review + post merge fixes
2021-11-11 16:45:08 +02:00
Muhammad Hamza
20f76e78da
Tidy up documentation (2) (#2137)
* Tidy up documentation.

* Fix spelling (maybe)

* Fix CI

* Update docs/concepts/function-components.md

Co-authored-by: Muhammad Hamza <muhammadhamza1311@gmail.com>

* apply review

Co-authored-by: teymour-aldridge <teymour.aldridge@icloud.com>
Co-authored-by: Teymour Aldridge <42674621+teymour-aldridge@users.noreply.github.com>
2021-11-11 16:25:31 +02:00
Kaede Hoshikawa
706fb48f6e
Reliable use_reducer dispatch and use_state setter (#2126)
* Add Redirect Comp.

* Fix router behaviour.

* Fix output.

* Fix pr-flow.

* Remove Redirect.

* Readd 77b46bf.

* Reliable dispatch for use_reducer.

* Detachable Dispatcher and Setter.

* Update docs wording.

* Update website/docs/concepts/function-components/pre-defined-hooks.md

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

* Update website/docs/concepts/function-components/pre-defined-hooks.md

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

* Update website/docs/concepts/function-components/pre-defined-hooks.md

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

Co-authored-by: Simon <simon@siku2.io>
2021-11-11 12:33:33 +01:00
Kaede Hoshikawa
f43760e3ca
Update Yew Router as per #2113 (#2118)
* Add Redirect Comp.

* Fix router behaviour.

* Fix output.

* Fix pr-flow.

* Remove Redirect.

* Readd 77b46bf.

* Router Context, History and Location.

* Finish Porting.

* Add Switch, Fix example.

* Add state.

* Fix pr-flow.

* Fix pr-flow.

* Fix unstable feature for 1.49.

* Add documentation.

* Error Types & Simplify Implementation.

* Add some tests.

* Update documentation.

* Fix route outside of a Switch.
2021-11-11 13:08:42 +02:00
Jonathan Birk
3ebd866d13
Minor fixup of tutorial files (#2131)
* Make the talk titles consistent

* Add replacing the hardcoded list of talks with the one generated from data

* Update website/docs/tutorial.md

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

* Update website/docs/tutorial.md

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

Co-authored-by: Simon <simon@siku2.io>
2021-11-05 17:49:57 +01:00
Julius Lungys
f2a0d617ce
Add set_if_neq for UseStateHandle (#2109)
* add set_neq for UseStateHandle

* add docs

* update based on PR comments 1
2021-10-16 00:25:16 +01:00
Robin Moussu
799a098841
Use git serve --open in the tutorial (#2108)
The line `server listening at 0.0.0.0:8080` isn’t very visible in the
logs of `trunk serve`, and can be easily be lost if the user does
multiple changes before looking at them. A beginner to web development
may not have the reflex to open this address, or may try to open
`dist/index.html` directly. In both cases he will not be able to see its
application.
2021-10-15 21:35:30 +01:00
mc1098
dbd8545a03
Add documentation for wasm-bindgen (#2082)
* Add documentation for wasm-bindgen

Adds a wasm-bindgen section to docs and gives a high level
description of it's crates and how they are used with Yew.

* Fix typos and formatting

* Expand JS example section

* fix re-export web_sys through yew info

* Add HtmlSelectElement feature

* Fix identing

* Fix code example comment
2021-10-02 19:59:50 +02:00
Jon Cahill
4ab710c0e5
Update tutorial to use use_effect_deps instead of use_effect (#2090) 2021-09-27 13:18:37 +01:00
mc1098
e503c9acda
Remove web_sys re-export (#2084)
* Remove `web_sys` re-export

Removes re-exporting the `web_sys` dependency from the yew crate and
removes some `web_sys` features that were only enabled for re-exporting.

* re-export events through yew::events
2021-09-27 02:07:38 +02:00