Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved Context API docs #3409

Merged
merged 2 commits into from
Sep 23, 2023
Merged

Conversation

its-the-shrimp
Copy link
Contributor

@its-the-shrimp its-the-shrimp commented Sep 23, 2023

Description

  1. Added an example of how to produce context updates from a struct component
  2. Updated the docs of use_context to point to the actual Yew Docs page about using contexts.
  3. Synchronised examples of usage of use_context here and here

Fixes #2943, fixes #2927

Checklist

  • I have reviewed my own code
  • I have added tests

@github-actions
Copy link

github-actions bot commented Sep 23, 2023

Size Comparison

examples master (KB) pull request (KB) diff (KB) diff (%)
async_clock 102.409 102.409 0 0.000%
boids 175.650 175.650 0 0.000%
communication_child_to_parent 95.304 95.304 0 0.000%
communication_grandchild_with_grandparent 109.040 109.040 0 0.000%
communication_grandparent_to_grandchild 105.716 105.716 0 0.000%
communication_parent_to_child 92.782 92.782 0 0.000%
contexts 110.994 113.452 +2.458 +2.215%
counter 89.196 89.196 0 0.000%
counter_functional 89.932 89.932 0 0.000%
dyn_create_destroy_apps 92.369 92.369 0 0.000%
file_upload 103.526 103.526 0 0.000%
function_memory_game 174.630 174.630 0 0.000%
function_router 353.013 353.013 0 0.000%
function_todomvc 163.523 163.523 0 0.000%
futures 227.415 227.415 0 0.000%
game_of_life 112.359 112.359 0 0.000%
immutable 188.779 188.779 0 0.000%
inner_html 85.980 85.980 0 0.000%
js_callback 113.370 113.370 0 0.000%
keyed_list 201.298 201.298 0 0.000%
mount_point 89.188 89.188 0 0.000%
nested_list 114.602 114.602 0 0.000%
node_refs 96.289 96.289 0 0.000%
password_strength 1583.745 1583.745 0 0.000%
portals 98.358 98.358 0 0.000%
router 319.013 319.013 0 0.000%
simple_ssr 144.150 144.150 0 0.000%
ssr_router 390.805 390.805 0 0.000%
suspense 118.896 118.896 0 0.000%
timer 91.795 91.795 0 0.000%
timer_functional 100.468 100.468 0 0.000%
todomvc 143.679 143.679 0 0.000%
two_apps 89.896 89.896 0 0.000%
web_worker_fib 138.875 138.875 0 0.000%
web_worker_prime 190.399 190.399 0 0.000%
webgl 88.553 88.553 0 0.000%

⚠️ The following example has changed its size significantly:

examples master (KB) pull request (KB) diff (KB) diff (%)
contexts 110.994 113.452 +2.458 +2.215%

@github-actions
Copy link

github-actions bot commented Sep 23, 2023

Visit the preview URL for this PR (updated for commit 2fb5d4c):

https://yew-rs--pr3409-fix-context-api-docs-iyn2cc5p.web.app

(expires Sat, 30 Sep 2023 11:59:53 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

@github-actions
Copy link

Benchmark - SSR

Yew Master

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 422.911 424.146 423.365 0.437
Hello World 10 779.589 780.474 780.005 0.326
Function Router 10 2505.927 2527.189 2515.800 6.680
Concurrent Task 10 1008.666 1011.097 1010.296 0.741
Many Providers 10 1792.772 1825.000 1803.041 10.036

Pull Request

Benchmark Round Min (ms) Max (ms) Mean (ms) Standard Deviation
Baseline 10 422.941 424.557 423.978 0.481
Hello World 10 779.381 786.896 781.507 2.845
Function Router 10 2505.288 2519.078 2512.981 4.757
Concurrent Task 10 1008.970 1014.338 1010.922 1.445
Many Providers 10 1770.582 1813.011 1780.058 12.755

Copy link
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for PR!

@ranile ranile enabled auto-merge (squash) September 23, 2023 12:41
Copy link
Member

@cecton cecton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lot of minor comments but LGTM

Comment on lines +101 to +102

/// App theme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Unnecessary white space added. Really not important)

Comment on lines +112 to +115
let ctx = use_state(|| Theme {
foreground: "#000000".to_owned(),
background: "#eeeeee".to_owned(),
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this one have the same issue than #3396?

Comment on lines 105 to 106
foreground: String,
background: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably use AttrValue 😁

Comment on lines +128 to +129
/// The toolbar.
/// This component has access to the context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either it's the first sentence (one line) or it's a new paragraph, in which case we need spacing

Suggested change
/// The toolbar.
/// This component has access to the context
/// The toolbar.
///
/// This component has access to the context.
Suggested change
/// The toolbar.
/// This component has access to the context
/// The toolbar. This component has access to the context.

Comment on lines +139 to +141
/// Button placed in `Toolbar`.
/// As this component is a child of `ThemeContextProvider` in the component tree, it also has access
/// to the context.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Button placed in `Toolbar`.
/// As this component is a child of `ThemeContextProvider` in the component tree, it also has access
/// to the context.
/// Button placed in `Toolbar`.
///
/// As this component is a child of `ThemeContextProvider` in the component tree, it also has access
/// to the context.

@ranile ranile merged commit a2786b1 into yewstack:master Sep 23, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add documentation on how to create a Context Producer in a struct Component Inconsistent context examples
3 participants