Skip to content

Commit ada85f4

Browse files
committed
Merge commit 8d2cfde (no conflict)
2 parents 46e12dc + 8d2cfde commit ada85f4

57 files changed

Lines changed: 7527 additions & 4241 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/benchmark-core.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ jobs:
1616

1717
steps:
1818
- name: Checkout master
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020
with:
2121
repository: "yewstack/yew"
2222
ref: master
2323
path: yew-master
2424

2525
- name: Checkout pull request
26-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2727
with:
2828
path: current-pr
2929

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
version: "latest"
4343

4444
- name: Setup Node
45-
uses: actions/setup-node@v3
45+
uses: actions/setup-node@v4
4646
with:
4747
node-version: 18
4848
cache: "npm"

.github/workflows/build-website.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
- uses: actions/checkout@v4
2424

2525
- name: Setup node
26-
uses: actions/setup-node@v3
26+
uses: actions/setup-node@v4
2727
with:
28-
node-version: "16"
28+
node-version: "18"
2929

3030
- name: Install dependencies
3131
run: |

.github/workflows/post-benchmark-core.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
steps:
1717
- name: Download Repository
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919

2020
- name: Download Artifact
2121
uses: Legit-Labs/action-download-artifact@v2

packages/yew/src/functional/hooks/use_reducer.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::ops::Deref;
55
use std::rc::Rc;
66

77
use crate::functional::{hook, Hook, HookContext};
8+
use crate::html::IntoPropValue;
9+
use crate::Callback;
810

911
type DispatchFn<T> = Rc<dyn Fn(<T as Reducible>::Action)>;
1012

@@ -133,6 +135,24 @@ where
133135
}
134136
}
135137

138+
impl<T> From<UseReducerDispatcher<T>> for Callback<<T as Reducible>::Action>
139+
where
140+
T: Reducible,
141+
{
142+
fn from(val: UseReducerDispatcher<T>) -> Self {
143+
Callback { cb: val.dispatch }
144+
}
145+
}
146+
147+
impl<T> IntoPropValue<Callback<<T as Reducible>::Action>> for UseReducerDispatcher<T>
148+
where
149+
T: Reducible,
150+
{
151+
fn into_prop_value(self) -> Callback<<T as Reducible>::Action> {
152+
Callback { cb: self.dispatch }
153+
}
154+
}
155+
136156
impl<T> UseReducerDispatcher<T>
137157
where
138158
T: Reducible,
@@ -141,6 +161,14 @@ where
141161
pub fn dispatch(&self, value: T::Action) {
142162
(self.dispatch)(value)
143163
}
164+
165+
/// Get a callback, invoking which is equivalent to calling `dispatch()`
166+
/// on this same dispatcher.
167+
pub fn to_callback(&self) -> Callback<<T as Reducible>::Action> {
168+
Callback {
169+
cb: self.dispatch.clone(),
170+
}
171+
}
144172
}
145173

146174
/// The base function of [`use_reducer`] and [`use_reducer_eq`]

packages/yew/src/functional/hooks/use_state.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ use std::rc::Rc;
44

55
use super::{use_reducer, use_reducer_eq, Reducible, UseReducerDispatcher, UseReducerHandle};
66
use crate::functional::hook;
7+
use crate::html::IntoPropValue;
8+
use crate::Callback;
79

810
struct UseStateReducer<T> {
911
value: T,
@@ -171,6 +173,18 @@ where
171173
}
172174
}
173175

