-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of tf-input, tf-input-group, and tf-textarea
- Loading branch information
Showing
20 changed files
with
402 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
@module ticketfly-fields | ||
*/ | ||
import Ember from 'ember'; | ||
import layout from './template'; | ||
const { Component, guidFor, computed } = Ember; | ||
|
||
/** | ||
@public | ||
@class TfInputGroup | ||
@extends Ember.Component | ||
*/ | ||
export default Component.extend({ | ||
layout, | ||
|
||
classNames: ['c-input-group'], | ||
|
||
inputGuid: computed({ | ||
get() { | ||
return `id-${guidFor(this)}`; | ||
} | ||
}), | ||
|
||
describedByGuid: computed({ | ||
get() { | ||
return `described-by-${guidFor(this)}`; | ||
} | ||
}) | ||
}); |
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,18 @@ | ||
{{yield (hash | ||
label=(component 'tf-input/input-label' | ||
sizeStyle=sizeStyle | ||
for=inputGuid | ||
shouldValidate=shouldValidate | ||
isValid=isValid) | ||
input=(component 'tf-input' | ||
sizeStyle=sizeStyle | ||
id=inputGuid | ||
aria-describedby=describedByGuid | ||
shouldValidate=shouldValidate | ||
isValid=isValid) | ||
description=(component 'tf-input/input-description' | ||
sizeStyle=sizeStyle | ||
id=describedByGuid | ||
shouldValidate=shouldValidate | ||
isValid=isValid) | ||
)}} |
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,18 @@ | ||
/** | ||
@module ticketfly-fields | ||
*/ | ||
import Ember from 'ember'; | ||
import SizingMixin from 'ticketfly-fields/mixins/sizing-mixin'; | ||
import ValidityMixin from 'ticketfly-fields/mixins/validity-mixin'; | ||
const { TextField } = Ember; | ||
|
||
/** | ||
@public | ||
@class TfInput | ||
@extends Ember.TextField | ||
*/ | ||
export default TextField.extend(SizingMixin, ValidityMixin, { | ||
classNames: ['c-input'], | ||
classNameBindings: ['sizing', 'validity'], | ||
attributeBindings: ['aria-describedby'] | ||
}); |
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,27 @@ | ||
/** | ||
@module ticketfly-fields | ||
*/ | ||
import Ember from 'ember'; | ||
import SizingMixin from 'ticketfly-fields/mixins/sizing-mixin'; | ||
import ValidityMixin from 'ticketfly-fields/mixins/validity-mixin'; | ||
import layout from './template'; | ||
const { Component } = Ember; | ||
|
||
/** | ||
@class TfInputDescription | ||
@extends Ember.Computed | ||
*/ | ||
const InputDescriptionComponent = Component.extend(SizingMixin, ValidityMixin, { | ||
layout, | ||
|
||
tagName: 'p', | ||
classNameBindings: ['sizing', 'validity'], | ||
|
||
utilityName: 'description' | ||
}); | ||
|
||
InputDescriptionComponent.reopenClass({ | ||
positionalParams: ['text'] | ||
}); | ||
|
||
export default InputDescriptionComponent; |
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 @@ | ||
{{text}} |
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,26 @@ | ||
/** | ||
@module ticketfly-fields | ||
*/ | ||
import Ember from 'ember'; | ||
import SizingMixin from 'ticketfly-fields/mixins/sizing-mixin'; | ||
import ValidityMixin from 'ticketfly-fields/mixins/validity-mixin'; | ||
import layout from './template'; | ||
const { Component } = Ember; | ||
|
||
/** | ||
@class TfInputLabel | ||
@extends Ember.Computed | ||
*/ | ||
const InputLabelComponent = Component.extend(SizingMixin, ValidityMixin, { | ||
layout, | ||
|
||
tagName: 'label', | ||
classNameBindings: ['sizing', 'validity'], | ||
attributeBindings: ['for'] | ||
}); | ||
|
||
InputLabelComponent.reopenClass({ | ||
positionalParams: ['text'] | ||
}); | ||
|
||
export default InputLabelComponent; |
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 @@ | ||
{{text}} |
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,14 @@ | ||
/** | ||
@module ticketfly-fields | ||
*/ | ||
import Ember from 'ember'; | ||
const { TextArea } = Ember; | ||
|
||
/** | ||
@public | ||
@class TfTextarea | ||
@extends Ember.TextArea | ||
*/ | ||
export default TextArea.extend({ | ||
classNames: ['c-textarea'] | ||
}); |
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,38 @@ | ||
/** | ||
* @module ticketfly-fields | ||
*/ | ||
import Ember from 'ember'; | ||
const { Mixin, computed, get } = Ember; | ||
|
||
/** | ||
@class SizingMixin | ||
@extends Ember.Mixin | ||
*/ | ||
export default Mixin.create({ | ||
sizing: computed('sizeStyle','utilityName', { | ||
get() { | ||
const sizeStyle = get(this, 'sizeStyle'); | ||
if (sizeStyle) { | ||
const utilityName = get(this, 'utilityName'); | ||
return `u-${utilityName}-${sizeStyle}`; | ||
} | ||
} | ||
}), | ||
|
||
/** | ||
Override the utilityName property for a more unique sizing class name. | ||
Defaults to the class' tagName | ||
Example | ||
If the tagName of the component is 'p', one can set the utilityName to change | ||
the return value of sizing: | ||
```javascript | ||
get(this, 'sizing'); // 'u-p-large' | ||
set(this, 'utilityName', 'description'); | ||
get(this, 'sizing'); // 'u-description-large' | ||
``` | ||
*/ | ||
utilityName: computed.oneWay('tagName') | ||
}); |
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,22 @@ | ||
/** | ||
* @module ticketfly-fields | ||
*/ | ||
import Ember from 'ember'; | ||
const { Mixin, computed, get } = Ember; | ||
|
||
/** | ||
@class ValidityMixin | ||
@extends Ember.Mixin | ||
*/ | ||
export default Mixin.create({ | ||
shouldValidate: false, | ||
isValid: false, | ||
|
||
validity: computed('shouldValidate','isValid', { | ||
get() { | ||
if (get(this, 'shouldValidate')) { | ||
return get(this, 'isValid') ? 'is-valid' : 'is-invalid'; | ||
} | ||
} | ||
}) | ||
}); |
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 @@ | ||
export { default } from 'ticketfly-fields/components/tf-input-group/component'; |
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 @@ | ||
export { default } from 'ticketfly-fields/components/tf-input/component'; |
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 @@ | ||
export { default } from 'ticketfly-fields/components/tf-input/input-description/component'; |
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 @@ | ||
export { default } from 'ticketfly-fields/components/tf-input/input-label/component'; |
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 @@ | ||
export { default } from 'ticketfly-fields/components/tf-textarea/component'; |
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.