styling of side panel & search results

This commit is contained in:
David Mosbach 2023-06-04 14:56:42 +02:00
parent bc5b984814
commit 4c24eab8c7
4 changed files with 26 additions and 9 deletions

View File

@ -145,7 +145,7 @@ body {
#search-result-list { #search-result-list {
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
/* padding: 15px; */ font-family: 'OpenSans';
} }
#search-result-list > * { #search-result-list > * {
@ -263,6 +263,10 @@ body {
position: absolute; position: absolute;
top: 10px; top: 10px;
left: 20px; left: 20px;
cursor: default;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
} }
#sidecontentedge, #sidecontentnode { #sidecontentedge, #sidecontentnode {
@ -278,9 +282,11 @@ body {
#sideheading { #sideheading {
font-family: 'OpenSans'; font-family: 'OpenSans';
text-align: center; text-align: center;
font-size: 2em; font-size: 1.75em;
font-style: normal; font-style: normal;
margin-top: 40px; margin-top: 40px;
padding-left: 20px;
padding-right: 20px;
} }
#sidecontent { #sidecontent {
@ -298,6 +304,10 @@ body {
word-wrap: break-word; word-wrap: break-word;
} }
#sidecontent h2 {
font-size: 1.25em;
}
#sidebuttons, #filebuttons { #sidebuttons, #filebuttons {
position: absolute; position: absolute;
bottom: 20px; bottom: 20px;

View File

@ -128,7 +128,7 @@
<div class="menuitem" onclick="openSearchMenu(this)"> <div class="menuitem" onclick="openSearchMenu(this)">
<div id="search-container"> <div id="search-container">
<input id="search-input" type="text" placeholder="Search" onclick="showSearchResults()" oninput="search(this.value)"> <input id="search-input" type="text" placeholder="Search" onclick="showSearchResults()" oninput="search(this.value)">
<span class="search-button"> <span class="search-button" onclick="searchInput.focus()">
<svg id="search-icon" class="search-icon-lightmode" height="18" width="18" xmlns="http://www.w3.org/2000/svg"> <svg id="search-icon" class="search-icon-lightmode" height="18" width="18" xmlns="http://www.w3.org/2000/svg">
<circle cx="11" cy="7" r="6" stroke-width="2" fill="none" /> <circle cx="11" cy="7" r="6" stroke-width="2" fill="none" />
<polyline points="6,12 2,16" style="fill:none;stroke-width:2" stroke-linecap="round" /> <polyline points="6,12 2,16" style="fill:none;stroke-width:2" stroke-linecap="round" />

View File

@ -148,7 +148,7 @@ function focusSelection() {
function openSearchMenu(menuitem) { function openSearchMenu(menuitem) {
if (selectedMenuItem === menuitem) return; if (selectedMenuItem === menuitem) return;
var val = document.getElementById('search-input').value; var val = searchInput.value;
if (val === '' || val === null) if (val === '' || val === null)
while (searchResultList.firstChild) while (searchResultList.firstChild)
searchResultList.removeChild(searchResultList.lastChild); searchResultList.removeChild(searchResultList.lastChild);
@ -170,12 +170,12 @@ function search(text) {
searchResultList.removeChild(searchResultList.lastChild); searchResultList.removeChild(searchResultList.lastChild);
var searchStates = soStates.checked; var searchStates = soStates.checked;
var searchActions = soEdges.checked var searchActions = soEdges.checked
var stateResults = searchStates ? nodeIndex.search(text, searchActions ? 5 : 10) : null; var stateResults = searchStates ? nodeIndex.search(text, searchActions ? 5 : 10) : null;
var actionResults = searchActions ? actionIndex.search(text, searchStates ? 5 : 10) : null; var actionResults = searchActions ? actionIndex.search(text, searchStates ? 5 : 10) : null;
function defineFocus(div, target) { function defineFocus(div, target) {
div.onclick = (_ => { div.onclick = (_ => {
document.getElementById('search-input').value = null; searchInput.value = null;
closeMenuItem(); closeMenuItem();
select(target); select(target);
focusSelection(); focusSelection();
@ -293,6 +293,9 @@ function defineOnClick(item, url, title) {
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
closeFileDisplay(); closeFileDisplay();
searchInput.value = null;
while (searchResultList.firstChild)
searchResultList.removeChild(searchResultList.lastChild);
for (var key in data) for (var key in data)
workflow[key] = data[key]; workflow[key] = data[key];
nodeIndex = new FlexSearch.Index({tokenize: 'forward'}); nodeIndex = new FlexSearch.Index({tokenize: 'forward'});
@ -406,6 +409,7 @@ const contextMenuSt = document.getElementById('ctmenust'); //Click on state
const contextMenuEd = document.getElementById('ctmenued'); //Click on edge const contextMenuEd = document.getElementById('ctmenued'); //Click on edge
//Search //Search
const searchContainer = document.getElementById('search-container'); const searchContainer = document.getElementById('search-container');
const searchInput = document.getElementById('search-input');
const searchResults = document.getElementById('search-results'); const searchResults = document.getElementById('search-results');
const searchResultList = document.getElementById('search-result-list'); const searchResultList = document.getElementById('search-result-list');
const searchOptions = document.getElementById('search-options') const searchOptions = document.getElementById('search-options')
@ -440,7 +444,10 @@ function select(item) {
sideInfoEdge.style.display = 'none'; sideInfoEdge.style.display = 'none';
sideInfoNode.style.display = 'block'; sideInfoNode.style.display = 'block';
} }
sideHeading.innerHTML = item.name; var heading = item.name;
if (heading.length > 90) heading = heading.substring(0, 88) + '...';
sideHeading.innerHTML = heading;
sideHeading.setAttribute('title', item.name);
var data = document.createElement('div'); var data = document.createElement('div');
var content = generatePanelContent(selection); var content = generatePanelContent(selection);
content.forEach(c => data.appendChild(c)); content.forEach(c => data.appendChild(c));

View File

@ -8,12 +8,12 @@ document.addEventListener('keydown', e => {
closeFileDisplay(); closeFileDisplay();
deselect(); deselect();
rightSelection = null; rightSelection = null;
document.getElementById('search-input').blur(); searchInput.blur();
} else if (!e.ctrlKey) return; } else if (!e.ctrlKey) return;
switch (e.key) { switch (e.key) {
case 'f': case 'f':
e.preventDefault(); e.preventDefault();
document.getElementById('search-input').focus(); searchInput.focus();
openSearchMenu(searchContainer.parentElement); openSearchMenu(searchContainer.parentElement);
break; break;
case 'o': case 'o':