From cb406f993ea94bfc75bf0e22edbc6c3c57bf939b Mon Sep 17 00:00:00 2001 From: "Jones, Michael Dean (Contractor)" Date: Thu, 29 Dec 2022 16:32:39 -0500 Subject: [PATCH] feat: UiFilter reset button only shows when there is something to reset --- addon/components/ui-filter/input/component.ts | 8 ++- addon/components/ui-filter/input/template.hbs | 21 ++++---- app/styles/_ui-foundation.scss | 3 ++ .../ui-foundation/components/_filter.scss | 52 +++++++++++++++++++ .../integration/components/ui-filter-test.ts | 6 +-- 5 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 app/styles/ui-foundation/components/_filter.scss diff --git a/addon/components/ui-filter/input/component.ts b/addon/components/ui-filter/input/component.ts index 519b274..503dabc 100644 --- a/addon/components/ui-filter/input/component.ts +++ b/addon/components/ui-filter/input/component.ts @@ -1,4 +1,4 @@ -import { className, layout } from '@ember-decorators/component'; +import { className, classNames, layout } from '@ember-decorators/component'; import { action } from '@ember/object'; import { empty, or } from '@ember/object/computed'; import Component from '@ember/component'; @@ -7,6 +7,7 @@ import template from './template'; /** * The UiFilterInput component */ +@classNames('ui-filter ui-filter-input') @layout(template) export default class UiFilterInput extends Component { /** @@ -29,6 +30,11 @@ export default class UiFilterInput extends Component { */ public showClearButton = false; + /** + * The name of the icon to use with the close button. + */ + public clearButtonIcon = 'times'; + /** * An array that will be used to populate a menu of options that can * be selected to auto-populate the text input. diff --git a/addon/components/ui-filter/input/template.hbs b/addon/components/ui-filter/input/template.hbs index 2ef2be6..ab1da71 100644 --- a/addon/components/ui-filter/input/template.hbs +++ b/addon/components/ui-filter/input/template.hbs @@ -25,17 +25,16 @@ oninput={{this.handleInputChange}} > -{{#if this.showClearButton}} - - - +{{#if (and this.showClearButton this.value)}} + {{/if}}