-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove base class and modernize
- Loading branch information
1 parent
cdf7a10
commit 8885d0f
Showing
34 changed files
with
266 additions
and
438 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,50 +1,39 @@ | ||
import BaseTransformiconComponent from './-private/base'; | ||
import { computed, get } from '@ember/object'; | ||
import { className, classNames, layout } from '@ember-decorators/component'; | ||
import Component from '@ember/component'; | ||
import { assert } from '@ember/debug'; | ||
import { action } from '@ember/object'; | ||
import { layout, tagName } from '@ember-decorators/component'; | ||
import template from '../templates/components/t-form'; | ||
|
||
/** | ||
Form Transformicon | ||
PUBLIC | ||
* `is-searching` boolean - Set initial searching state. | ||
* `onclick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isSearching`, which is a boolean type indicating if the current state is searching or not searching. | ||
* `isSearching` boolean - Set initial searching state. | ||
* `onClick` closure action - The name of your consuming application's component/controller/route action to handle the transformicon click. Returned with 1 parameter `isSearching`, which is a boolean type indicating if the current state is searching or not searching. | ||
```hbs | ||
{{! These are functionally equivalent}} | ||
<TForm /> | ||
<TForm @is-searching={{false}} /> | ||
<TForm @isSearching={{false}} /> | ||
``` | ||
*/ | ||
@layout(template) | ||
@classNames('tcon-search--xcross') | ||
export default class TFormComponent extends BaseTransformiconComponent { | ||
label = 'toggle search'; | ||
initialState = 'is-searching'; | ||
|
||
@tagName('') | ||
export default class TFormComponent extends Component { | ||
/** | ||
* Flag to indicate the state of this transformicon | ||
* @type {boolean} | ||
*/ | ||
// 'is-searching' = false; | ||
isSearching = false; | ||
|
||
constructor() { | ||
super(...arguments); | ||
@action | ||
clickHandler() { | ||
this.toggleProperty('isSearching'); | ||
|
||
// NOTE: ESDoc does not currently support parsing a quoted and dasherized class field. Adding | ||
// here from the constructor as a temporary workaround. | ||
// https://github.com/esdoc/esdoc/issues/519#issuecomment-417895936 | ||
this['is-searching'] = false; | ||
} | ||
if (this.onClick) { | ||
assert(`[ember-transformicons] ${this.toString()} \`onClick\` action handler must be a valid closure action`, typeof this.onClick === 'function'); | ||
|
||
/** | ||
* Get the {@link transformClass} CSS classname representing the `is-searching` toggled state | ||
* for this transformicon | ||
* @type {string|boolean} | ||
*/ | ||
@className | ||
@computed('is-searching') | ||
get isSearching() { | ||
return get(this, 'is-searching') ? get(this, 'transformClass') : false; | ||
this.onClick(this.isSearching); | ||
} | ||
} | ||
} |
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.