feat: add mobile new issue navigation (Closes #971)
This commit is contained in:
1 parent
dcc3348c12
commit
2b671d91fd
8 files changed
+271
-2
No files matched your search
@@ -701,7 +701,9 @@ textarea { resize: vertical; min-height: 120px; }
|
||||
.create-issue-panel { width:min(560px,100%); height:100dvh; overflow:auto; overflow-x:hidden; display:grid; align-content:start; gap:12px; padding:18px; padding-bottom:calc(18px + env(safe-area-inset-bottom)); background:#0b1526; border-left:1px solid #2a496e; }
|
||||
.create-issue-header { display:flex; align-items:center; justify-content:space-between; gap:10px; }
|
||||
.create-issue-header button, .create-issue-actions button, .create-issue-capture-actions button { min-height:44px; }
|
||||
.mobile-create-issue-nav { display:none; }
|
||||
.create-issue-form { display:grid; gap:12px; }
|
||||
.create-issue-describe { display:grid; gap:12px; min-width:0; }
|
||||
.voice-issue-capture { display:grid; gap:8px; min-width:0; padding:12px; border:1px solid #31577f; border-radius:12px; background:#101d31; }
|
||||
.voice-issue-capture[hidden], .voice-issue-review[hidden], .voice-issue-controls button[hidden] { display:none; }
|
||||
.voice-issue-heading, .voice-issue-review { display:grid; gap:6px; }
|
||||
@@ -908,6 +910,20 @@ textarea { resize: vertical; min-height: 120px; }
|
||||
.saved-search-row { align-items:stretch; }
|
||||
#cmd-results { flex:1; min-height:0; overflow-y:auto; max-height:none; overscroll-behavior:contain; padding-bottom:env(safe-area-inset-bottom); }
|
||||
.create-issue-panel { width:100%; border-left:0; padding:14px; }
|
||||
.mobile-create-issue-nav {
|
||||
position:sticky; top:env(safe-area-inset-top); z-index:6;
|
||||
display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px;
|
||||
margin-inline:-14px; padding:4px 14px;
|
||||
background:rgba(11,21,38,.98); border-block:1px solid #2a496e;
|
||||
}
|
||||
.mobile-create-issue-nav button {
|
||||
min-width:0; min-height:44px; padding:4px; border-color:transparent; font-size:12px;
|
||||
}
|
||||
.mobile-create-issue-nav button[aria-current="location"] {
|
||||
border-color:#60a5fa; background:#17365a; color:#fff;
|
||||
}
|
||||
.mobile-create-issue-nav button[aria-disabled="true"] { opacity:.55; }
|
||||
#create-issue-describe, #create-issue-evidence, #create-issue-filing { scroll-margin-top:72px; }
|
||||
.pull-sheet-panel { width:100%; border-left:0; padding:14px; }
|
||||
.create-issue-panel.composer-keyboard-active,
|
||||
.issue-sheet-panel.composer-keyboard-active,
|
||||
|
||||
+9
-1
@@ -873,6 +873,11 @@
|
||||
<h3 id="create-issue-heading">Capture work</h3>
|
||||
<button id="cancel-new-issue" type="button">Cancel</button>
|
||||
</div>
|
||||
<nav class="mobile-create-issue-nav" aria-label="New issue sections">
|
||||
<button type="button" data-create-issue-section="describe">Describe</button>
|
||||
<button type="button" data-create-issue-section="evidence">Evidence</button>
|
||||
<button type="button" data-create-issue-section="file">File</button>
|
||||
</nav>
|
||||
<aside class="shared-content-conflict" id="shared-content-conflict" aria-live="assertive" hidden>
|
||||
<strong>You already have an unfinished issue draft.</strong>
|
||||
<span class="small">Resume it, or replace its title and description with the content shared to Stackchain.</span>
|
||||
@@ -882,6 +887,7 @@
|
||||
</div>
|
||||
</aside>
|
||||
<form class="create-issue-form" id="create-issue-form">
|
||||
<section class="create-issue-describe" id="create-issue-describe">
|
||||
<label for="create-issue-title">Title
|
||||
<input id="create-issue-title" type="text" maxlength="255" required autocomplete="off" />
|
||||
</label>
|
||||
@@ -913,7 +919,8 @@
|
||||
<button id="save-unfiled-issue" type="button">Save to Drafts</button>
|
||||
<button id="file-new-issue" type="button">File now</button>
|
||||
</div>
|
||||
<section class="create-issue-attachment" aria-labelledby="create-issue-attachment-label">
|
||||
</section>
|
||||
<section class="create-issue-attachment" id="create-issue-evidence" aria-labelledby="create-issue-attachment-label">
|
||||
<strong id="create-issue-attachment-label">Photo evidence <span class="small">Optional · Up to 5 · PNG, JPEG, or WebP · 2 MB each</span></strong>
|
||||
<div class="issue-attachment-controls photo-evidence-actions">
|
||||
<label class="issue-attachment-trigger" for="take-create-issue-photo">Take photo</label>
|
||||
@@ -1537,6 +1544,7 @@
|
||||
<script src="static/voice-issue-capture.js"></script>
|
||||
<script src="static/voice-conversation-capture.js"></script>
|
||||
<script src="static/create-issue-sheet.js"></script>
|
||||
<script src="static/mobile-create-issue-nav.js"></script>
|
||||
<script src="static/create-and-start.js"></script>
|
||||
<script src="static/assign-and-start.js"></script>
|
||||
<script src="static/filed-claim.js"></script>
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
function createMobileCreateIssueNavigation(options) {
|
||||
const buttons = options.buttons || {};
|
||||
const targets = options.targets || {};
|
||||
const listeners = new Map();
|
||||
const prefersReducedMotion = options.prefersReducedMotion || (() => false);
|
||||
const targetNames = new Map(Object.entries(targets).map(([name, target]) => [target, name]));
|
||||
let filingAvailable = !options.filing?.hidden;
|
||||
let observer = null;
|
||||
|
||||
function select(name) {
|
||||
Object.entries(buttons).forEach(([key, button]) => {
|
||||
if (!button) return;
|
||||
if (key === name) button.setAttribute('aria-current', 'location');
|
||||
else button.removeAttribute('aria-current');
|
||||
});
|
||||
}
|
||||
|
||||
function setFilingAvailable(available) {
|
||||
filingAvailable = Boolean(available);
|
||||
const button = buttons.file;
|
||||
if (!button) return;
|
||||
if (filingAvailable) button.removeAttribute('aria-disabled');
|
||||
else button.setAttribute('aria-disabled', 'true');
|
||||
}
|
||||
|
||||
function navigate(name) {
|
||||
if (name === 'file') setFilingAvailable(!options.filing?.hidden);
|
||||
if (name === 'file' && !filingAvailable) return false;
|
||||
const target = targets[name];
|
||||
if (!target) return false;
|
||||
target.scrollIntoView({
|
||||
block: 'start',
|
||||
behavior: prefersReducedMotion() ? 'auto' : 'smooth',
|
||||
});
|
||||
select(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset(available = !options.filing?.hidden) {
|
||||
setFilingAvailable(available);
|
||||
select('describe');
|
||||
}
|
||||
|
||||
return {
|
||||
start() {
|
||||
Object.entries(buttons).forEach(([name, button]) => {
|
||||
if (!button || listeners.has(button)) return;
|
||||
const listener = event => {
|
||||
event.preventDefault();
|
||||
navigate(name);
|
||||
};
|
||||
listeners.set(button, listener);
|
||||
button.addEventListener('click', listener);
|
||||
});
|
||||
reset();
|
||||
const observe = options.observe || ((handler, observedTargets, root) => {
|
||||
if (typeof IntersectionObserver === 'undefined') return null;
|
||||
const instance = new IntersectionObserver(handler, {
|
||||
root,
|
||||
rootMargin: '-20% 0px -60% 0px',
|
||||
threshold: [0, 0.25, 0.5, 0.75, 1],
|
||||
});
|
||||
observedTargets.forEach(target => instance.observe(target));
|
||||
return instance;
|
||||
});
|
||||
observer = observe(entries => {
|
||||
const visible = entries
|
||||
.filter(entry => entry.isIntersecting && targetNames.has(entry.target))
|
||||
.filter(entry => targetNames.get(entry.target) !== 'file' || filingAvailable)
|
||||
.sort((left, right) => right.intersectionRatio - left.intersectionRatio)[0];
|
||||
if (visible) select(targetNames.get(visible.target));
|
||||
}, Array.from(targetNames.keys()).filter(Boolean), options.root || null);
|
||||
},
|
||||
stop() {
|
||||
listeners.forEach((listener, button) => button.removeEventListener('click', listener));
|
||||
listeners.clear();
|
||||
if (observer) observer.disconnect();
|
||||
observer = null;
|
||||
},
|
||||
navigate,
|
||||
reset,
|
||||
select,
|
||||
setFilingAvailable,
|
||||
};
|
||||
}
|
||||
|
||||
function attachMobileCreateIssueNavigation({ document, window }) {
|
||||
const bySection = name => document.querySelector('[data-create-issue-section="' + name + '"]');
|
||||
const navigation = createMobileCreateIssueNavigation({
|
||||
root:document.querySelector('.create-issue-panel'),
|
||||
buttons:{describe:bySection('describe'), evidence:bySection('evidence'), file:bySection('file')},
|
||||
targets:{
|
||||
describe:document.getElementById('create-issue-describe'),
|
||||
evidence:document.getElementById('create-issue-evidence'),
|
||||
file:document.getElementById('create-issue-filing'),
|
||||
},
|
||||
filing:document.getElementById('create-issue-filing'),
|
||||
prefersReducedMotion:() => window.matchMedia('(prefers-reduced-motion: reduce)').matches,
|
||||
});
|
||||
navigation.start();
|
||||
document.getElementById('file-new-issue').addEventListener('click', () => {
|
||||
navigation.navigate('file');
|
||||
});
|
||||
new MutationObserver(() => {
|
||||
if (document.getElementById('create-issue-sheet').classList.contains('open')) {
|
||||
navigation.reset(!document.getElementById('create-issue-filing').hidden);
|
||||
}
|
||||
}).observe(document.getElementById('create-issue-sheet'), {
|
||||
attributes:true, attributeFilter:['class'],
|
||||
});
|
||||
return navigation;
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined') module.exports = createMobileCreateIssueNavigation;
|
||||
else attachMobileCreateIssueNavigation({document, window});
|
||||
@@ -85,6 +85,7 @@ const SHELL = [
|
||||
BASE + 'static/voice-issue-capture.js',
|
||||
BASE + 'static/voice-conversation-capture.js',
|
||||
BASE + 'static/create-issue-sheet.js',
|
||||
BASE + 'static/mobile-create-issue-nav.js',
|
||||
BASE + 'static/create-and-start.js',
|
||||
BASE + 'static/assign-and-start.js',
|
||||
BASE + 'static/filed-claim.js',
|
||||
|
||||
Reference in new issue
Block a user