T44d Web · The gallery's start takes its defaults from one place
This commit is contained in:
3 files changed
+10
-20
No files matched your search
@@ -96,6 +96,7 @@ fn choose(window: WindowHandle<shell::Gallery>, choice: shell::Choice, cx: &mut
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// What the gallery opens on.
|
/// What the gallery opens on.
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Start {
|
pub struct Start {
|
||||||
pub page: usize,
|
pub page: usize,
|
||||||
/// One section, by title or slug, drawn alone.
|
/// One section, by title or slug, drawn alone.
|
||||||
@@ -154,13 +155,7 @@ struct Args {
|
|||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
fn parse_args() -> Result<Args> {
|
fn parse_args() -> Result<Args> {
|
||||||
let mut args = Args {
|
let mut args = Args {
|
||||||
start: Start {
|
start: Start::default(),
|
||||||
page: 0,
|
|
||||||
story: None,
|
|
||||||
choice: shell::Choice::Light,
|
|
||||||
narrow: None,
|
|
||||||
failure: None,
|
|
||||||
},
|
|
||||||
page: None,
|
page: None,
|
||||||
capture: None,
|
capture: None,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ use gpui::{
|
|||||||
|
|
||||||
use crate::{Start, pages, ui::Story};
|
use crate::{Start, pages, ui::Story};
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
#[derive(Clone, Copy, PartialEq, Eq, Default)]
|
||||||
pub enum Choice {
|
pub enum Choice {
|
||||||
|
#[default]
|
||||||
Light,
|
Light,
|
||||||
Dark,
|
Dark,
|
||||||
System,
|
System,
|
||||||
|
|||||||
+6
-12
@@ -7,7 +7,10 @@ use gpui_web::{CanvasFontFallback, WebBackendPreference, WebPlatform};
|
|||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use web_sys::UrlSearchParams;
|
use web_sys::UrlSearchParams;
|
||||||
|
|
||||||
use crate::{Start, choose, launch, pages, shell::Choice, shell::Gallery};
|
use crate::{
|
||||||
|
Start, choose, launch, pages,
|
||||||
|
shell::{Choice, Gallery},
|
||||||
|
};
|
||||||
|
|
||||||
/// The i18n page's Hebrew: gpui_web asks the browser for emoji and CJK alone.
|
/// The i18n page's Hebrew: gpui_web asks the browser for emoji and CJK alone.
|
||||||
const HEBREW: &[u8] = include_bytes!("fonts/NotoSansHebrew-Regular.ttf");
|
const HEBREW: &[u8] = include_bytes!("fonts/NotoSansHebrew-Regular.ttf");
|
||||||
@@ -36,13 +39,7 @@ fn read(search: &str) -> Result<Start> {
|
|||||||
{
|
{
|
||||||
bail!("ELY_GALLERY_ASSETS is an address ending in /, not {assets}");
|
bail!("ELY_GALLERY_ASSETS is an address ending in /, not {assets}");
|
||||||
}
|
}
|
||||||
let mut start = Start {
|
let mut start = Start::default();
|
||||||
page: 0,
|
|
||||||
story: None,
|
|
||||||
choice: Choice::Light,
|
|
||||||
narrow: None,
|
|
||||||
failure: None,
|
|
||||||
};
|
|
||||||
let params = UrlSearchParams::new_with_str(search).map_err(js)?;
|
let params = UrlSearchParams::new_with_str(search).map_err(js)?;
|
||||||
for key in js_sys::try_iter(¶ms.keys())
|
for key in js_sys::try_iter(¶ms.keys())
|
||||||
.map_err(js)?
|
.map_err(js)?
|
||||||
@@ -80,11 +77,8 @@ pub fn start() {
|
|||||||
let start = read(&search).unwrap_or_else(|error| {
|
let start = read(&search).unwrap_or_else(|error| {
|
||||||
log::error!("gallery: {search} -> {error:#}");
|
log::error!("gallery: {search} -> {error:#}");
|
||||||
Start {
|
Start {
|
||||||
page: 0,
|
|
||||||
story: None,
|
|
||||||
choice: Choice::Light,
|
|
||||||
narrow: None,
|
|
||||||
failure: Some(SharedString::from(format!("{search}: {error:#}"))),
|
failure: Some(SharedString::from(format!("{search}: {error:#}"))),
|
||||||
|
..Start::default()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// One thread: a static site sends no cross-origin isolation, so there is no shared memory.
|
// One thread: a static site sends no cross-origin isolation, so there is no shared memory.
|
||||||
|
|||||||
Reference in new issue
Block a user