-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #6008 Refactoring search component Fixes #6008 * rename main search class * #6008 fixed styles * #6008 - fixed toolbox search color * #6008 - fix toolbox search placeholder text * #6008 remove search from toolbox styles * #6008 fix propertygrid search placeholder * #6008 fix search clear button size
- Loading branch information
Showing
29 changed files
with
335 additions
and
291 deletions.
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
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
13 changes: 13 additions & 0 deletions
13
packages/survey-creator-angular/src/components/search.component.html
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,13 @@ | ||
<ng-template #template> | ||
<div *ngIf="model.isVisible" class="svc-search"> | ||
<div class="svc-search__search-icon"> | ||
<svg [iconName]="'icon-search'" [size]="'auto'" sv-ng-svg-icon></svg> | ||
</div> | ||
<input type="text" class="svc-search__input" [(ngModel)]="model.filterString" | ||
[attr.aria-label]="model.filterStringPlaceholder" [attr.placeholder]="model.filterStringPlaceholder" /> | ||
<div class="svc-search__toolbar"> | ||
<div class="svc-search__toolbar-counter">{{model.matchCounterText}}</div> | ||
<sv-action-bar [model]="model.searchActionBar"></sv-action-bar> | ||
</div> | ||
</div> | ||
</ng-template> |
File renamed without changes.
13 changes: 0 additions & 13 deletions
13
packages/survey-creator-angular/src/side-bar/search.component.html
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
packages/survey-creator-core/src/components/search-manager.ts
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,54 @@ | ||
import { Action, ActionContainer, Base, ComputedUpdater, property } from "survey-core"; | ||
import { getLocString } from "../editorLocalization"; | ||
|
||
export abstract class SearchManager extends Base { | ||
public searchActionBar: ActionContainer = new ActionContainer(); | ||
public get filterStringPlaceholder(): string { return this.getFilterStringPlaceholder(); } | ||
@property() filterString: string; | ||
@property() isVisible: boolean; | ||
@property() matchCounterText: string; | ||
|
||
protected getSearchActions() { | ||
return [new Action({ | ||
id: "svd-grid-search-close", | ||
iconName: "icon-clear_16x16", | ||
component: "sv-action-bar-item", | ||
title: getLocString("ed.clear"), | ||
showTitle: false, | ||
iconSize: "auto", | ||
disableTabStop: true, | ||
innerCss: "svc-search__bar-item", | ||
visible: <any>new ComputedUpdater(() => !!this.filterString), | ||
action: () => { | ||
this.clearFilterString(); | ||
} | ||
})]; | ||
} | ||
initActionBar() { | ||
this.searchActionBar.setItems(this.getSearchActions()); | ||
} | ||
public clearFilterString(): void { | ||
this.filterString = ""; | ||
} | ||
|
||
protected abstract setFiterString(newValue: string, oldValue: string); | ||
protected abstract getFilterStringPlaceholder(): string; | ||
|
||
protected onPropertyValueChanged(name: string, oldValue: any, newValue: any) { | ||
super.onPropertyValueChanged(name, oldValue, newValue); | ||
|
||
if (name === "filterString") { | ||
this.setFiterString(newValue, oldValue); | ||
} | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.initActionBar(); | ||
} | ||
|
||
dispose(): void { | ||
this.searchActionBar.dispose(); | ||
super.dispose(); | ||
} | ||
} |
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,74 @@ | ||
@import "../variables.scss"; | ||
.svc-search { | ||
// TODO remove v2 | ||
--sjs-general-forecolor: rgba(0, 0, 0, 0.91); | ||
--sjs-general-forecolor-light: rgba(0, 0, 0, 0.45); | ||
} | ||
|
||
.svc-search { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.svc-search__input { | ||
@include textEllipsis; | ||
@include ctrSmallBoldFont; | ||
|
||
border: none; | ||
-webkit-appearance: none; | ||
-moz-appearance: none; | ||
appearance: none; | ||
|
||
display: block; | ||
background: transparent; | ||
box-sizing: border-box; | ||
outline: none; | ||
padding: 0; | ||
width: 0; | ||
flex-grow: 1; | ||
} | ||
|
||
.svc-creator--mobile .svc-search__input { | ||
$fontSize: var(--ctr-font-small-size, #{calcSize(1.5)}); | ||
font-size: Max(16px, #{$fontSize}); | ||
} | ||
|
||
|
||
.svc-search__toolbar { | ||
display: flex; | ||
gap: var(--ctr-search-toolbar-gap, calcSize(1.5)); | ||
justify-content: flex-end; | ||
align-items: center; | ||
flex-shrink: 0; | ||
} | ||
|
||
.svc-search__toolbar .sv-action-bar { | ||
gap: var(--ctr-search-toolbar-gap, calcSize(0.5)); | ||
margin: 0; | ||
flex-shrink: 0; | ||
} | ||
|
||
.svc-search__toolbar .sv-action--hidden { | ||
display: none; | ||
} | ||
|
||
.svc-search__toolbar .svc-search__bar-item { | ||
height: min-content; | ||
margin: 0; | ||
border-radius: var(--ctr-search-button-corner-radius); | ||
padding: var(--ctr-search-button-padding-vertical, calcSize(0.5)) | ||
var(--ctr-search-button-padding-horizontal, calcSize(0.5)) var(--ctr-search-button-padding-vertical, calcSize(0.5)) | ||
var(--ctr-search-button-padding-horizontal, calcSize(0.5)); | ||
border-radius: 100px; | ||
|
||
.sv-svg-icon { | ||
width: var(--ctr-search-button-icon-width, calcSize(2)); | ||
height: var(--ctr-search-button-icon-height, calcSize(2)); | ||
} | ||
} | ||
|
||
.svc-search__toolbar-counter { | ||
@include ctrSmallBoldFont; | ||
display: flex; | ||
flex-shrink: 0; | ||
} |
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
24 changes: 24 additions & 0 deletions
24
packages/survey-creator-core/src/components/toolbox/toolbox-search-manager.ts
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,24 @@ | ||
import { property } from "survey-core"; | ||
import { getLocString } from "../../editorLocalization"; | ||
|
||
import { QuestionToolbox } from "../../toolbox"; | ||
import { SearchManager } from "../search-manager"; | ||
|
||
export class SearchManagerToolbox extends SearchManager { | ||
@property() toolbox: QuestionToolbox; | ||
protected getFilterStringPlaceholder(): string { return getLocString("ed.toolboxFilteredTextPlaceholder"); } | ||
protected setFiterString(newValue: string, oldValue: string) { | ||
this.toolbox.showSeparators = !newValue; | ||
this.toolbox.items.forEach(item => item.visible = item.hasText(newValue)); | ||
this.toolbox.showPlaceholder = !this.toolbox.items.filter(i => i.visible).length; | ||
this.toolbox.categories.forEach(category => { | ||
category.forceExpand = !!newValue; | ||
category.empty = category.items.filter(item => item.visible).length == 0; | ||
}); | ||
} | ||
|
||
public clearFilterString(): void { | ||
this.filterString = ""; | ||
this.toolbox.rootElement.querySelector("input").focus(); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
packages/survey-creator-core/src/components/toolbox/toolbox-search.scss
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,45 @@ | ||
@import "../../variables.scss"; | ||
|
||
.svc-toolbox { | ||
.svc-search { | ||
padding-top: var(--ctr-toolbox-search-padding-top, calcSize(2.5)); | ||
padding-inline-end: var(--ctr-toolbox-search-padding-right, calcSize(2)); | ||
padding-bottom: var(--ctr-toolbox-search-padding-bottom, calcSize(2.5)); | ||
padding-inline-start: var(--ctr-toolbox-search-padding-left, calcSize(3)); | ||
gap: var(--ctr-toolbox-search-gap, calcSize(1)); | ||
height: unset; | ||
|
||
width: unset; | ||
flex-grow: 1; | ||
border-bottom: none; | ||
} | ||
|
||
.svc-search__input { | ||
color: var(--ctr-toolbox-search-text-color, $foreground); | ||
} | ||
.svc-search__input::placeholder { | ||
color: var(--ctr-toolbox-search-text-color-placeholder, $foreground-light); | ||
} | ||
.svc-search__bar-item { | ||
&:hover:enabled { | ||
background-color: var(--ctr-toolbox-search-clear-button-background-color-hovered, $red-light); | ||
svg use { | ||
fill: var(--ctr-toolbox-search-clear-button-icon-color-hovered, $red); | ||
} | ||
} | ||
} | ||
|
||
.svc-search__search-icon { | ||
width: var(--ctr-toolbox-search-icon-width, calcSize(3)); | ||
height: var(--ctr-toolbox-search-icon-height, calcSize(3)); | ||
|
||
.sv-svg-icon { | ||
width: var(--ctr-toolbox-search-icon-width, calcSize(3)); | ||
height: var(--ctr-toolbox-search-icon-height, calcSize(3)); | ||
|
||
use { | ||
fill: var(--ctr-toolbox-search-icon-color, $foreground-light); | ||
} | ||
} | ||
} | ||
} |
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.