62 Commits

Author SHA1 Message Date
Justin Starry
8fd95d867a
Use VList for VTag children (#754)
* Use VList for VTag children

* Fix placeholder bug

* impl Deref for VList

* cargo fmt
2019-11-24 13:19:24 -05:00
Justin Starry
7c959a5396
Bump yew from 0.10 to 0.10.1 (#737) 2019-11-11 00:58:44 -05:00
Justin Starry
c178d5273f
Add ref attributes to enabling DOM access in Components (#715) 2019-11-04 00:32:56 -05:00
Henry Zimmerman
5056b8458f Box VTag to reduce size disparity between VNode variants (#675) 2019-10-14 19:57:31 -04:00
Justin Starry
6fdf17757f Use wasm32-unknown-unknown as the default build target (#702)
* Use wasm32-unknown-unknown as the default build target

* Print rustup installed targets

* Add doc_test alias
2019-10-14 15:05:51 -04:00
Justin Starry
7f276d57f1
Improve compile error for non-string attributes (#710) 2019-10-13 23:18:42 -04:00
Justin Starry
9845bd3ff8
Variable renames (#696)
* childs -> children

* precursor -> previous_sibling

* cargo fmt and name changes
2019-10-12 16:39:55 -04: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
afb832d4b8
Bump version to v0.10.0 (#662) 2019-09-27 11:15:40 -04:00
Justin Starry
567a945ba1
Fix touch events (#656) 2019-09-24 22:21:10 -04:00
Justin Starry
f8d07237cc Add test 2019-09-22 09:15:41 -10:00
Andrew Straw
16c7864d63 fix #638 2019-09-15 11:42:04 +02:00
bors[bot]
24d39f97e3
Merge #589
589: Allow components to accept children elements r=jstarry a=jstarry

Fixes: https://github.com/yewstack/yew/issues/537

#### Terminology
- (B) Base component that renders components nested inside each other
- (P) Parent component that has a `children` property and can render those children
- (C) Child component that is nested inside parent and included inside the Parent's `children`

#### Todo
- [x] Add example for nested components
- [x] Support arbitrary html nested inside component tags
- [x] Support nested components inside component tags
- [x] Allow modifying & accessing (C) props when rendering (P)
- [x] Allow filtering (C) components when rendering (P)
- [x] Children prop be required or optional
- [x] Clean up nested component example
- [x] Fix parser for generic component type
- [x] Write tests
- [x] Update documentation and README
- [x] ~~Investigate passing required properties from (P) -> (C)~~
- [x] ~~Allow sending messages from (C) -> (B)~~


Co-authored-by: Justin Starry <jstarry@users.noreply.github.com>
2019-09-10 14:53:24 +00:00
Justin Starry
527cb9865e Add is_empty and len methods to ChildrenRenderer 2019-09-04 20:16:37 -04:00
Denis Kolodin
c4fa17004b Change org to YewStack 2019-09-01 00:02:24 +09:00
Justin Starry
7ae088647b Add tests 2019-08-25 18:12:14 -04:00
Justin Starry
599e4d0764 Support generic components 2019-08-25 00:10:57 -04:00
Justin Starry
bd2fc4254f Use holder to avoid box paren wrapping 2019-08-25 00:10:57 -04:00
Justin Starry
8e4a7eda36 Add default implementation for children prop 2019-08-25 00:10:57 -04:00
Justin Starry
bddb2f0b8e Props 2019-08-25 00:10:57 -04:00
Justin Starry
a7e251cdb0 First pass at component children 2019-08-25 00:10:57 -04:00
Maximilian Goisser
c97d23cb40 Update proc-macro2, syn and quote to 1.0
CLOSES #590
2019-08-21 09:18:06 +02:00
bors[bot]
84db98ccde Merge #585
585: Add own Classes struct implementation r=DenisKolodin a=DenisKolodin

Hide details of Classes set implementation and add a feature to produce that struct from variety of sources like `&str`, `String` and `Vec<T> where T: AsRef<str>`.

I need this to have an effective way to construct complex classes set for https://github.com/yewstack/facade. With this PR we can do something like:

```rust
let mut classes = vec!["container"];
classes.push("fluid");
// or
let mut classes = Classes::new();
classes.append("container");
if fluid_flag {
    container.append("fluid");
}

html! {
    <div classes=classes />
}
```

In the future we can implement `impl Info<Classes> for (tuple)` and  simplify macro by delegating **tuples to classes** conversion to type system (instead of macro).

Let's give a chance to CI to check it 🤞 

Also I applied `cargo fmt` to the root crate sources.

Co-authored-by: Denis Kolodin <deniskolodin@gmail.com>
2019-08-13 13:52:35 +00:00
Boyd Johnson
76336b3940 Add touch events (#584)
This adds:
   - TouchCancel
   - TouchEnd
   - TouchEnter
   - TouchMove
   - TouchStart
2019-08-13 09:31:30 -04:00
Denis Kolodin
46ae317926 Add own Classes struct implementation
Hide details of Classes set implementation and add a feature to produce that struct
from variety of sources like `&str`, `String` and `Vec<T> where T: AsRef<str>`.
2019-08-13 00:56:00 +09:00
Justin Starry
74373e6164 Add lifetime support to derive props macro 2019-08-11 17:38:49 -04:00
Justin Starry
c9d5c70af0 Bump version to 0.9.0 2019-08-10 19:48:21 -04:00
Justin Starry
584973c9f6 Enable 'extra-traits' feature for syn dep 2019-08-10 19:22:28 -04:00
Thomas Lacroix
78d4376c38
html!: handle misleading '>' in tag attributes
### Problem
The html! macro didn't handle cases like this one:

```rust
html! {
    <div onclick=|_| 2 > 1 />
    //                 ^ this
}
```

Moreover, the introduction of handling of mixed self-closing and not
self-closing tags introduced a buggy error message, which is now fixed.

### Solution
The parser only allows '<', '{' or nothing after a tag's closing '>'.

`verify_end` is removed, and the presence of a closing tag is checked
when parsing the children.

Note: I also moved some tests around.

### Regression
Unfortunately, this change has a regression: the error message is less
good now, like here in `html-tag-fail.stderr`:

```
diff --git a/tests/macro/html-tag-fail.stderr b/tests/macro/html-tag-fail.stderr
index b14fc14..d59e8f4 100644
--- a/tests/macro/html-tag-fail.stderr
+++ b/tests/macro/html-tag-fail.stderr
@@ -52,11 +52,13 @@ error: only one root html element allowed
 12 |     html! { <img /></img> };
    |                    ^^^^^^

-error: expected valid html element
-  --> $DIR/html-tag-fail.rs:13:18
+error: unexpected end of input, expected token tree
+  --> $DIR/html-tag-fail.rs:13:5
    |
 13 |     html! { <div>Invalid</div> };
-   |                  ^^^^^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

 error: only one `attr` attribute allowed
   --> $DIR/html-tag-fail.rs:15:27
```
2019-08-07 11:52:52 +02:00
Thomas Lacroix
c6e1a395d1
html!: fix explicit return types in callbacks
### Problem
The html! macro didn't properly handle explicit return types in
callbacks, considering the '>' in '->' as the end of the HTML tag.

```rust
html! {
    <div onblur=|_| -> u32 0 />
    //               ^ here
}
```

Fixes: #560
2019-08-05 15:37:32 +02:00
Justin Starry
480a099397 Add support for svg by creating elements with correct namespace 2019-08-03 10:38:00 -04:00
Justin Starry
f2e0f4886b @totorigolo feedback 2019-07-31 12:23:55 -04:00
Justin Starry
e97bc98ce5 Add PeekValue trait 2019-07-30 09:47:32 -04:00
Justin Starry
478b5b99bb Support dashed custom tag names 2019-07-30 01:30:24 -04:00
Thomas Lacroix
5908d33b2c
html!: allow mixing self-closing and non-sc tags
#### Problem
Self-closing tags are more convenient when there are no children. For
instance, React's JSX allows it.

Before, self-closing tags where considered as open tags in `verify_end`,
causing codes like this to not compile:

```rust
html! {
    <div>
        <div/> // <- considered as open tag
    </div>
}
```

```
error: this open tag has no corresponding close tag
   --> src/lib.rs:264:17
    |
... | <div>
    | ^^^^^
```

#### Solution
Add a new `Peek`-able `HtmlSelfClosingTag`, used in `verify_end`.

However, this fix isn't ideal because it peeks the buffer twice for
non self-closing tags. I did it that way in order to keep the peek
thing. An alternative would be to turn HtmlSelfClosingTag::peek into a
function returning (ident, is_self_closing).

#### Notes
I added a TODO for when proc-macro::Diagnostic gets stabilized, in
order to replace the clunky `eprintln!` with proper diagnostics. I
didn't try to return a Result to get a nice error right now because
this error should be fairly rare so we can just wait IMO.

Fixes: #522
2019-07-26 15:09:18 +02:00
Justin Starry
97818842d7 Improve component trait check 2019-07-21 10:37:42 -04:00
Justin Starry
073d0af65d Update macro doc tests 2019-07-20 23:03:05 -04:00
Justin Starry
da1374540f Refactor props derive 2019-07-20 22:38:50 -04:00
Justin Starry
3fed651b42 Add support for required props 2019-07-20 22:38:50 -04:00
Justin Starry
d8ca45e9dd Bump version to 0.8.0 2019-07-19 10:44:03 -04:00
Justin Starry
4d775730ca Small fixes to yew-macro Cargo.toml 2019-07-19 10:25:07 -04:00
Justin Starry
43e101d201 Update macro docs and set macro version in yew cargo.toml 2019-07-18 08:38:26 -04:00
Justin Starry
af45d91f05 Remove macro-impl crate 2019-07-15 10:06:43 -04:00
Justin Starry
18e045eb51 Rework macro tests and remove yew-shared dependency 2019-07-14 22:47:15 -04:00
Justin Starry
c0bb528f76 Allow using keyword for as tag attribute 2019-07-06 10:30:59 -04:00
Justin Starry
e373df1ca2
Merge branch 'master' into refactor-vcomp 2019-07-05 20:41:26 -04:00
Justin Starry
0f87b5506d Fix test 2019-07-03 09:10:11 -04:00
Justin Starry
8962b77ff5 Support dashed tag labels 2019-07-03 00:13:12 -04:00
Justin Starry
1e1eb6f019 Code cleanup 2019-06-27 15:55:58 -04:00
Justin Starry
5615f53540 Add more test cases and improve error messages 2019-05-28 16:31:04 -04:00