on main help sign in
v0.3.4 update docs and rework sigil input modes
commit363cd2beb8a3ae25f2893d2fc3a13e7502d8f906 authorJohn Hyde <johnhydefour@gmail.com> dateTue 4 Oct 2022, 14:10 (4 years ago) parentf385d34
12 files changed+137−70
.vscode/settings.json+6 .vscode/tasks.json+3−3 desk/desk.docket-0+2−2 desk/doc.toc+2−1 desk/doc/overview.udon+2 desk/doc/usr/astrolabe.udon+6−6 desk/doc/usr/sigil-input.udon+27 desk/doc/usr/sigil.udon+3−2 ui/index.html+1 ui/src/components/search/SearchBar.svelte+1−1 ui/src/components/search/sigil/SymbolInputModeSelector.svelte+83−54 ui/src/types/sigil.ts+1−1
.vscode/settings.json+6
@@ -48,5 +48,11 @@
4848 }
4949 ]
5050 }
51+ ],
52+ "grammarly.selectors": [
53+ {
54+ "language": "markdown",
55+ "scheme": "file"
56+ }
5157 ]
5258}
.vscode/tasks.json+3−3
@@ -3,11 +3,11 @@
33 "tasks": [
44 {
55 "type": "npm",
6− "script": "commit",
6+ "script": "install:desk",
77 "path": "ui",
88 "problemMatcher": [],
9− "label": "npm: commit - ui",
10− "detail": "dotenv -c local npm run _commit"
9+ "label": "npm: install:desk - ui",
10+ "detail": "dotenv -c local npm run _install:desk"
1111 }
1212 ]
1313}
desk/desk.docket-0+2−2
@@ -2,9 +2,9 @@
22 info+'Your guide to the Urbit constellations'
33 color+0x1f.243c
44 image+'https://raw.githubusercontent.com/johnhyde/astrolabe/main/ui/src/assets/astrolabe-tile.svg'
5− glob-http+['https://s3.us-east-2.amazonaws.com/warkgnall.com/urbit/astrolabe/globs/glob-0v7.6404d.39fgn.ms148.c6qf4.9c0f3.glob' 0v7.6404d.39fgn.ms148.c6qf4.9c0f3]
5+ glob-http+['https://s3.us-east-2.amazonaws.com/warkgnall.com/urbit/astrolabe/globs/glob-0v2.jtc81.6iedn.re59t.n1mo1.9e0k8.glob' 0v2.jtc81.6iedn.re59t.n1mo1.9e0k8]
66 base+'astrolabe'
7− version+[0 3 3]
7+ version+[0 3 4]
88 website+'https://github.com/johnhyde/astrolabe'
99 license+'MIT'
1010==
desk/doc.toc+2−1
@@ -1,4 +1,4 @@
1−/overview/udon About Astrolabe
1+/overview/udon Overview
22/usr User
33 /urbit-id/udon What is an Urbit ID?
44 /galaxy/udon Galaxies
@@ -12,3 +12,4 @@
1212 /azimuth/udon What is Azimuth?
1313 /l2/udon Layer 1 and Layer 2
1414 /keys/udon Networking Keys
15+ /astrolabe/udon About Astrolabe
desk/doc/overview.udon+2
@@ -5,6 +5,8 @@ Currently Astrolabe lets you input `@p`s, Azimuth point numbers, or sigils
55to look up ships on the network. Use the Star Chart to explore visually.
66There's also Help Documentation if you want to learn more about how Urbit IDs work.
77
8+[How to Use Astrolabe](/~/scry/docs/usr/astrolabe/astrolabe.html)
9+
810## Info
911
1012- Developer: ~midlev-mindyr
desk/doc/usr/astrolabe.udon+6−6
@@ -32,7 +32,7 @@ Clicking the symbol at the right of the search bar opens the Sigil Input Tool.
3232Use the dropdown at the top to select Galaxy, Star, or Planet.
3333Click on a square to start selecting sigil components.
3434
35−Select component catogeries on the right, and then tap the options on the sigil
35+Select component categories on the right, and then click the options on the sigil
3636to add them to your search.
3737
3838The ^ button goes up a level so you can select another category.
@@ -40,13 +40,13 @@ The X button will clear sigil components from the current symbol,
4040except the basic shape. If only the basic shape remains, the X button will clear that.
4141At the top level, the X button will clear all inputs.
4242
43−Your contacts will be searched for any search.
43+Your contacts will be searched for any input.
4444When the search has become specific enough,
4545all spawned ships with matching sigils will be shown.
4646If your input is unambiguous, the page for the matching ship will be shown,
4747whether the ship is spawned or not.
4848
49−NOTE: Some sigil inputs are considered ambiguous even if they exactly match
49+NOTE: Some sigil inputs are considered ambiguous, even if they exactly match
5050a particular sigil, because further details could match a different sigil.
5151E.g. `~zod` is a circle, but a circle in the suffix position might be intended as a more general search.
5252A future version of Astrolabe will allow you to view the ship
@@ -56,7 +56,7 @@ Read more about Sigils [here](/~/scry/docs/usr/astrolabe/sigil.html).
5656
5757## The Star Chart
5858
59−Click and drag to move your view, use the mouse wheel to zoom in and out. Click on a dot
59+Click and drag to move your view; use the mouse wheel to zoom in and out. Click on a dot
6060to see the full Ship View. Enter full `@p`s in the search bar to find a specific point.
6161
6262Please note that stars [locked in the Linear Release Contract](/~/scry/docs/usr/astrolabe/star.html)
@@ -64,7 +64,7 @@ are not shown in the Star Chart, as they are not yet a part of the network (thou
6464been spawned).
6565
6666The Sponsors/Parents toggle lets you switch between two different views of the network.
67−The default Sponsors view shows each planet under its sponsoring star, and each
67+The default Sponsors view shows each planet under its sponsoring star and each
6868star under its sponsoring galaxy. Planets and Stars without sponsors are not
6969present in this view.
7070The Parent view simply shows each point under the point that spawned it. All spawned points
@@ -73,7 +73,7 @@ In both views, all galaxies are shown for completeness.
7373
7474## Upcoming Features
7575
76−In addition to improving the search features over time, Astrolabe will one day feature ntegrations with Groups, `%pals`, `%gora`, and whatever else seems fun and/or useful.
76+In addition to improving the search features over time, Astrolabe will one day feature integrations with Groups, `%pals`, `%gora`, and whatever else seems fun and/or useful.
7777
7878## Info
7979
desk/doc/usr/sigil-input.udonnew file+27
@@ -0,0 +1,27 @@
1+;>
2+# How to Search by Sigil
3+
4+Use the dropdown at the top to select Galaxy, Star, or Planet.
5+Click on an empty square to start selecting sigil components.
6+
7+Select component categories on the right, and then click the options on the sigil
8+to add them to your search.
9+
10+The ^ button goes up a level so you can select another category.
11+The X button will clear sigil components from the current symbol,
12+except the basic shape. If only the basic shape remains, the X button will clear that.
13+At the top level, the X button will clear all inputs.
14+
15+Your contacts will be searched for any input.
16+When the search has become specific enough,
17+all spawned ships with matching sigils will be shown.
18+If your input is unambiguous, the page for the matching ship will be shown,
19+whether the ship is spawned or not.
20+
21+_NOTE:_ Some sigil inputs are considered ambiguous, even if they exactly match
22+a particular sigil, because further details could match a different sigil.
23+E.g. `~zod` is a circle, but a circle in the suffix position might be intended as a more general search.
24+A future version of Astrolabe will allow you to view the ship
25+whose sigil most closely matches your search, even if the search is ambiguous.
26+
27+_See Also:_ [*What is a Sigil?*](/~/scry/docs/usr/astrolabe/sigil.html)
desk/doc/usr/sigil.udon+3−2
@@ -2,9 +2,9 @@
22# What is a Sigil?
33
44It's a default profile picture, based on your [`@p`](/~/scry/docs/usr/astrolabe/patpee.html).
5−Each 3-letter syllable corresponds to sigil shape, or symbol.
5+Each 3-letter syllable corresponds to a sigil shape, or "symbol".
66Since planet `@p`s have 4 syllables, a planet sigil is a 2x2 grid of 4 symbols.
7−Star sigils have 2 symbols, and galaxies just 1.
7+Star sigils have 2 symbols, and galaxies have just 1.
88
99![planet sigils](/apps/astrolabe/sigil-example.png)
1010
@@ -19,3 +19,4 @@ with a focus on visual design rather than algorithmic purity.
1919Tlon saw that Urbit IDs need a visual representation,
2020so they designed a system for generating default avatars.
2121You can read about it in the blog post [_Creating Sigils_](https://urbit.org/blog/creating-sigils).
22+
ui/index.html+1
@@ -8,6 +8,7 @@
88 <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
99 <link rel="manifest" href="/site.webmanifest">
1010 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
11+ <meta name="color-scheme" content="light only">
1112 </head>
1213 <body>
1314 <div id="app" class="h-full"></div>
ui/src/components/search/SearchBar.svelte+1−1
@@ -82,7 +82,7 @@
8282 }
8383
8484 function showSigilDoc() {
85− docs.show('sigil');
85+ docs.show('sigil-input');
8686 }
8787
8888 const buttonClasses = 'rounded-full bg-black text-white text-sm transition-opacity opacity-50 hover:opacity-80';
ui/src/components/search/sigil/SymbolInputModeSelector.svelte+83−54
@@ -14,87 +14,110 @@
1414 export let inputComponents: string[] = [];
1515 export let unfocusSymbol: Function = () => {};
1616
17− let modes: string[] = [];
17+ let mode: string = null;
18+ let subMode: string = null;
1819 let modeDef: ModeDef = undefined;
19− let subModeDefs: ModeDefs = MODE_DEFS;
20+ let unselectedSubModesExist: boolean = false;
21+ let modeDefs: ModeDefs = MODE_DEFS;
22+ let plausibleModeDefs: { name: string, def: ModeDef }[] = [];
2023
2124 function showGeonSelector() {
22− if (!symbolQuery.components.length && modes.length == 0) {
23− modes = ['geon'];
25+ if (!symbolQuery.components.length && !mode) {
26+ mode = 'geon';
27+ subMode = null;
2428 }
2529 }
2630
2731 $: symbolQuery.components, showGeonSelector();
2832
29− function pushMode(mode: string) {
30− if (modeDef?.modes) {
31− modes = [...modes, mode];
33+ function pushMode(newMode: string) {
34+ const subModes = modeDef?.modes;
35+ if (subModes || subMode) {
36+ subMode = newMode;
3237 } else {
33− modes = [...modes.slice(0, -1), mode];
38+ mode = newMode;
39+ subMode = null;
3440 }
3541 }
3642
3743 function popMode() {
38− if (modes.length) {
39− if (modeDef?.modes) {
40− modes = modes.slice(0, -1);
41− } else {
42− modes = modes.slice(0, -2);
43− }
44+ if (mode || subMode) {
45+ mode = null;
46+ subMode = null;
4447 } else {
4548 unfocusSymbol();
4649 }
4750 }
4851
4952 $: {
50− modeDef = undefined;
51− subModeDefs = MODE_DEFS;
52− for (let mode of modes) {
53− if (modeDef && modeDef.modes) {
54− subModeDefs = modeDef.modes;
53+ let modeResolved = false;
54+ let count = 0;
55+ while (!modeResolved && count < 5) {
56+ modeDef = undefined;
57+ modeDefs = MODE_DEFS;
58+ if (mode) {
59+ modeDef = MODE_DEFS[mode];
60+ }
61+ unselectedSubModesExist = !!modeDef?.modes;
62+ if (unselectedSubModesExist) {
63+ modeDefs = modeDef.modes;
64+ if (subMode) {
65+ if (modeDefs[subMode]) {
66+ modeDef = modeDefs[subMode];
67+ } else {
68+ console.error(`Unknown subMode: ${subMode} of ${mode} in defs:`, modeDefs);
69+ subMode = null;
70+ }
71+ }
5572 }
56− if (subModeDefs[mode]) {
57− modeDef = subModeDefs[mode];
73+ unselectedSubModesExist = !!modeDef?.modes;
74+ if (!isDefPlausible(modeDef) && mode !== 'geon') {
75+ if (subMode) {
76+ subMode = null;
77+ } else {
78+ mode = null;
79+ }
5880 } else {
59− console.error(`Unknown mode: ${mode} of ${modes} in defs:`, subModeDefs);
81+ plausibleModeDefs = getPlausibleModeDefs(modeDefs);
82+ if (unselectedSubModesExist) {
83+ subMode = plausibleModeDefs[0].name;
84+ } else {
85+ modeResolved = true;
86+ }
87+ }
88+ count++;
89+ if (count >= 5 && !modeResolved) {
90+ console.error("sigil input mode resulotion failed");
6091 }
6192 }
62−
63− if (modeDef && modeDef.modes) {
64− subModeDefs = modeDef.modes;
65− }
66−
67− if (modeDef?.parts?.length && !modeDef.modes) {
93+ inputComponents = [];
94+ if (modeDef?.parts?.length) {
6895 inputComponents = modeDef.parts;
6996 if (!$searchSettings.allowFictionalSigils) {
7097 inputComponents = symbolQuery.filterPlausibleParts(inputComponents);
7198 }
72− } else {
73− inputComponents = [];
7499 }
75100 }
76101
77− $: plausibleModes = Object.entries(subModeDefs).map(([modeName, def]) => {
102+ function isDefPlausible(def: ModeDef): boolean {
103+ if (!def) return true;
78104 const deepParts = getDeepParts(def);
79− const plausible = $searchSettings.allowFictionalSigils || symbolQuery.arePartsPlausible(deepParts);
80− if (!plausible && modeName !== 'geon') return null;
81− const parts = filterPartsByGeon(def.displayParts || def.parts, symbolQuery.geon);
82− return { parts, modeName };
83− }).filter(mode => mode !== null);
105+ return $searchSettings.allowFictionalSigils || symbolQuery.arePartsPlausible(deepParts);
106+ }
84107
85− $: {
86− const currentMode = modes.slice(-1)[0];
87− if (currentMode != 'geon') {
88− if (plausibleModes.length === 0) {
89− popMode();
90− } else if (plausibleModes.length >= 1) {
91− const leafMode = modeDef && !(modeDef.modes);
92− const plausibleModeNames = plausibleModes.map(({ modeName }) => modeName);
93− if ((modes.length == 1 && modeDef.modes) || (leafMode && !plausibleModeNames.includes(currentMode))) {
94− pushMode(plausibleModes[0].modeName);
95− }
96− }
97− }
108+ function getPlausibleModeDefs(modeDefs: ModeDefs) {
109+ return Object.entries(modeDefs).map(([modeName, def]) => {
110+ const plausible = isDefPlausible(def);
111+ if (!plausible && modeName !== 'geon') return null;
112+ const parts = filterPartsByGeon(def.displayParts || def.parts, symbolQuery.geon);
113+ return {
114+ name: modeName,
115+ def: {
116+ ...def,
117+ parts,
118+ },
119+ };
120+ }).filter(mode => mode !== null);
98121 }
99122
100123 function clear() {
@@ -116,17 +139,23 @@
116139</style>
117140
118141<div class="mx-auto flex justify-center xs:items-center xs:flex-col">
119− <SymbolInputNavButtons onDone={popMode} onClear={clear} />
142+ <SymbolInputNavButtons onDone={popMode} onClear={clear} hideClearButton={symbolQuery.components.length == 0} />
120143 <div class="max-w-[15rem] h-full grid grid-cols-custom gap-1 justify-center xs:max-w-[8rem]">
121− {#if modes[0] === 'geon'}
144+ {#if mode === 'geon'}
122145 <GeonSelector bind:symbolQuery {popMode} />
123146 {:else}
124− {#each plausibleModes as { modeName, parts }}
125− <SymbolInputModeSelectorButton components={parts} focused={modes.slice(-1)[0] === modeName}
126− on:click={() => pushMode(modeName)}
147+ {#each plausibleModeDefs as { name, def: { parts } }}
148+ <SymbolInputModeSelectorButton components={parts} focused={mode === name || subMode === name}
149+ on:click={() => pushMode(name)}
127150 />
128151 {/each}
129152 {/if}
130153 </div>
154+ <!-- <p class="break-all w-24">
155+ mode: {mode}
156+ </p>
157+ <p class="break-all w-24">
158+ sub: {subMode}
159+ </p> -->
131160</div>
132161
ui/src/types/sigil.ts+1−1
@@ -22,7 +22,7 @@ export interface ModeDefs {
2222
2323export const MODE_DEFS: ModeDefs = {
2424 geon: {
25− modes: {},
25+ // modes: {},
2626 displayParts: ['ghb'],
2727 },
2828 line: {