chore: rename ctx to cx
This commit is contained in:
1 parent
23c14078bb
commit
81382e7044
99 files changed
+789
-664
No files matched your search
@@ -1,7 +1,7 @@
|
||||
use dioxus_ssr::prelude::*;
|
||||
|
||||
pub static Blog: FC<()> = |ctx| {
|
||||
rsx! { in ctx,
|
||||
pub static Blog: FC<()> = |cx| {
|
||||
rsx! { in cx,
|
||||
div {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use dioxus_ssr::prelude::*;
|
||||
|
||||
pub static Community: FC<()> = |ctx| {
|
||||
rsx! { in ctx,
|
||||
pub static Community: FC<()> = |cx| {
|
||||
rsx! { in cx,
|
||||
div {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use dioxus_ssr::prelude::*;
|
||||
|
||||
pub static Docs: FC<()> = |ctx| {
|
||||
rsx! { in ctx,
|
||||
pub static Docs: FC<()> = |cx| {
|
||||
rsx! { in cx,
|
||||
div {
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const HeroContent: [(&'static str, &'static str); 3] = [
|
||||
|
||||
const SnippetHighlights: &'static str = include_str!("./../snippets.md");
|
||||
|
||||
pub static Home: FC<()> = |ctx| {
|
||||
pub static Home: FC<()> = |cx| {
|
||||
let hero = HeroContent.iter().map(|(title, body)| {
|
||||
rsx! {
|
||||
div {
|
||||
@@ -20,9 +20,9 @@ pub static Home: FC<()> = |ctx| {
|
||||
}
|
||||
}
|
||||
});
|
||||
let snippets: Vec<VNode> = crate::utils::markdown_to_snippet(ctx, SnippetHighlights);
|
||||
let snippets: Vec<VNode> = crate::utils::markdown_to_snippet(cx, SnippetHighlights);
|
||||
|
||||
rsx! { in ctx,
|
||||
rsx! { in cx,
|
||||
div {
|
||||
header {
|
||||
// Hero
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use dioxus_ssr::prelude::*;
|
||||
|
||||
pub static Tutorial: FC<()> = |ctx| {
|
||||
rsx! { in ctx,
|
||||
pub static Tutorial: FC<()> = |cx| {
|
||||
rsx! { in cx,
|
||||
div {
|
||||
|
||||
}
|
||||
|
||||
@@ -24,18 +24,18 @@ fn main() {
|
||||
*/
|
||||
}
|
||||
|
||||
static App: FC<()> = |ctx| {
|
||||
let (url, set_url) = use_state(&ctx, || "");
|
||||
static App: FC<()> = |cx| {
|
||||
let (url, set_url) = use_state(&cx, || "");
|
||||
|
||||
let body = match *url {
|
||||
"community" => rsx!(in ctx, Community {}),
|
||||
"tutorial" => rsx!(in ctx, Tutorial {}),
|
||||
"blog" => rsx!(in ctx, Blog {}),
|
||||
"docs" => rsx!(in ctx, Docs {}),
|
||||
_ => rsx!(in ctx, Home {}),
|
||||
"community" => rsx!(in cx, Community {}),
|
||||
"tutorial" => rsx!(in cx, Tutorial {}),
|
||||
"blog" => rsx!(in cx, Blog {}),
|
||||
"docs" => rsx!(in cx, Docs {}),
|
||||
_ => rsx!(in cx, Home {}),
|
||||
};
|
||||
|
||||
ctx.render(rsx! {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
NavBar {}
|
||||
{body}
|
||||
@@ -44,8 +44,8 @@ static App: FC<()> = |ctx| {
|
||||
})
|
||||
};
|
||||
|
||||
static NavBar: FC<()> = |ctx| {
|
||||
ctx.render(rsx! {
|
||||
static NavBar: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
header {
|
||||
a {
|
||||
href: "/"
|
||||
@@ -99,7 +99,7 @@ static SECTIONS: &[(&str, &[(&str, &str)])] = &[
|
||||
),
|
||||
];
|
||||
|
||||
fn Footer(ctx: Context<()>) -> VNode {
|
||||
fn Footer(cx: Context<()>) -> VNode {
|
||||
let sections = SECTIONS.iter().map(|(section, raw_links)| {
|
||||
let links = raw_links.iter().map(|(link_name, href)| {
|
||||
rsx! (
|
||||
@@ -117,7 +117,7 @@ fn Footer(ctx: Context<()>) -> VNode {
|
||||
}
|
||||
});
|
||||
|
||||
ctx.render(rsx! {
|
||||
cx.render(rsx! {
|
||||
footer {
|
||||
div {
|
||||
div {
|
||||
@@ -136,8 +136,8 @@ fn Footer(ctx: Context<()>) -> VNode {
|
||||
})
|
||||
}
|
||||
|
||||
const ExternalLinkIcon: FC<()> = |ctx| {
|
||||
ctx.render(html! {
|
||||
const ExternalLinkIcon: FC<()> = |cx| {
|
||||
cx.render(html! {
|
||||
<svg x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15">
|
||||
<path
|
||||
fill="currentColor"
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#[derive(PartialEq, Properties)]
|
||||
struct Props { name: &'static str }
|
||||
|
||||
static HelloMessage: FC<Props> = |ctx| {
|
||||
ctx.render(rsx!{
|
||||
div { "Hello {ctx.props.name}" }
|
||||
static HelloMessage: FC<Props> = |cx| {
|
||||
cx.render(rsx!{
|
||||
div { "Hello {cx.props.name}" }
|
||||
})
|
||||
}
|
||||
```
|
||||
@@ -16,8 +16,8 @@ static HelloMessage: FC<Props> = |ctx| {
|
||||
Choose from a close-to-html syntax or the standard rsx! syntax
|
||||
|
||||
```rust
|
||||
static HelloMessage: FC<()> = |ctx| {
|
||||
ctx.render(html!{
|
||||
static HelloMessage: FC<()> = |cx| {
|
||||
cx.render(html!{
|
||||
<div> Hello World! </div>
|
||||
})
|
||||
}
|
||||
@@ -33,8 +33,8 @@ enum LightState {
|
||||
Yellow,
|
||||
Red,
|
||||
}
|
||||
static HelloMessage: FC<()> = |ctx| {
|
||||
let (color, set_color) = use_state(&ctx, || LightState::Green);
|
||||
static HelloMessage: FC<()> = |cx| {
|
||||
let (color, set_color) = use_state(&cx, || LightState::Green);
|
||||
|
||||
let title = match color {
|
||||
Green => "Green means go",
|
||||
@@ -42,7 +42,7 @@ static HelloMessage: FC<()> = |ctx| {
|
||||
Red => "Red means stop",
|
||||
};
|
||||
|
||||
ctx.render(rsx!{
|
||||
cx.render(rsx!{
|
||||
h1 { "{title}" }
|
||||
button { "tick"
|
||||
onclick: move |_| set_color(match color {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use dioxus_ssr::prelude::{Context, VNode};
|
||||
|
||||
// Parse a snippet into
|
||||
pub fn markdown_to_snippet<'a, P>(ctx: Context<'a, P>, text: &str) -> Vec<VNode<'a>> {
|
||||
pub fn markdown_to_snippet<'a, P>(cx: Context<'a, P>, text: &str) -> Vec<VNode<'a>> {
|
||||
let snips = Vec::new();
|
||||
use pulldown_cmark::{Options, Parser};
|
||||
let mut options = Options::empty();
|
||||
|
||||
Reference in new issue
Block a user