176+
impl<T> From<UseStateSetter<T>> for Callback<T> {
177+
fn from(value: UseStateSetter<T>) -> Self {
178+
Self::from(value.inner)
179+
}
180+
}
181+
182+
impl<T> IntoPropValue<Callback<T>> for UseStateSetter<T> {
183+
fn into_prop_value(self) -> Callback<T> {
184+
self.inner.into_prop_value()
185+
}
186+
}
187+
174188
impl<T> PartialEq for UseStateSetter<T> {
175189
fn eq(&self, rhs: &Self) -> bool {
176190
self.inner == rhs.inner
@@ -182,4 +196,10 @@ impl<T> UseStateSetter<T> {
182196
pub fn set(&self, value: T) {
183197
self.inner.dispatch(value)
184198
}
199+
200+
/// Get a callback, invoking which is equivalent to calling `set()`
201+
/// on this same setter.
202+
pub fn to_callback(&self) -> Callback<T> {
203+
self.inner.to_callback()
204+
}
185205
}

website/docs/getting-started/build-a-sample-app.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn main() {
115115
Finally, add an `index.html` file in the root directory of your app.
116116

117117
```html , title=index.html
118-
<!DOCTYPE html>
118+
<!doctype html>
119119
<html>
120120
<head>
121121
<meta charset="utf-8" />

website/docs/getting-started/examples.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We also welcome Pull Requests and issues for when they inevitably get neglected
99
For more details including a list of examples, refer to the [README].
1010

1111
:::note
12-
Most of the examples have a live deployment that can be found at https://examples.yew.rs/<example_name>.
12+
Most of the examples have a live deployment that can be found at https://examples.yew.rs/< example_name >.
1313
Click the shield on their README page in their respective sub-folder to navigate to the live demo.
1414
:::
1515

website/docs/tutorial/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fn main() {
105105
Now, let's create an `index.html` at the root of the project.
106106

107107
```html title="index.html"
108-
<!DOCTYPE html>
108+
<!doctype html>
109109
<html lang="en">
110110
<head></head>
111111
<body></body>

website/docusaurus.config.js

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -119,33 +119,47 @@ module.exports = {
119119
prism: {
120120
additionalLanguages: ['rust', 'toml'],
121121
},
122-
gtag: {
123-
trackingID: 'G-DENCL8P4YP',
124-
anonymizeIP: true,
122+
algolia: {
123+
appId: 'F8S2ICRD2T',
124+
apiKey: '2dc337d68f84389c3713a393aff39816',
125+
indexName: 'yew-rs',
126+
contextualSearch: true,
127+
insights: true, // Optional, automatically send insights when user interacts with search results
128+
searchPagePath: 'search',
125129
},
126130
},
127131
i18n: {
128132
defaultLocale: 'en',
129133
locales: ['en', 'ja', 'zh-Hans', 'zh-Hant'],
130134
},
131-
plugins: [
132-
'content-pages',
133-
'docusaurus-plugin-sass',
134-
[
135-
'@docusaurus/theme-classic',
136-
{
137-
customCss: require.resolve('./src/css/custom.css'),
138-
},
139-
],
135+
presets: [
140136
[
141-
'@docusaurus/plugin-content-docs',
137+
'@docusaurus/preset-classic',
142138
{
143-
path: 'docs',
144-
sidebarPath: require.resolve('./sidebars/docs.js'),
145-
editUrl,
146-
routeBasePath: '/docs',
139+
theme: {
140+
customCss: ['./src/css/custom.css'],
141+
},
142+
docs: {
143+
path: 'docs',
144+
sidebarPath: require.resolve('./sidebars/docs.js'),
145+
editUrl,
146+
routeBasePath: '/docs',
147+
},
148+
blog: {
149+
path: 'blog',
150+
blogTitle: 'Yew Blog',
151+
editUrl,
152+
},
153+
pages: {},
154+
gtag: {
155+
trackingID: 'G-DENCL8P4YP',
156+
anonymizeIP: true,
157+
},
147158
},
148159
],
160+
],
161+
plugins: [
162+
'docusaurus-plugin-sass',
149163
[
150164
'@docusaurus/plugin-content-docs',
151165
{
@@ -156,14 +170,6 @@ module.exports = {
156170
editUrl,
157171
},
158172
],
159-
[
160-
'@docusaurus/plugin-content-blog',
161-
{
162-
path: 'blog',
163-
blogTitle: 'Yew Blog',
164-
editUrl,
165-
},
166-
],
167173
[
168174
'client-redirects',
169175
{
@@ -177,12 +183,5 @@ module.exports = {
177183
],
178184
},
179185
],
180-
[
181-
'@easyops-cn/docusaurus-search-local',
182-
{
183-
hashed: true,
184-
indexBlog: false,
185-
},
186-
],
187186
],
188187
}

0 commit comments

Comments
 (0)