Skip to content

Commit

Permalink
chore: Linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Trishu-Patel committed Dec 17, 2024
1 parent fe5dcd3 commit 46b5cb0
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 60 deletions.
93 changes: 62 additions & 31 deletions apps/docs-app/app/components/f/form/search.gts
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,63 @@ export default class extends Component {
hideSearchIcon = false;

@tracked
stringOptions = ["Apple", "Pear", "Orange", "Banana", "Grape", "Strawberry", "Mango", "Pineapple", "Peach", "Cherry", "Blueberry", "Watermelon", "Papaya", "Kiwi", "Plum", "Apricot", "Pomegranate", "Lemon", "Lime", "Raspberry", "Blackberry", "Coconut", "Dragon fruit", "Lychee", "Fig", "Tangerine" ];
stringOptions = [
'Apple',
'Pear',
'Orange',
'Banana',
'Grape',
'Strawberry',
'Mango',
'Pineapple',
'Peach',
'Cherry',
'Blueberry',
'Watermelon',
'Papaya',
'Kiwi',
'Plum',
'Apricot',
'Pomegranate',
'Lemon',
'Lime',
'Raspberry',
'Blackberry',
'Coconut',
'Dragon fruit',
'Lychee',
'Fig',
'Tangerine',
];

@tracked
objectOptions = [
{ key: "Option 1", fruit: "Apple"},
{ key: "Option 2", fruit: "Pear"},
{ key: "Option 3", fruit: "Orange"},
{ key: "Option 4", fruit: "Banana"},
{ key: "Option 5", fruit: "Grape"},
{ key: "Option 6", fruit: "Strawberry"},
{ key: "Option 7", fruit: "Mango"},
{ key: "Option 8", fruit: "Pineapple"},
{ key: "Option 9", fruit: "Peach"},
{ key: "Option 10", fruit: "Cherry"},
{ key: "Option 11", fruit: "Blueberry"},
{ key: "Option 12", fruit: "Watermelon"},
{ key: "Option 13", fruit: "Papaya"},
{ key: "Option 14", fruit: "Kiwi"},
{ key: "Option 15", fruit: "Plum"},
{ key: "Option 16", fruit: "Apricot"},
{ key: "Option 17", fruit: "Pomegranate"},
{ key: "Option 18", fruit: "Lemon"},
{ key: "Option 19", fruit: "Lime"},
{ key: "Option 20", fruit: "Raspberry"},
{ key: "Option 21", fruit: "Blackberry"},
{ key: "Option 22", fruit: "Coconut"},
{ key: "Option 23", fruit: "Dragon fruit"},
{ key: "Option 24", fruit: "Lychee"},
{ key: "Option 25", fruit: "Fig"},
{ key: "Option 26", fruit: "Tangerine"}
{ key: 'Option 1', fruit: 'Apple' },
{ key: 'Option 2', fruit: 'Pear' },
{ key: 'Option 3', fruit: 'Orange' },
{ key: 'Option 4', fruit: 'Banana' },
{ key: 'Option 5', fruit: 'Grape' },
{ key: 'Option 6', fruit: 'Strawberry' },
{ key: 'Option 7', fruit: 'Mango' },
{ key: 'Option 8', fruit: 'Pineapple' },
{ key: 'Option 9', fruit: 'Peach' },
{ key: 'Option 10', fruit: 'Cherry' },
{ key: 'Option 11', fruit: 'Blueberry' },
{ key: 'Option 12', fruit: 'Watermelon' },
{ key: 'Option 13', fruit: 'Papaya' },
{ key: 'Option 14', fruit: 'Kiwi' },
{ key: 'Option 15', fruit: 'Plum' },
{ key: 'Option 16', fruit: 'Apricot' },
{ key: 'Option 17', fruit: 'Pomegranate' },
{ key: 'Option 18', fruit: 'Lemon' },
{ key: 'Option 19', fruit: 'Lime' },
{ key: 'Option 20', fruit: 'Raspberry' },
{ key: 'Option 21', fruit: 'Blackberry' },
{ key: 'Option 22', fruit: 'Coconut' },
{ key: 'Option 23', fruit: 'Dragon fruit' },
{ key: 'Option 24', fruit: 'Lychee' },
{ key: 'Option 25', fruit: 'Fig' },
{ key: 'Option 26', fruit: 'Tangerine' },
];

@tracked
Expand All @@ -78,10 +105,10 @@ export default class extends Component {
minCharacters = 1;

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

@tracked
placeholder = "Search";
placeholder = 'Search';

@tracked
readonly = false;
Expand All @@ -98,14 +125,18 @@ export default class extends Component {
@action
async stringQuery(searchString: string) {
await timeout(1000);
return this.stringOptions.filter((item) => item.toLowerCase().includes(searchString.toLowerCase()));
return this.stringOptions.filter((item) =>
item.toLowerCase().includes(searchString.toLowerCase()),
);
}

@action
async objectQuery(searchString: string) {
await timeout(1000);

const things = this.objectOptions.filter((item) => item.fruit.toLowerCase().includes(searchString.toLowerCase()));
const things = this.objectOptions.filter((item) =>
item.fruit.toLowerCase().includes(searchString.toLowerCase()),
);
return things;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/docs-app/app/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Router.map(function () {
this.route('datetime');
this.route('phone-input');
this.route('radio-group');
this.route('search')
this.route('search');
this.route('select');
this.route('text-area');
this.route('text-input');
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-app/app/templates/components.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<Item @name="Checkbox Group" @route="components.form.checkbox-group" />
<Item @name="Phone Input" @route="components.form.phone-input" />
<Item @name="Radio Group" @route="components.form.radio-group" />
<Item @name="Search" @route="components.form.search"/>
<Item @name="Search" @route="components.form.search" />
<Item @name="Select" @route="components.form.select" />
<Item @name="Text Area" @route="components.form.text-area" />
<Item @name="Text Input" @route="components.form.text-input" />
Expand Down
5 changes: 3 additions & 2 deletions packages/design-system/src/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ select,
}
}
&:not([disabled]) {
&:not(input[type='checkbox']):not(input[type='radio']) {
&:not(input[type="checkbox"]):not(input[type="radio"]) {
background: inherit !important;
padding-right: revert !important;
}
Expand Down Expand Up @@ -136,7 +136,8 @@ input::placeholder {
background-color: var(--bs-secondary-bg);
}

&:hover, &.active {
&:hover,
&.active {
background-color: var(--bs-secondary-bg);
}

Expand Down
51 changes: 28 additions & 23 deletions packages/ember-core/src/components/form/search.gts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,26 @@ class SearchItem<T> extends Component<SearchItemSignature<T>> {
active = true;

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

if (this.isActiveIndex) {
classes.push('active');
}

return classes.join(' ');
if (this.isActive) {
classes.push('active');
}

get isActiveIndex() {
return classes.join(' ');
}

get isActive() {
return this.args.activeIndex === this.args.index;
}

<template>
<li class={{this.classList}} role="option" ...attributes>{{this.args.option.label}}</li>
<li
class={{this.classList}}
role="option"
aria-selected={{this.isActive}}
...attributes
>{{@option.label}}</li>
</template>
}

Expand Down Expand Up @@ -77,7 +82,10 @@ export interface SearchSignature<T> {
Element: HTMLDivElement;
}

export default class Search<T> extends BoundValue<SearchSignature<T>, string | T> {
export default class Search<T> extends BoundValue<
SearchSignature<T>,
string | T
> {
@tracked
activeIndex = -1;

Expand Down Expand Up @@ -121,15 +129,15 @@ export default class Search<T> extends BoundValue<SearchSignature<T>, string | T
}

get noResultsLabel() {
return this.args.noResultsLabel ?? "No results found";
return this.args.noResultsLabel ?? 'No results found';
}

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

return this.args.placeholder ?? "Search";
return this.args.placeholder ?? 'Search';
}

get scrollable() {
Expand All @@ -140,7 +148,7 @@ export default class Search<T> extends BoundValue<SearchSignature<T>, string | T
return this.args.searchTimeout ?? 300;
}

get canPerformSearch () {
get canPerformSearch() {
return this.searchString.trim().length >= this.minCharacters;
}

Expand Down Expand Up @@ -267,7 +275,7 @@ export default class Search<T> extends BoundValue<SearchSignature<T>, string | T
this.activeIndex--;
this.scrollActiveOptionIntoView();
}
}
}

@action
moveDown(evt: KeyboardEvent) {
Expand Down Expand Up @@ -335,7 +343,7 @@ export default class Search<T> extends BoundValue<SearchSignature<T>, string | T

@action
clear() {
this.searchString = ''
this.searchString = '';
this.value = '';
this.activeIndex = -1;

Expand All @@ -353,18 +361,14 @@ export default class Search<T> extends BoundValue<SearchSignature<T>, string | T
}

<template>
<div
class={{this.classList}}
{{onClickOutside this.onBlur}}
...attributes
>
<div class={{this.classList}} {{onClickOutside this.onBlur}} ...attributes>
<div class="input-group">
{{#unless this.hideSearchIcon}}
<span class="input-group-text">
{{#if this.loading}}
<span class="spinner-border spinner-border-sm"/>
<span class="spinner-border spinner-border-sm" />
{{else}}
<i class="bi bi-search"/>
<i class="bi bi-search" />
{{/if}}
</span>
{{/unless}}
Expand All @@ -390,9 +394,10 @@ export default class Search<T> extends BoundValue<SearchSignature<T>, string | T
{{#if this.clearable}}
<button
class="input-group-text"
type="button"
{{on "click" this.clear}}
>
<i class="bi bi-x-lg"/>
<i class="bi bi-x-lg" />
</button>
{{/if}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-core/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { default as Field } from './form/field.gts';
export { default as Form } from './form/index.gts';
export { default as PhoneInput } from './form/phone-input.gts';
export { default as RadioGroup } from './form/radio-group.gts';
export { default as Search } from './form/search.gts'
export { default as Search } from './form/search.gts';
export { default as Select } from './form/select.gts';
export { default as TextArea } from './form/text-area.gts';
export { default as TextInput } from './form/text-input.gts';
Expand Down
5 changes: 4 additions & 1 deletion packages/ember-core/src/template-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,7 @@ export interface ModifierRegistry {
'on-update': typeof OnUpdate;
}

export default interface TemplateRegistry extends ComponentRegistry, HelperRegistry, ModifierRegistry {}
export default interface TemplateRegistry
extends ComponentRegistry,
HelperRegistry,
ModifierRegistry {}

0 comments on commit 46b5cb0

Please sign in to comment.