Skip to content

Commit

Permalink
feat: Peer review
Browse files Browse the repository at this point in the history
  • Loading branch information
Trishu-Patel committed Dec 17, 2024
1 parent 4676b7d commit 401ea43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
6 changes: 2 additions & 4 deletions apps/docs-app/app/components/f/form/search.gts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import FreestyleSection from 'ember-freestyle/components/freestyle-section';

import CodeBlock from '../../code-block';

// TypeScript doesn't recognize that this function is used in the template
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function log(...msg: string[]) {
console.log(msg.join(' '));
}
Expand Down Expand Up @@ -105,10 +103,10 @@ export default class extends Component {
minCharacters = 1;

@tracked
noResultsLabel = 'No results found';
noResultsLabel;

@tracked
placeholder = 'Search';
placeholder;

@tracked
readonly = false;
Expand Down
24 changes: 14 additions & 10 deletions packages/ember-core/src/components/form/search.gts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { action, get } from '@ember/object';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { restartableTask, timeout } from 'ember-concurrency';
import { t } from 'ember-intl';
// @ts-expect-error Ember keyboard doesn't currently ship a type for the `on-key` modifier
// https://github.com/adopted-ember-addons/ember-keyboard/issues/464
import onKey from 'ember-keyboard/modifiers/on-key';

import BoundValue from './bound-value.ts';
import onClickOutside from '../../modifiers/on-click-outside.ts';
import onInsert from '../../modifiers/on-insert.ts';
import Button from '../button.gts';

import type { Optional } from '../../';
import type IntlService from 'ember-intl/services/intl';

declare type SearchOption<T> = {
label: string;
Expand All @@ -30,9 +34,6 @@ interface SearchItemSignature<T> {
}

class SearchItem<T> extends Component<SearchItemSignature<T>> {
@tracked
active = true;

get classList() {
const classes = ['dropdown-item'];

Expand Down Expand Up @@ -104,6 +105,9 @@ export default class Search<T> extends BoundValue<
@tracked
searchString = '';

@service
declare intl: IntlService;

get clearable() {
if (this.args.basic) {
return false;
Expand All @@ -129,15 +133,15 @@ export default class Search<T> extends BoundValue<
}

get noResultsLabel() {
return this.args.noResultsLabel ?? 'No results found';
return this.args.noResultsLabel ?? this.intl.t('nrg.search.noResults');
}

get placeholder() {
if (this.args.basic) {
return '';
}

return this.args.placeholder ?? 'Search';
return this.args.placeholder ?? this.intl.t('nrg.search.placeholder');
}

get scrollable() {
Expand Down Expand Up @@ -392,13 +396,13 @@ export default class Search<T> extends BoundValue<
{{onInsert this.onSearchBarInsert}}
/>
{{#if this.clearable}}
<button
class="input-group-text"
type="button"
{{on "click" this.clear}}
<Button
aria-label={{t "nrg.base.clear"}}
class="btn-outline-secondary"
@onClick={{this.clear}}
>
<i class="bi bi-x-lg" />
</button>
</Button>
{{/if}}
</div>
<div class="dropdown {{if this.scrollable 'scrollable'}}">
Expand Down
7 changes: 6 additions & 1 deletion packages/ember-core/translations/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"loading": "Loading",
"next": "Next",
"previous": "Previous"
"previous": "Previous",
"clear" : "Clear"
},
"navbar": {
"toggleContextMenu": "Toggle context menu"
Expand All @@ -21,6 +22,10 @@
"select": {
"defaultText": "Select an Option"
},
"search": {
"placeholder": "Search",
"noResults": "No results found"
},
"validation": {
"confirmation": {
"invalid": "This field does not match {label}",
Expand Down

0 comments on commit 401ea43

Please sign in to comment.