2. Choose independent layouts around a design-system breakpoint
Responsive owns the width rule. The app does not scatter viewport comparisons through the editor and preview. The breakpoint comes from the active design system; test whether that threshold gives these two panes enough room rather than assuming it suits every design.
The identity-aware constructor builds each branch under a different retained scope. Supply component values which construct independent trees, not clones of a prebuilt Widget. The editor and preview implementations are still shared code; their mounted widget instances are separate.
{"id":"fission-tabs-1","tabs":[{"index":0,"label":"src/wide.rs","value":"src-wide-rs"},{"index":1,"label":"src/app.rs","value":"src-app-rs"},{"index":2,"label":"src/lib.rs","value":"src-lib-rs"},{"index":3,"label":"preview/lib.rs","value":"preview-lib-rs"}]}
{"id":"fission-tabs-1","index":0,"label":"src/wide.rs","value":"src-wide-rs"}
use fission::prelude::*;
use crate::{editor::RecipeEditor, recipe_preview::RecipePreview, state::RecipeState};
fission_component! {
pub WideRecipeLayout<RecipeState> {}
view(_layout, _state, cx) {
let tokens = &cx.view.env().theme.tokens;
} =>
Row(gap: tokens.spacing.m, align_items: ir_op::AlignItems::Start, children: [
Container(child: RecipeEditor(), width: 0.0, min_width: 0.0, flex_grow: 1.0),
Container(child: RecipePreview(), width: 0.0, min_width: 0.0, flex_grow: 1.0),
])
}
{"id":"fission-tabs-1","index":1,"label":"src/app.rs","value":"src-app-rs"}
use fission::prelude::*;
use crate::{compact::CompactRecipeLayout, state::RecipeState};
use crate::wide::WideRecipeLayout;
fission_component! {
pub RecipeWorkbench<RecipeState> {}
view(_app, _state, cx) {
let tokens = &cx.view.env().theme.tokens;
} =>
SafeArea(
child: Scroll(
child: Container(
child: Column(gap: tokens.spacing.m, children: [
Text(cx.tr("recipe.title")).size(tokens.typography.heading2_size),
Text(cx.tr("recipe.scope")),
Responsive::new_with_id(
WidgetId::explicit("recipe.layout"),
|| WideRecipeLayout,
).case_max_width_with(
tokens.breakpoints.medium_max,
|| CompactRecipeLayout,
),
]),
).padding_all(tokens.spacing.l),
),
)
}
{"id":"fission-tabs-1","index":2,"label":"src/lib.rs","value":"src-lib-rs"}
pub mod app;
mod state;
mod editor;
mod recipe_preview;
mod compact;
mod wide;
mod translations;
use app::RecipeWorkbench;
use state::RecipeState;
use fission::prelude::*;
#[cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))]
pub fn run_desktop() -> anyhow::Result<()> {
DesktopApp::<RecipeState, _>::new(RecipeWorkbench)
.with_env(translations::create_env())
.run()
}
#[cfg(any(target_os = "android", target_os = "ios"))]
fn mobile_app() -> MobileApp<RecipeState, RecipeWorkbench> {
let app = MobileApp::<RecipeState, _>::new(RecipeWorkbench)
.with_env(translations::create_env());
#[cfg(all(target_os = "android", debug_assertions))]
let app = app.with_test_control_port(48761);
app
}
#[cfg(any(target_os = "android", target_os = "ios"))]
pub fn run_mobile() -> anyhow::Result<()> { mobile_app().run() }
#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app_handle: AndroidApp) {
let _ = mobile_app().run_with_android_app(app_handle);
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen::prelude::wasm_bindgen(start)]
pub fn run_web() -> Result<(), wasm_bindgen::JsValue> {
console_error_panic_hook::set_once();
WebApp::<RecipeState, _>::new(RecipeWorkbench)
.with_env(translations::create_env())
.run()
.map_err(|error| wasm_bindgen::JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1","index":3,"label":"preview/lib.rs","value":"preview-lib-rs"}
mod app;
mod state;
mod editor;
mod recipe_preview;
mod compact;
mod wide;
mod translations;
use fission::prelude::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen(start)]
pub fn run() -> Result<(), JsValue> {
console_error_panic_hook::set_once();
WebApp::<state::RecipeState, _>::new(app::RecipeWorkbench)
.with_env(translations::create_env())
.mount("#fission-web-mount")
.run()
.map_err(|error| JsValue::from_str(&error.to_string()))
}
{"id":"fission-tabs-1"}
Type a recipe, widen the window until the panes sit side by side, then make it narrow again. The same draft must remain visible. Below the maximum-width threshold the compact branch applies; at the threshold and above, the wide fallback applies.
The responsive widget constructs and lowers its branches even when only one is visible. Hidden content is not an authorisation or resource-startup boundary. Keep effects out of component conversion and use ProtectedRoute when access must prevent constructing a tree.
Show the app previewHide the app preview
Show the app preview
Hide the app preview