repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/web_worker_fib/src/bin/worker.rs | examples/web_worker_fib/src/bin/worker.rs | use yew_agent::Registrable;
use yew_worker_fib::agent::{FibonacciTask, Postcard};
fn main() {
FibonacciTask::registrar().encoding::<Postcard>().register();
}
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/two_apps/src/main.rs | examples/two_apps/src/main.rs | use yew::html::Scope;
use yew::{html, AppHandle, Component, Context, Html};
pub enum Msg {
SetOpposite(Scope<App>),
SendToOpposite(String),
SetTitle(String),
}
pub struct App {
opposite: Option<Scope<App>>,
selector: &'static str,
title: String,
}
impl Component for App {
type Message = M... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/keyed_list/src/random.rs | examples/keyed_list/src/random.rs | use rand::distr::Bernoulli;
use rand::Rng;
/// `0 <= p <= 1`
pub fn chance(p: f64) -> bool {
let d = Bernoulli::new(p).unwrap();
rand::rng().sample(d)
}
/// half-open: [min, max)
pub fn range_exclusive(min: usize, max: usize) -> usize {
rand::rng().random_range(min..max)
}
pub fn choose_two_distinct_mut<... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/keyed_list/src/person.rs | examples/keyed_list/src/person.rs | use std::rc::Rc;
use fake::faker::address::raw::*;
use fake::faker::name::raw::*;
use fake::locales::*;
use fake::Fake;
use yew::{html, Component, Context, Html, Properties};
use crate::random;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PersonInfo {
pub id: usize,
pub name: Rc<str>,
pub address: R... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/keyed_list/src/main.rs | examples/keyed_list/src/main.rs | use std::cell::RefCell;
use instant::Instant;
use person::PersonType;
use web_sys::{HtmlElement, HtmlInputElement};
use yew::html::Scope;
use yew::prelude::*;
mod person;
mod random;
pub enum Msg {
CreatePersons(usize),
CreatePersonsPrepend(usize),
ChangeRatio(f64),
DeletePersonById(usize),
Delet... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/state.rs | examples/function_todomvc/src/state.rs | use std::rc::Rc;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumIter};
use yew::html::IntoPropValue;
use yew::prelude::*;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct State {
pub entries: Vec<Entry>,
pub filter: Filter,
}
#[derive(Clone, Debug, Serialize, De... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/hooks.rs | examples/function_todomvc/src/hooks.rs | pub mod use_bool_toggle;
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/main.rs | examples/function_todomvc/src/main.rs | use gloo::storage::{LocalStorage, Storage};
use state::{Action, Filter, State};
use strum::IntoEnumIterator;
use yew::prelude::*;
mod components;
mod hooks;
mod state;
use components::entry::Entry as EntryItem;
use components::filter::Filter as FilterItem;
use components::header_input::HeaderInput;
use components::in... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/components.rs | examples/function_todomvc/src/components.rs | pub mod entry;
pub mod filter;
pub mod header_input;
pub mod info_footer;
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/hooks/use_bool_toggle.rs | examples/function_todomvc/src/hooks/use_bool_toggle.rs | use std::ops::Deref;
use std::rc::Rc;
use yew::prelude::*;
#[derive(Clone)]
pub struct UseBoolToggleHandle {
value: UseStateHandle<bool>,
toggle: Rc<dyn Fn()>,
}
impl UseBoolToggleHandle {
pub fn toggle(self) {
(self.toggle)()
}
}
impl Deref for UseBoolToggleHandle {
type Target = bool;
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/components/info_footer.rs | examples/function_todomvc/src/components/info_footer.rs | use yew::prelude::*;
#[function_component(InfoFooter)]
pub fn info_footer() -> Html {
html! {
<footer class="info">
<p>{ "Double-click to edit a todo" }</p>
<p>{ "Written by " }<a href="https://github.com/Yoroshikun/" target="_blank">{ "Drew Hutton <Yoroshi>" }</a></p>
<... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/components/filter.rs | examples/function_todomvc/src/components/filter.rs | use yew::prelude::*;
use crate::state::Filter as FilterEnum;
#[derive(PartialEq, Properties)]
pub struct FilterProps {
pub filter: FilterEnum,
pub selected: bool,
pub onset_filter: Callback<FilterEnum>,
}
#[function_component]
pub fn Filter(props: &FilterProps) -> Html {
let filter = props.filter;
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/components/header_input.rs | examples/function_todomvc/src/components/header_input.rs | use web_sys::HtmlInputElement;
use yew::events::KeyboardEvent;
use yew::prelude::*;
#[derive(PartialEq, Properties, Clone)]
pub struct HeaderInputProps {
pub onadd: Callback<String>,
}
#[function_component(HeaderInput)]
pub fn header_input(props: &HeaderInputProps) -> Html {
let onkeypress = {
let ona... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_todomvc/src/components/entry.rs | examples/function_todomvc/src/components/entry.rs | use web_sys::{HtmlInputElement, MouseEvent};
use yew::events::{Event, FocusEvent, KeyboardEvent};
use yew::prelude::*;
use crate::hooks::use_bool_toggle::use_bool_toggle;
use crate::state::Entry as Item;
#[derive(PartialEq, Properties, Clone)]
pub struct EntryProps {
pub entry: Item,
pub ontoggle: Callback<us... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_delayed_input/src/main.rs | examples/function_delayed_input/src/main.rs | use std::time::Duration;
use gloo_timers::callback::Timeout;
use web_sys::wasm_bindgen::JsCast;
use web_sys::HtmlInputElement;
use yew::*;
#[component]
fn App() -> Html {
#[derive(PartialEq, Default, Clone)]
enum Search {
#[default]
Idle,
Fetching(AttrValue),
Fetched(AttrValue)... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/async_clock/src/services.rs | examples/async_clock/src/services.rs | use std::time::Duration;
use chrono::{DateTime, Local};
use futures::{Stream, StreamExt};
use gloo_net::http::Request;
use yew::platform::pinned::mpsc::UnboundedSender;
use yew::platform::spawn_local;
use yew::platform::time::{interval, sleep};
use yew::{AttrValue, Callback};
const ONE_SEC: Duration = Duration::from_... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/async_clock/src/main.rs | examples/async_clock/src/main.rs | use chrono::{DateTime, Local};
use futures::{FutureExt, StreamExt};
use services::compute_fun_score;
use yew::platform::pinned::mpsc::UnboundedSender;
use yew::{html, AttrValue, Component, Context, Html};
use crate::services::{emit_jokes, initialize_atomic_clocks, stream_time};
mod services;
/// The AsyncComponent d... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/app.rs | examples/function_router/src/app.rs | use std::collections::HashMap;
use yew::prelude::*;
use yew_router::history::{AnyHistory, History, MemoryHistory};
use yew_router::prelude::*;
use crate::components::nav::Nav;
use crate::pages::author::Author;
use crate::pages::author_list::AuthorList;
use crate::pages::home::Home;
use crate::pages::page_not_found::P... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/lib.rs | examples/function_router/src/lib.rs | // # Implementation Note:
//
// This example is also used to demonstrate SSR hydration.
// It is important to follow the following rules when updating this example:
//
// - Do not use usize for randomised contents.
//
// usize differs in memory size in 32-bit and 64-bit targets (wasm32 is a 32-bit target family.)
// ... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/content.rs | examples/function_router/src/content.rs | use crate::generator::{Generated, Generator};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Author {
pub seed: u32,
pub name: String,
pub keywords: Vec<String>,
pub image_url: String,
}
impl Generated for Author {
fn generate(gen: &mut Generator) -> Self {
let name = gen.human_name();
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/generator.rs | examples/function_router/src/generator.rs | use lipsum::MarkovChain;
use once_cell::sync::Lazy;
use rand::distr::Bernoulli;
use rand::rngs::StdRng;
use rand::seq::IteratorRandom;
use rand::{Rng, SeedableRng};
const KEYWORDS: &str = include_str!("../data/keywords.txt");
const SYLLABLES: &str = include_str!("../data/syllables.txt");
const YEW_CONTENT: &str = incl... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/pages/page_not_found.rs | examples/function_router/src/pages/page_not_found.rs | use yew::prelude::*;
#[function_component]
pub fn PageNotFound() -> Html {
html! {
<section class="hero is-danger is-bold is-large">
<div class="hero-body">
<div class="container">
<h1 class="title">
{ "Page not found" }
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/pages/author.rs | examples/function_router/src/pages/author.rs | use yew::prelude::*;
use crate::components::author_card::AuthorState;
use crate::content;
use crate::generator::Generated;
#[derive(Clone, Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub seed: u32,
}
#[function_component]
pub fn Author(props: &Props) -> Html {
let seed = props.seed;
let author... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/pages/home.rs | examples/function_router/src/pages/home.rs | use yew::prelude::*;
#[function_component]
fn InfoTiles() -> Html {
html! {
<>
<div class="tile is-parent">
<div class="tile is-child box">
<p class="title">{ "What are yews?" }</p>
<p class="subtitle">{ "Everything you need to know!" }</p... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/pages/mod.rs | examples/function_router/src/pages/mod.rs | pub mod author;
pub mod author_list;
pub mod home;
pub mod page_not_found;
pub mod post;
pub mod post_list;
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/pages/post.rs | examples/function_router/src/pages/post.rs | use std::rc::Rc;
use content::PostPart;
use yew::prelude::*;
use yew_router::prelude::*;
use crate::generator::Generated;
use crate::{content, Route};
#[derive(Clone, Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub seed: u32,
}
#[derive(PartialEq, Eq, Debug)]
pub struct PostState {
pub inner: cont... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/pages/post_list.rs | examples/function_router/src/pages/post_list.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::components::pagination::{PageQuery, Pagination};
use crate::components::post_card::PostCard;
use crate::Route;
const ITEMS_PER_PAGE: u32 = 10;
const TOTAL_PAGES: u32 = u32::MAX / ITEMS_PER_PAGE;
#[function_component]
pub fn PostList() -> Html {
let loca... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/pages/author_list.rs | examples/function_router/src/pages/author_list.rs | use rand::{distr, Rng};
use yew::prelude::*;
use crate::components::author_card::AuthorCard;
use crate::components::progress_delay::ProgressDelay;
/// Amount of milliseconds to wait before showing the next set of authors.
const CAROUSEL_DELAY_MS: u32 = 15000;
#[function_component]
pub fn AuthorList() -> Html {
l... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/components/progress_delay.rs | examples/function_router/src/components/progress_delay.rs | use std::rc::Rc;
use gloo::timers::callback::Interval;
use instant::Instant;
use yew::prelude::*;
const RESOLUTION: u32 = 500;
const MIN_INTERVAL_MS: u32 = 50;
pub enum ValueAction {
Tick,
Props(Props),
}
#[derive(Clone, PartialEq, Debug)]
pub struct ValueState {
start: Instant,
value: f64,
pr... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/components/post_card.rs | examples/function_router/src/components/post_card.rs | use std::rc::Rc;
use yew::prelude::*;
use yew_router::components::Link;
use crate::content::PostMeta;
use crate::generator::Generated;
use crate::Route;
#[derive(Clone, Debug, PartialEq, Eq, Properties)]
pub struct Props {
pub seed: u32,
}
#[derive(PartialEq, Eq, Debug)]
pub struct PostMetaState {
inner: Po... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/components/author_card.rs | examples/function_router/src/components/author_card.rs | use std::rc::Rc;
use yew::prelude::*;
use yew_router::prelude::*;
use crate::content::Author;
use crate::generator::Generated;
use crate::Route;
#[derive(Clone, Debug, PartialEq, Eq, Properties)]
pub struct Props {
pub seed: u32,
}
#[derive(PartialEq, Eq, Debug)]
pub struct AuthorState {
pub inner: Author,
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/components/mod.rs | examples/function_router/src/components/mod.rs | pub mod author_card;
pub mod nav;
pub mod pagination;
pub mod post_card;
pub mod progress_delay;
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/components/nav.rs | examples/function_router/src/components/nav.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::Route;
#[function_component]
pub fn Nav() -> Html {
let navbar_active = use_state_eq(|| false);
let toggle_navbar = {
let navbar_active = navbar_active.clone();
Callback::from(move |_| {
navbar_active.set(!*navbar_active... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/components/pagination.rs | examples/function_router/src/components/pagination.rs | use std::ops::Range;
use serde::{Deserialize, Serialize};
use yew::prelude::*;
use yew_router::prelude::*;
use crate::Route;
const ELLIPSIS: &str = "\u{02026}";
#[derive(Serialize, Deserialize, PartialEq, Eq, Clone, Debug)]
pub struct PageQuery {
pub page: u32,
}
#[derive(Clone, Debug, PartialEq, Eq, Propertie... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/function_router/src/bin/function_router.rs | examples/function_router/src/bin/function_router.rs | pub use function_router::*;
fn main() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
yew::Renderer::<App>::new().render();
}
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/todomvc/src/state.rs | examples/todomvc/src/state.rs | use serde_derive::{Deserialize, Serialize};
use strum_macros::{Display, EnumIter};
use yew::html::IntoPropValue;
use yew::prelude::*;
#[derive(Debug, Serialize, Deserialize)]
pub struct State {
pub entries: Vec<Entry>,
pub filter: Filter,
pub edit_value: String,
}
impl State {
pub fn new(entries: Vec<... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/todomvc/src/main.rs | examples/todomvc/src/main.rs | use gloo::storage::{LocalStorage, Storage};
use state::{Entry, Filter, State};
use strum::IntoEnumIterator;
use web_sys::HtmlInputElement as InputElement;
use yew::events::{FocusEvent, KeyboardEvent};
use yew::html::Scope;
use yew::{classes, html, Classes, Component, Context, Html, NodeRef, TargetCast};
mod state;
co... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/communication_grandparent_to_grandchild/src/grandparent.rs | examples/communication_grandparent_to_grandchild/src/grandparent.rs | use super::*;
/// Our top-level (grandparent) component that holds a reference to the shared state.
pub struct GrandParent {
state: Rc<AppState>,
}
pub enum Msg {
ButtonClick,
}
impl Component for GrandParent {
type Message = Msg;
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/communication_grandparent_to_grandchild/src/child.rs | examples/communication_grandparent_to_grandchild/src/child.rs | use super::*;
/// The `Child` component is the child of the `Parent` component, and will receive updates from the
/// grandparent using the context.
pub struct Child {
state: Rc<AppState>,
_listener: ContextHandle<Rc<AppState>>,
}
pub enum ChildMsg {
ContextChanged(Rc<AppState>),
}
impl Component for Chi... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/communication_grandparent_to_grandchild/src/main.rs | examples/communication_grandparent_to_grandchild/src/main.rs | use std::rc::Rc;
use child::Child;
use grandparent::GrandParent;
use parent::Parent;
mod child;
mod grandparent;
mod parent;
use yew::{function_component, html, Component, Context, ContextHandle, ContextProvider, Html};
/// This is the shared state between the parent and child components.
#[derive(Clone, Eq, Partia... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/communication_grandparent_to_grandchild/src/parent.rs | examples/communication_grandparent_to_grandchild/src/parent.rs | use super::*;
/// The `Parent` component is the parent of the `Child` component. It has no logic, and is here to
/// show there is no direct relation between grandchild and grandparent.
#[function_component]
pub fn Parent() -> Html {
html! {
<div class="parent-body">
<div class="parent-tag">
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/communication_parent_to_child/src/child.rs | examples/communication_parent_to_child/src/child.rs | use super::*;
/// The `Child` component is the child of the `Parent` component, and will receive updates from the
/// parent using properties.
pub struct Child;
#[derive(Clone, Eq, PartialEq, Properties)]
pub struct ChildProps {
pub clicks: u32,
}
impl Component for Child {
type Message = ();
type Proper... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/communication_parent_to_child/src/main.rs | examples/communication_parent_to_child/src/main.rs | use child::Child;
use parent::Parent;
use yew::{html, Component, Context, Html, Properties};
mod child;
mod parent;
fn main() {
yew::Renderer::<Parent>::new().render();
}
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/communication_parent_to_child/src/parent.rs | examples/communication_parent_to_child/src/parent.rs | use super::*;
/// The `Parent` component holds some state that is passed down to the children.
pub struct Parent {
/// The total number of clicks received
nr_of_clicks: u32,
}
pub enum Msg {
ButtonClick,
}
impl Component for Parent {
type Message = Msg;
type Properties = ();
fn create(_ctx: ... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/immutable/src/array.rs | examples/immutable/src/array.rs | use implicit_clone::unsync::*;
use wasm_bindgen::{JsCast, UnwrapThrowExt};
use web_sys::{HtmlInputElement, KeyboardEvent};
use yew::prelude::*;
#[derive(Properties, PartialEq)]
struct FolksViewProps {
folks: IArray<IString>,
}
#[function_component(FolksView)]
fn folks_view(props: &FolksViewProps) -> Html {
ht... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/immutable/src/string.rs | examples/immutable/src/string.rs | use implicit_clone::unsync::*;
use wasm_bindgen::{JsCast, UnwrapThrowExt};
use web_sys::{HtmlInputElement, InputEvent};
use yew::prelude::*;
#[derive(Properties, PartialEq)]
struct DisplayProps {
name: IString,
}
#[function_component]
fn Display(props: &DisplayProps) -> Html {
html! {
<p>{"Hello "}{&p... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/immutable/src/map.rs | examples/immutable/src/map.rs | use implicit_clone::unsync::*;
use wasm_bindgen::{JsCast, UnwrapThrowExt};
use web_sys::{HtmlInputElement, KeyboardEvent};
use yew::prelude::*;
#[derive(Properties, PartialEq)]
struct DisplayProps {
values: IMap<u32, IString>,
}
#[function_component]
fn Display(props: &DisplayProps) -> Html {
html! {
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/immutable/src/main.rs | examples/immutable/src/main.rs | mod array;
mod map;
mod string;
use yew::prelude::*;
use self::array::*;
use self::map::*;
use self::string::*;
#[function_component]
fn App() -> Html {
html! {
<>
<h1>{ "IString Example" }</h1>
<StringExample />
<hr/>
<h1>{ "IArray Example" }</h1>
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/web_worker_prime/src/lib.rs | examples/web_worker_prime/src/lib.rs | pub mod agent;
use agent::{ControlSignal, PrimeReactor};
use yew::prelude::*;
use yew_agent::reactor::{use_reactor_subscription, ReactorProvider};
#[function_component]
fn Main() -> Html {
let prime_sub = use_reactor_subscription::<PrimeReactor>();
let started = use_state_eq(|| false);
let skip_len = use_s... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/web_worker_prime/src/agent.rs | examples/web_worker_prime/src/agent.rs | use std::time::Duration;
use futures::sink::SinkExt;
use futures::{FutureExt, StreamExt};
use serde::{Deserialize, Serialize};
use yew::platform::time::sleep;
use yew_agent::prelude::*;
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum ControlSignal {
Start,
Stop,
}
#[reactor]
pub async fn Pri... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/web_worker_prime/src/bin/app.rs | examples/web_worker_prime/src/bin/app.rs | fn main() {
yew::Renderer::<yew_worker_prime::App>::new().render();
}
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/web_worker_prime/src/bin/worker.rs | examples/web_worker_prime/src/bin/worker.rs | use yew_agent::Registrable;
use yew_worker_prime::agent::PrimeReactor;
fn main() {
PrimeReactor::registrar().register();
}
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/portals/src/main.rs | examples/portals/src/main.rs | use wasm_bindgen::JsCast;
use web_sys::{Element, ShadowRootInit, ShadowRootMode};
use yew::{create_portal, html, Component, Context, Html, NodeRef, Properties};
#[derive(Properties, PartialEq)]
pub struct ShadowDOMProps {
#[prop_or_default]
pub children: Html,
}
pub struct ShadowDOMHost {
host_ref: NodeRe... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/ssr_router/src/lib.rs | examples/ssr_router/src/lib.rs | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false | |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/ssr_router/src/bin/ssr_router_server.rs | examples/ssr_router/src/bin/ssr_router_server.rs | use std::collections::HashMap;
use std::convert::Infallible;
use std::future::Future;
use std::net::SocketAddr;
use std::path::PathBuf;
use axum::body::Body;
use axum::extract::{Query, Request, State};
use axum::handler::HandlerWithoutStateExt;
use axum::http::Uri;
use axum::response::IntoResponse;
use axum::routing::... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/ssr_router/src/bin/ssr_router_hydrate.rs | examples/ssr_router/src/bin/ssr_router_hydrate.rs | use function_router::App;
fn main() {
#[cfg(target_arch = "wasm32")]
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
yew::Renderer::<App>::new().hydrate();
}
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/timer/src/main.rs | examples/timer/src/main.rs | use gloo::console::{self, Timer};
use gloo::timers::callback::{Interval, Timeout};
use yew::prelude::*;
pub enum Msg {
StartTimeout,
StartInterval,
Cancel,
Done,
Tick,
UpdateTime,
}
pub struct App {
time: String,
messages: Vec<AttrValue>,
_standalone: (Interval, Interval),
inte... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/mount_point/src/main.rs | examples/mount_point/src/main.rs | use wasm_bindgen::JsValue;
use web_sys::{
CanvasRenderingContext2d, Document, HtmlCanvasElement, HtmlInputElement, InputEvent,
};
use yew::{html, Component, Context, Html, TargetCast};
pub enum Msg {
UpdateName(String),
}
pub struct App {
name: String,
}
impl Component for App {
type Message = Msg;
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/file_upload/src/main.rs | examples/file_upload/src/main.rs | extern crate base64;
use std::collections::HashMap;
use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use gloo::file::callbacks::FileReader;
use web_sys::{DragEvent, Event, HtmlInputElement};
use yew::html::TargetCast;
use yew::{html, Callback, Component, Context, Html};
pub struct FileDetails {
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/js_callback/trunk_post_build.rs | examples/js_callback/trunk_post_build.rs | use std::fs;
use std::io::{Read, Write};
fn read_env(env: &'static str) -> String {
std::env::var(env).unwrap_or_else(|e| panic!("can't read {} env var: {}", env, e))
}
fn main() {
let stage_dir = read_env("TRUNK_STAGING_DIR");
let mut res = fs::read_dir(format!("{stage_dir}/snippets")).expect("no snippet... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/js_callback/src/bindings.rs | examples/js_callback/src/bindings.rs | use wasm_bindgen::prelude::*;
// https://github.com/rustwasm/wasm-bindgen/issues/3208
#[wasm_bindgen(inline_js = "export function import2(path) { return import(path); }")]
extern "C" {
// this should be in js-sys but is not. see https://github.com/rustwasm/wasm-bindgen/issues/2865
// pub fn import(s: &str) -> ... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/js_callback/src/main.rs | examples/js_callback/src/main.rs | use once_cell::sync::OnceCell;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
use yew::prelude::*;
use yew::suspense::{use_future, SuspensionResult};
mod bindings;
static WASM_BINDGEN_SNIPPETS_PATH: OnceCell<String> = OnceCell::new();
#[function_component]
fn Important() ... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/counter/src/main.rs | examples/counter/src/main.rs | use gloo::console;
use js_sys::Date;
use yew::{html, Component, Context, Html};
// Define the possible messages which can be sent to the component
pub enum Msg {
Increment,
Decrement,
}
pub struct App {
value: i64, // This will store the counter value
}
impl Component for App {
type Message = Msg;
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/webgl/src/main.rs | examples/webgl/src/main.rs | use std::cell::RefCell;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::{window, HtmlCanvasElement, WebGlRenderingContext as GL, WebGlRenderingContext};
use yew::{html, Component, Context, Html, NodeRef};
// Wrap gl in Rc (Arc for multi-threaded) so it can be injected into the re... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/timer_functional/src/main.rs | examples/timer_functional/src/main.rs | use std::rc::Rc;
use gloo::timers::callback::{Interval, Timeout};
use yew::prelude::*;
fn get_current_time() -> String {
let date = js_sys::Date::new_0();
String::from(date.to_locale_time_string("en-US"))
}
enum TimerAction {
Add(&'static str),
Cancel,
SetInterval(Interval),
SetTimeout(Timeou... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/boids/src/simulation.rs | examples/boids/src/simulation.rs | use gloo::timers::callback::Interval;
use yew::{html, Component, Context, Html, Properties};
use crate::boid::Boid;
use crate::math::Vector2D;
use crate::settings::Settings;
pub const SIZE: Vector2D = Vector2D::new(1600.0, 1000.0);
#[derive(Debug)]
pub enum Msg {
Tick,
}
#[derive(Clone, Debug, PartialEq, Proper... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/boids/src/settings.rs | examples/boids/src/settings.rs | use gloo::storage::{LocalStorage, Storage};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct Settings {
/// amount of boids
pub boids: usize,
// time between each simulation tick
pub tick_interval_ms: u64,
/// view distance of a boid
pub... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/boids/src/math.rs | examples/boids/src/math.rs | use std::f64::consts::{FRAC_PI_3, PI};
use std::iter::Sum;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
// at the time of writing the TAU constant is still unstable
pub const TAU: f64 = 2.0 * PI;
pub const FRAC_TAU_3: f64 = 2.0 * FRAC_PI_3;
/// Get the smaller signed angle from... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/boids/src/slider.rs | examples/boids/src/slider.rs | use std::cell::Cell;
use web_sys::HtmlInputElement;
use yew::events::InputEvent;
use yew::{html, Callback, Component, Context, Html, Properties, TargetCast};
thread_local! {
static SLIDER_ID: Cell<usize> = Cell::default();
}
fn next_slider_id() -> usize {
SLIDER_ID.with(|cell| cell.replace(cell.get() + 1))
}
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/boids/src/boid.rs | examples/boids/src/boid.rs | use std::fmt::Write;
use std::iter;
use rand::Rng;
use yew::{html, Html};
use crate::math::{self, Mean, Vector2D, WeightedMean};
use crate::settings::Settings;
use crate::simulation::SIZE;
#[derive(Clone, Debug, PartialEq)]
pub struct Boid {
position: Vector2D,
velocity: Vector2D,
radius: f64,
hue: f... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/boids/src/main.rs | examples/boids/src/main.rs | use settings::Settings;
use simulation::Simulation;
use slider::Slider;
use yew::html::Scope;
use yew::{html, Component, Context, Html};
mod boid;
mod math;
mod settings;
mod simulation;
mod slider;
pub enum Msg {
ChangeSettings(Settings),
ResetSettings,
RestartSimulation,
TogglePause,
}
pub struct A... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/simple_ssr/src/lib.rs | examples/simple_ssr/src/lib.rs | use serde::{Deserialize, Serialize};
use uuid::Uuid;
use yew::prelude::*;
#[derive(Serialize, Deserialize)]
struct UuidResponse {
uuid: Uuid,
}
#[cfg(feature = "ssr")]
async fn fetch_uuid() -> Uuid {
// reqwest works for both non-wasm and wasm targets.
let resp = reqwest::get("https://httpbin.org/uuid").a... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/simple_ssr/src/bin/simple_ssr_server.rs | examples/simple_ssr/src/bin/simple_ssr_server.rs | use std::error::Error;
use std::path::PathBuf;
use bytes::Bytes;
use clap::Parser;
use futures::stream::{self, Stream, StreamExt};
use simple_ssr::App;
use warp::Filter;
type BoxedError = Box<dyn Error + Send + Sync + 'static>;
/// A basic example
#[derive(Parser, Debug)]
struct Opt {
/// the "dist" created by t... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/simple_ssr/src/bin/simple_ssr_hydrate.rs | examples/simple_ssr/src/bin/simple_ssr_hydrate.rs | use simple_ssr::App;
fn main() {
#[cfg(target_arch = "wasm32")]
wasm_logger::init(wasm_logger::Config::new(log::Level::Trace));
yew::Renderer::<App>::new().hydrate();
}
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/futures/src/markdown.rs | examples/futures/src/markdown.rs | /// Original author of this code is [Nathan Ringo](https://github.com/remexre)
/// Source: https://github.com/acmumn/mentoring/blob/master/web-client/src/view/markdown.rs
use pulldown_cmark::{Alignment, CodeBlockKind, Event, Options, Parser, Tag, TagEnd};
use yew::virtual_dom::{VNode, VTag, VText};
use yew::Html;
stru... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/futures/src/main.rs | examples/futures/src/main.rs | use std::error::Error;
use std::fmt::{self, Debug, Display, Formatter};
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
use web_sys::{Request, RequestInit, RequestMode, Response};
use yew::{html, Component, Context, Html};
mod markdown;
const MARKDOWN_URL: &str = "https://... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/nested_list/src/app.rs | examples/nested_list/src/app.rs | use std::iter;
use yew::prelude::*;
use super::header::ListHeader;
use super::item::ListItem;
use super::list::List;
use super::{Hovered, WeakComponentLink};
pub enum Msg {
Hover(Hovered),
}
pub struct App {
hovered: Hovered,
list_link: WeakComponentLink<List>,
sub_list_link: WeakComponentLink<List>... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/nested_list/src/list.rs | examples/nested_list/src/list.rs | use implicit_clone::unsync::IArray;
use yew::prelude::*;
use yew::virtual_dom::VChild;
use crate::header::ListHeader;
use crate::item::ListItem;
use crate::{Hovered, WeakComponentLink};
pub enum Msg {
HeaderClick,
}
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
#[prop_or_default]
pub header:... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/nested_list/src/header.rs | examples/nested_list/src/header.rs | use yew::prelude::*;
use super::list::{List, Msg as ListMsg};
use super::{Hovered, WeakComponentLink};
#[derive(Clone, PartialEq, Properties)]
pub struct Props {
pub on_hover: Callback<Hovered>,
pub text: String,
pub list_link: WeakComponentLink<List>,
}
pub struct ListHeader;
impl Component for ListHea... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/nested_list/src/main.rs | examples/nested_list/src/main.rs | mod app;
mod header;
mod item;
mod list;
use std::cell::RefCell;
use std::fmt;
use std::ops::Deref;
use std::rc::Rc;
use yew::html::{ImplicitClone, IntoPropValue, Scope};
use yew::prelude::*;
pub struct WeakComponentLink<COMP: Component>(Rc<RefCell<Option<Scope<COMP>>>>);
impl<COMP: Component> Clone for WeakCompone... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/nested_list/src/item.rs | examples/nested_list/src/item.rs | use yew::prelude::*;
use crate::Hovered;
#[derive(PartialEq, Clone, Properties)]
pub struct Props {
#[prop_or_default]
pub hide: bool,
pub on_hover: Callback<Hovered>,
pub name: AttrValue,
#[prop_or_default]
pub children: Children,
}
pub struct ListItem;
impl Component for ListItem {
typ... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/node_refs/src/main.rs | examples/node_refs/src/main.rs | mod input;
use input::InputComponent;
use web_sys::HtmlInputElement;
use yew::prelude::*;
pub enum Msg {
HoverIndex(usize),
Submit,
}
pub struct App {
refs: Vec<NodeRef>,
focus_index: usize,
email_error: String,
password_error: String,
}
impl App {
fn apply_focus(&self) {
if let S... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/node_refs/src/input.rs | examples/node_refs/src/input.rs | use yew::prelude::*;
pub enum Msg {
Hover,
}
#[derive(Properties, PartialEq)]
pub struct Props {
pub on_hover: Callback<()>,
pub placeholder: AttrValue,
pub input_ref: NodeRef,
}
pub struct InputComponent;
impl Component for InputComponent {
type Message = Msg;
type Properties = Props;
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/dyn_create_destroy_apps/src/counter.rs | examples/dyn_create_destroy_apps/src/counter.rs | use gloo::console;
use gloo::timers::callback::Interval;
use yew::prelude::*;
pub struct CounterModel {
counter: usize,
_interval: Interval,
}
#[derive(Clone, Properties, PartialEq)]
pub struct CounterProps {
pub destroy_callback: Callback<()>,
}
pub enum CounterMessage {
Tick,
}
impl Component for ... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/dyn_create_destroy_apps/src/main.rs | examples/dyn_create_destroy_apps/src/main.rs | use gloo::utils::document;
use slab::Slab;
use web_sys::Element;
use yew::prelude::*;
mod counter;
use counter::{CounterModel, CounterProps};
// Define the possible messages which can be sent to the component
pub enum Msg {
// Spawns a new instance of the CounterModel app
SpawnCounterAppInstance,
// Dest... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/wasi_ssr_module/src/router.rs | examples/wasi_ssr_module/src/router.rs | use yew::prelude::*;
use yew_router::prelude::*;
#[derive(Routable, PartialEq, Eq, Clone, Debug)]
pub enum Route {
#[at("/")]
Portal,
#[at("/t/:id")]
Thread { id: String },
#[not_found]
#[at("/404")]
NotFound,
}
pub fn switch(routes: Route) -> Html {
match routes {
Route::Por... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/wasi_ssr_module/src/main.rs | examples/wasi_ssr_module/src/main.rs | #![allow(unused_imports)]
#![allow(non_snake_case)]
mod router;
use anyhow::Result;
use router::{switch, Route};
use yew::prelude::*;
use yew::LocalServerRenderer;
#[function_component]
fn Content() -> Html {
use yew_router::prelude::*;
html! {
<>
<h1>{"Yew WASI SSR demo"}</h1>
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/content.rs | examples/router/src/content.rs | use crate::generator::{Generated, Generator};
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Author {
pub seed: u64,
pub name: String,
pub keywords: Vec<String>,
pub image_url: String,
}
impl Generated for Author {
fn generate(gen: &mut Generator) -> Self {
let name = gen.human_name();
... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/generator.rs | examples/router/src/generator.rs | use lipsum::MarkovChain;
use once_cell::sync::Lazy;
use rand::distr::Bernoulli;
use rand::rngs::SmallRng;
use rand::seq::IteratorRandom;
use rand::{Rng, SeedableRng};
const KEYWORDS: &str = include_str!("../data/keywords.txt");
const SYLLABLES: &str = include_str!("../data/syllables.txt");
const YEW_CONTENT: &str = in... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/main.rs | examples/router/src/main.rs | use yew::prelude::*;
use yew_router::prelude::*;
mod components;
mod content;
mod generator;
mod pages;
use pages::author::Author;
use pages::author_list::AuthorList;
use pages::home::Home;
use pages::page_not_found::PageNotFound;
use pages::post::Post;
use pages::post_list::PostList;
use yew::html::Scope;
#[derive(R... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/pages/page_not_found.rs | examples/router/src/pages/page_not_found.rs | use yew::prelude::*;
pub struct PageNotFound;
impl Component for PageNotFound {
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
Self
}
fn view(&self, _ctx: &Context<Self>) -> Html {
html! {
<section class="hero is-danger is-bold is-l... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/pages/author.rs | examples/router/src/pages/author.rs | use yew::prelude::*;
use crate::content;
use crate::generator::Generated;
#[derive(Clone, Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub seed: u64,
}
pub struct Author {
author: content::Author,
}
impl Component for Author {
type Message = ();
type Properties = Props;
fn create(ctx: &... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/pages/home.rs | examples/router/src/pages/home.rs | use yew::prelude::*;
pub struct Home;
impl Component for Home {
type Message = ();
type Properties = ();
fn create(_ctx: &Context<Self>) -> Self {
Self
}
fn view(&self, _ctx: &Context<Self>) -> Html {
html! {
<div class="tile is-ancestor is-vertical">
<... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/pages/mod.rs | examples/router/src/pages/mod.rs | pub mod author;
pub mod author_list;
pub mod home;
pub mod page_not_found;
pub mod post;
pub mod post_list;
| rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/pages/post.rs | examples/router/src/pages/post.rs | use content::PostPart;
use yew::prelude::*;
use yew_router::prelude::*;
use crate::generator::Generated;
use crate::{content, Route};
#[derive(Clone, Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub seed: u64,
}
pub struct Post {
post: content::Post,
}
impl Component for Post {
type Message = ()... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/pages/post_list.rs | examples/router/src/pages/post_list.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::components::pagination::{PageQuery, Pagination};
use crate::components::post_card::PostCard;
use crate::Route;
const ITEMS_PER_PAGE: u64 = 10;
const TOTAL_PAGES: u64 = u64::MAX / ITEMS_PER_PAGE;
pub enum Msg {
PageUpdated,
}
pub struct PostList {
p... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/pages/author_list.rs | examples/router/src/pages/author_list.rs | use rand::{distr, Rng};
use yew::prelude::*;
use crate::components::author_card::AuthorCard;
use crate::components::progress_delay::ProgressDelay;
/// Amount of milliseconds to wait before showing the next set of authors.
const CAROUSEL_DELAY_MS: u64 = 15000;
pub enum Msg {
NextAuthors,
}
pub struct AuthorList ... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/components/progress_delay.rs | examples/router/src/components/progress_delay.rs | use gloo::timers::callback::Interval;
use instant::Instant;
use yew::prelude::*;
const RESOLUTION: u64 = 500;
const MIN_INTERVAL_MS: u64 = 50;
pub enum Msg {
Tick,
}
#[derive(Clone, Debug, PartialEq, Properties)]
pub struct Props {
pub duration_ms: u64,
pub on_complete: Callback<()>,
#[prop_or_defaul... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/components/post_card.rs | examples/router/src/components/post_card.rs | use yew::prelude::*;
use yew_router::components::Link;
use crate::content::PostMeta;
use crate::generator::Generated;
use crate::Route;
#[derive(Clone, Debug, PartialEq, Eq, Properties)]
pub struct Props {
pub seed: u64,
}
pub struct PostCard {
post: PostMeta,
}
impl Component for PostCard {
type Message... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
yewstack/yew | https://github.com/yewstack/yew/blob/2019f4577cbdcd389b34973fdec3164be3af941a/examples/router/src/components/author_card.rs | examples/router/src/components/author_card.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::content::Author;
use crate::generator::Generated;
use crate::Route;
#[derive(Clone, Debug, PartialEq, Eq, Properties)]
pub struct Props {
pub seed: u64,
}
pub struct AuthorCard {
author: Author,
}
impl Component for AuthorCard {
type Message = (... | rust | Apache-2.0 | 2019f4577cbdcd389b34973fdec3164be3af941a | 2026-01-04T15:33:05.007302Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.