mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-30 17:14:50 +00:00
feat(search): ✨ clean up HTML structure
This commit is contained in:
parent
3ad890206d
commit
c35d86f43f
|
@ -31,7 +31,7 @@ function htmlHelper() {
|
||||||
* @return {HTMLElement|void}
|
* @return {HTMLElement|void}
|
||||||
*/
|
*/
|
||||||
getItemGroupElement: function ( data ) {
|
getItemGroupElement: function ( data ) {
|
||||||
const itemGroup = document.createElement( 'li' );
|
const itemGroup = document.createElement( 'div' );
|
||||||
itemGroup.classList.add( 'citizen-typeahead-item-group' );
|
itemGroup.classList.add( 'citizen-typeahead-item-group' );
|
||||||
itemGroup.setAttribute( 'data-mw-citizen-typeahead-group', `${ data.id }` );
|
itemGroup.setAttribute( 'data-mw-citizen-typeahead-group', `${ data.id }` );
|
||||||
itemGroup.setAttribute( 'role', 'presentation' );
|
itemGroup.setAttribute( 'role', 'presentation' );
|
||||||
|
|
|
@ -5,12 +5,15 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: var( --space-xs );
|
gap: var( --space-xs );
|
||||||
margin: 0;
|
|
||||||
list-style: none;
|
|
||||||
border-bottom-right-radius: var( --border-radius-medium );
|
border-bottom-right-radius: var( --border-radius-medium );
|
||||||
border-bottom-left-radius: var( --border-radius-medium );
|
border-bottom-left-radius: var( --border-radius-medium );
|
||||||
|
|
||||||
> li {
|
ol {
|
||||||
|
margin: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .citizen-typeahead-item-group {
|
||||||
&:first-of-type {
|
&:first-of-type {
|
||||||
margin-top: var( --space-xxs );
|
margin-top: var( --space-xxs );
|
||||||
}
|
}
|
||||||
|
@ -55,11 +58,6 @@
|
||||||
|
|
||||||
&-item {
|
&-item {
|
||||||
&-group {
|
&-group {
|
||||||
&-list {
|
|
||||||
margin: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Use a generic attribute
|
// FIXME: Use a generic attribute
|
||||||
&[ data-mw-citizen-typeahead-group='action' ] .citizen-typeahead-item-group-list {
|
&[ data-mw-citizen-typeahead-group='action' ] .citizen-typeahead-item-group-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
string msg-citizen-search-toggle Search toggle label
|
string msg-citizen-search-toggle Search toggle label
|
||||||
}}
|
}}
|
||||||
|
|
||||||
<ol id="searchform-suggestions" class="citizen-typeahead" role="listbox">
|
<div id="searchform-suggestions" class="citizen-typeahead" role="listbox">
|
||||||
{{! Template }}
|
{{! Template }}
|
||||||
<template id="citizen-typeahead-template">
|
<template id="citizen-typeahead-template">
|
||||||
<li class="citizen-typeahead__item">
|
<li class="citizen-typeahead__item">
|
||||||
|
@ -22,4 +22,4 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</ol>
|
</div>
|
|
@ -11,6 +11,8 @@ const searchHistory = require( './searchHistory.js' )( config );
|
||||||
const searchResults = require( './searchResults.js' )();
|
const searchResults = require( './searchResults.js' )();
|
||||||
const searchQuery = require( './searchQuery.js' )();
|
const searchQuery = require( './searchQuery.js' )();
|
||||||
|
|
||||||
|
const templateTypeaheadElement = require( './templates/TypeaheadElement.mustache' );
|
||||||
|
|
||||||
const typeahead = {
|
const typeahead = {
|
||||||
/** @type {HTMLElement | undefined} */
|
/** @type {HTMLElement | undefined} */
|
||||||
element: undefined,
|
element: undefined,
|
||||||
|
@ -310,12 +312,13 @@ const typeahead = {
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
init: function ( formEl, inputEl ) {
|
init: function ( formEl, inputEl ) {
|
||||||
const template = mw.template.get( 'skins.citizen.search', 'resources/skins.citizen.search/templates/typeahead.mustache' );
|
this.mustacheCompiler = mw.template.getCompiler( 'mustache' );
|
||||||
|
const compiledTemplateTypeaheadElement = this.mustacheCompiler.compile( templateTypeaheadElement );
|
||||||
const data = {
|
const data = {
|
||||||
'msg-searchsuggest-search': mw.message( 'searchsuggest-search' ).text(),
|
'msg-searchsuggest-search': mw.message( 'searchsuggest-search' ).text(),
|
||||||
'msg-citizen-search-empty-desc': mw.message( 'citizen-search-empty-desc' ).text()
|
'msg-citizen-search-empty-desc': mw.message( 'citizen-search-empty-desc' ).text()
|
||||||
};
|
};
|
||||||
this.element = template.render( data ).get()[ 1 ];
|
this.element = compiledTemplateTypeaheadElement.render( data ).get()[ 1 ];
|
||||||
formEl.after( this.element );
|
formEl.after( this.element );
|
||||||
|
|
||||||
this.form.init( formEl );
|
this.form.init( formEl );
|
||||||
|
|
|
@ -201,9 +201,6 @@
|
||||||
},
|
},
|
||||||
"skins.citizen.search": {
|
"skins.citizen.search": {
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"templates": [
|
|
||||||
"resources/skins.citizen.search/templates/typeahead.mustache"
|
|
||||||
],
|
|
||||||
"styles": [
|
"styles": [
|
||||||
"resources/skins.citizen.search/skins.citizen.search.less"
|
"resources/skins.citizen.search/skins.citizen.search.less"
|
||||||
],
|
],
|
||||||
|
@ -214,6 +211,11 @@
|
||||||
"callback": "MediaWiki\\Skins\\Citizen\\Hooks\\ResourceLoaderHooks::getCitizenSearchResourceLoaderConfig"
|
"callback": "MediaWiki\\Skins\\Citizen\\Hooks\\ResourceLoaderHooks::getCitizenSearchResourceLoaderConfig"
|
||||||
},
|
},
|
||||||
"resources/skins.citizen.search/typeahead.js",
|
"resources/skins.citizen.search/typeahead.js",
|
||||||
|
{
|
||||||
|
"name": "resources/skins.citizen.search/templates/TypeaheadElement.mustache",
|
||||||
|
"file": "resources/skins.citizen.search/templates/TypeaheadElement.mustache",
|
||||||
|
"type": "text"
|
||||||
|
},
|
||||||
"resources/skins.citizen.search/htmlHelper.js",
|
"resources/skins.citizen.search/htmlHelper.js",
|
||||||
"resources/skins.citizen.search/fetch.js",
|
"resources/skins.citizen.search/fetch.js",
|
||||||
"resources/skins.citizen.search/searchAction.js",
|
"resources/skins.citizen.search/searchAction.js",
|
||||||
|
@ -240,6 +242,7 @@
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"mediawiki.storage",
|
"mediawiki.storage",
|
||||||
|
"mediawiki.template.mustache",
|
||||||
"mediawiki.user",
|
"mediawiki.user",
|
||||||
"mediawiki.util"
|
"mediawiki.util"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue