-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: user can select a facet value eg category which is not yet displayed - fixes #125 #134
Merged
alexgarel
merged 47 commits into
main
from
125-user-can-select-a-facet-value-eg-category-which-is-not-yet-displayed
Jun 12, 2024
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
42d016f
feat: add autocomplete and start to search facet
Kout95 105c424
fix
Kout95 d3d533f
fix: lint and move mixins to /mixins
Kout95 79f4400
fix: bind this to debounce fn
Kout95 754b07e
feat: link autocomplete data
Kout95 667aa3e
fix: checkbox
Kout95 6c00f40
feat: add showOther property
Kout95 3364a3d
feat: add global reset-button.ts
Kout95 570a9da
fix
Kout95 7c03773
fix: show other only in some facet and fix checkbox
Kout95 c49bea0
feat: add --searchalicious-hover-color
Kout95 d79f2c3
feat: add --searchalicious-autocomplete-selected-background-color
Kout95 7e04715
fix: weird behaviour on firefox
Kout95 d788f1c
Update frontend/src/mixins/utils.ts
Kout95 ad61231
feat: add comments
Kout95 f06ac94
feat: add comments
Kout95 6d64352
feat: add comments
Kout95 442e525
refacto: handleKeyDown to improve readibility
Kout95 bfc5a8e
refacto: handleKeyDown to improve readibility
Kout95 895775b
docs: add comment to handleInput
Kout95 ddbd6e1
docs: add comment to handleInput
Kout95 19a2dda
docs: add comment to handleInput
Kout95 77a6f2f
docs: add docs
Kout95 b857d69
docs: add docs
Kout95 17d902a
docs: add docs
Kout95 0f2e7bf
Update frontend/src/search-autocomplete.ts
Kout95 418c6f8
Update frontend/src/mixins/taxonomies-ctl.ts
Kout95 a5921fe
Update frontend/src/mixins/taxonomies-ctl.ts
Kout95 1dc2ab4
Update frontend/src/search-facets.ts
Kout95 1fe348b
Update frontend/src/search-checkbox.ts
Kout95 635660b
Update frontend/src/mixins/taxonomies-ctl.ts
Kout95 cfeaa1e
refacto: fix vars and rename file
Kout95 c35b301
feat: add part
Kout95 3c674ca
feat: add comments
Kout95 84bc534
feat: add comments
Kout95 8aeb289
feat: add comments
Kout95 61d49f2
feat: add comments
Kout95 ba0212e
feat: add comments
Kout95 9ed4e4b
Apply suggestions from code review
Kout95 403cec7
fix: lint
Kout95 40def3a
fix: add enum
Kout95 46b7d0e
feat: clean code, modify reset button in facet, update reset filters …
Kout95 b5a0bee
feat: add margin top to fieldset
Kout95 bfc0dc2
docs
Kout95 67c6fc7
docs
Kout95 8cf0a9b
refacto button-transparent
Kout95 5eebce0
fix
Kout95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import {LitElement, html, css} from 'lit'; | ||
import {customElement} from 'lit/decorators.js'; | ||
|
||
import {BasicEvents} from './utils/enums'; | ||
|
||
/** | ||
* A custom element that represents a button without background for a search. | ||
* It sends a custom event "click" when clicked. | ||
* It exists to have already styled button for secondary actions. | ||
* You can modify this variable to customize the button style : | ||
* --button-transparent-padding | ||
* --secondary-hover-color | ||
* @extends {LitElement} | ||
* @slot - This slot is for the button contents, default to "Search" string. | ||
*/ | ||
@customElement('searchalicious-button-transparent') | ||
export class SearchaliciousButtonTransparent extends LitElement { | ||
static override styles = css` | ||
.button-transparent { | ||
background-color: transparent; | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: none; | ||
border-radius: 3.5rem; | ||
cursor: pointer; | ||
padding: var(--button-transparent-padding, 0.25rem 0.5rem); | ||
} | ||
.button-transparent:hover { | ||
background-color: var(--secondary-hover-color, #cfac9e); | ||
} | ||
`; | ||
|
||
private _onClick() { | ||
this._dispatchEvent(); | ||
} | ||
|
||
private _onKeyUp(event: Event) { | ||
const kbd_event = event as KeyboardEvent; | ||
if (kbd_event.key === 'Enter') { | ||
this._dispatchEvent(); | ||
} | ||
} | ||
|
||
private _dispatchEvent() { | ||
this.dispatchEvent( | ||
new CustomEvent(BasicEvents.CLICK, {bubbles: true, composed: true}) | ||
); | ||
} | ||
|
||
override render() { | ||
return html` | ||
<button | ||
@click=${this._onClick} | ||
@keyup=${this._onKeyUp} | ||
part="button-transparent" | ||
role="button" | ||
class="button-transparent" | ||
type="button" | ||
> | ||
<slot></slot> | ||
</button> | ||
`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'searchalicious-button-transparent': SearchaliciousButtonTransparent; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {LitElement, html, css} from 'lit'; | ||
import {customElement} from 'lit/decorators.js'; | ||
|
||
/** | ||
* A custom element that represents a cross icon. | ||
* You can modify this variable to customize the icon style : | ||
* --icon-width by default 0.8rem | ||
* --icon-stroke-color by default black | ||
*/ | ||
@customElement('searchalicious-icon-cross') | ||
export class SearchaliciousIconCross extends LitElement { | ||
static override styles = css` | ||
svg { | ||
width: var(--icon-width, 0.8rem); | ||
} | ||
svg line { | ||
stroke: var(--icon-stroke-color, black); | ||
} | ||
`; | ||
override render() { | ||
return html` | ||
<svg | ||
part="icon-cross" | ||
viewBox="0 0 100 100" | ||
preserveAspectRatio="xMidYMid meet" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<line | ||
x1="10" | ||
y1="10" | ||
x2="90" | ||
y2="90" | ||
style="stroke:black;stroke-width:10" | ||
/> | ||
<line | ||
x1="90" | ||
y1="10" | ||
x2="10" | ||
y2="90" | ||
style="stroke:black;stroke-width:10" | ||
/> | ||
</svg> | ||
`; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'searchalicious-icon-cross': SearchaliciousIconCross; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {LitElement} from 'lit'; | ||
import {Constructor} from './utils'; | ||
|
||
/** | ||
* Interface for the DebounceMixin. | ||
* It defines the structure that DebounceMixin should adhere to. | ||
*/ | ||
export interface DebounceMixinInterface { | ||
timeout?: number; | ||
debounce<F extends () => void>(func: F, wait?: number): void; | ||
} | ||
|
||
/** | ||
* A mixin class for debouncing function calls. | ||
* It extends the LitElement class and adds debouncing functionality. | ||
* It is used to prevent a function from being called multiple times in a short period of time. | ||
* It is usefull to avoid multiple calls to a function when the user is typing in an input field. | ||
* @param {Constructor<LitElement>} superClass - The superclass to extend from. | ||
* @returns {Constructor<DebounceMixinInterface> & T} - The extended class with debouncing functionality. | ||
*/ | ||
export const DebounceMixin = <T extends Constructor<LitElement>>( | ||
superClass: T | ||
): Constructor<DebounceMixinInterface> & T => | ||
class extends superClass { | ||
timeout?: number = undefined; | ||
|
||
/** | ||
* Debounces a function call. | ||
* It delays the execution of the function until after wait milliseconds have elapsed since the last time this function was invoked. | ||
* @param {Function} func - The function to debounce. | ||
* @param {number} wait - The number of milliseconds to delay. | ||
*/ | ||
debounce<F extends () => void>(func: F, wait = 300): void { | ||
// eslint-disable-next-line @typescript-eslint/no-this-alias | ||
const self = this; | ||
clearTimeout(this.timeout); | ||
this.timeout = setTimeout(() => { | ||
this.timeout = undefined; | ||
func.bind(self)(); | ||
}, wait); | ||
} | ||
} as Constructor<DebounceMixinInterface> & T; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {LitElement} from 'lit'; | ||
import {Constructor} from './utils'; | ||
import {BaseSearchDetail, LaunchSearchEvent} from '../events'; | ||
import {SearchaliciousEvents} from '../utils/enums'; | ||
import {property} from 'lit/decorators.js'; | ||
|
||
export interface SearchActionMixinInterface { | ||
searchName: string; | ||
_launchSearch(): Promise<void>; | ||
} | ||
|
||
/** | ||
* A mixin class for search actions. | ||
* It extends the LitElement class and adds search functionality. | ||
* It is used to launch a search event. | ||
* @param {Constructor<LitElement>} superClass - The superclass to extend from. | ||
* @returns {Constructor<SearchActionMixinInterface> & T} - The extended class with search functionality. | ||
*/ | ||
export const SearchActionMixin = <T extends Constructor<LitElement>>( | ||
Kout95 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
superClass: T | ||
): Constructor<SearchActionMixinInterface> & T => { | ||
class SearchActionMixinClass extends superClass { | ||
@property({attribute: 'search-name'}) | ||
searchName = 'searchalicious'; | ||
|
||
/** | ||
* Launches a search event. | ||
* It creates a new event with the search name and dispatches it. | ||
*/ | ||
_launchSearch() { | ||
const detail: BaseSearchDetail = {searchName: this.searchName}; | ||
// fire the search event | ||
const event = new CustomEvent(SearchaliciousEvents.LAUNCH_SEARCH, { | ||
bubbles: true, | ||
composed: true, | ||
detail: detail, | ||
}) as LaunchSearchEvent; | ||
this.dispatchEvent(event); | ||
} | ||
} | ||
|
||
return SearchActionMixinClass as Constructor<SearchActionMixinInterface> & T; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great comment :-)