FIX: add clearContext, general cleanup (#25)
This commit is contained in:
parent
17d3347725
commit
9be6d63f35
|
|
@ -28,7 +28,7 @@ $max-width: 600px;
|
||||||
padding: 2.5em 0 3em;
|
padding: 2.5em 0 3em;
|
||||||
margin: 1em auto;
|
margin: 1em auto;
|
||||||
@include breakpoint(tablet) {
|
@include breakpoint(tablet) {
|
||||||
padding: 1em 8px 2em;
|
padding: 1em 8px 1.25em;
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,6 +40,10 @@ $max-width: 600px;
|
||||||
.search-menu {
|
.search-menu {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
.browser-search-tip {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
input[type="text"] {
|
input[type="text"] {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
@ -53,7 +57,7 @@ $max-width: 600px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
.searching {
|
.searching {
|
||||||
// spinner
|
// spinner
|
||||||
top: 0.5em;
|
top: 0.4em;
|
||||||
right: 2.25em;
|
right: 2.25em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +80,6 @@ $max-width: 600px;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
order: 2;
|
order: 2;
|
||||||
right: 0;
|
right: 0;
|
||||||
height: 100%;
|
|
||||||
background: transparent;
|
background: transparent;
|
||||||
.discourse-no-touch & {
|
.discourse-no-touch & {
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|
@ -88,22 +91,8 @@ $max-width: 600px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-context,
|
.search-input .btn.search-context {
|
||||||
.results {
|
margin: 0;
|
||||||
margin: 0 auto;
|
|
||||||
max-width: $max-width;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-context {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 10;
|
|
||||||
right: 0;
|
|
||||||
top: 2.67em;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
label {
|
|
||||||
margin-right: 1em;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.results {
|
.results {
|
||||||
|
|
@ -111,7 +100,6 @@ $max-width: 600px;
|
||||||
background: var(--secondary);
|
background: var(--secondary);
|
||||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
|
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: $max-width;
|
|
||||||
z-index: 9;
|
z-index: 9;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,26 @@ export default apiInitializer("0.8", (api) => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
focusSearchInput() {
|
||||||
|
const searchInput =
|
||||||
|
this.state.formFactor === "widget"
|
||||||
|
? document.querySelector(".search-widget #search-term")
|
||||||
|
: document.querySelector(".search-menu #search-term");
|
||||||
|
|
||||||
|
searchInput.focus();
|
||||||
|
searchInput.select();
|
||||||
|
},
|
||||||
|
|
||||||
|
clearContext() {
|
||||||
|
this.sendWidgetAction("clearSearch");
|
||||||
|
this.sendWidgetAction("clearSearchWidgetContext");
|
||||||
|
this.state.inTopicContext = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
clearSearchWidgetContext() {
|
||||||
|
this.state.inTopicContext = false;
|
||||||
|
},
|
||||||
|
|
||||||
panelContents() {
|
panelContents() {
|
||||||
const formFactor = this.state.formFactor;
|
const formFactor = this.state.formFactor;
|
||||||
let showHeaderResults =
|
let showHeaderResults =
|
||||||
|
|
@ -100,12 +120,6 @@ export default apiInitializer("0.8", (api) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
contents = contents.concat(...corePanelContents.call(this));
|
contents = contents.concat(...corePanelContents.call(this));
|
||||||
let results = contents.find((w) => w.name === "search-menu-results");
|
|
||||||
if (results && results.attrs.results) {
|
|
||||||
$(".search-menu.search-header").addClass("has-results");
|
|
||||||
} else {
|
|
||||||
$(".search-menu.search-header").removeClass("has-results");
|
|
||||||
}
|
|
||||||
if (formFactor === "menu" || showHeaderResults) {
|
if (formFactor === "menu" || showHeaderResults) {
|
||||||
return contents;
|
return contents;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -121,17 +135,24 @@ export default apiInitializer("0.8", (api) => {
|
||||||
|
|
||||||
api.createWidget("search-widget", {
|
api.createWidget("search-widget", {
|
||||||
tagName: "div.search-widget",
|
tagName: "div.search-widget",
|
||||||
});
|
|
||||||
|
|
||||||
api.decorateWidget("search-widget:after", function (helper) {
|
html() {
|
||||||
const searchWidget = helper.widget;
|
const searchMenuVisible = this.state.searchVisible;
|
||||||
const searchMenuVisible = searchWidget.state.searchVisible;
|
|
||||||
|
|
||||||
if (!searchMenuVisible && !searchWidget.attrs.topic) {
|
if (!searchMenuVisible && !this.attrs.topic) {
|
||||||
return helper.attach("search-menu", {
|
return this.attach("search-menu", {
|
||||||
contextEnabled: searchWidget.state.contextEnabled,
|
contextEnabled: this.state.contextEnabled,
|
||||||
formFactor: "widget",
|
formFactor: "widget",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
clearSearchWidgetContext() {
|
||||||
|
this.state.inTopicContext = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
setTopicContext() {
|
||||||
|
this.state.inTopicContext = true;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-search-banner-wrap .results {
|
.search-menu .search-input input#search-term {
|
||||||
padding: 2em 0.5em 0.5em;
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-search-banner-wrap .search-icon {
|
||||||
|
top: 0.15em;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-context,
|
|
||||||
.results {
|
.results {
|
||||||
max-width: unset;
|
max-width: unset;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-context {
|
||||||
|
max-width: unset;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
> h1,
|
> h1,
|
||||||
> p {
|
> p {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
@ -107,7 +111,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input .searching {
|
.search-input .searching {
|
||||||
top: 0.75em;
|
top: 0.45em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-results {
|
.no-results {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue