-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extensable identifier): moved the geration of the namespace iden…
…tifier and if the class should be added to a mixin for easier exensability
- Loading branch information
Showing
4 changed files
with
66 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +0,0 @@ | ||
import Ember from 'ember'; | ||
import podNames from 'ember-component-css/pod-names'; | ||
|
||
const { | ||
Component, | ||
ComponentLookup, | ||
computed, | ||
getOwner | ||
} = Ember; | ||
|
||
ComponentLookup.reopen({ | ||
componentFor(name, owner) { | ||
owner = owner.hasRegistration ? owner : getOwner(this); | ||
|
||
if (podNames[name] && !owner.hasRegistration(`component:${name}`)) { | ||
owner.register(`component:${name}`, Component); | ||
} | ||
return this._super(...arguments); | ||
} | ||
}); | ||
|
||
Component.reopen({ | ||
_componentIdentifier: computed({ | ||
get() { | ||
return (this._debugContainerKey || '').replace('component:', ''); | ||
} | ||
}), | ||
|
||
componentCssClassName: computed({ | ||
get() { | ||
return podNames[this.get('_componentIdentifier')] || ''; | ||
} | ||
}), | ||
|
||
init() { | ||
this._super(...arguments); | ||
|
||
let name = this.get('componentCssClassName'); | ||
|
||
if (this.get('tagName') !== '' && name) { | ||
this.classNames = this.classNames.concat(name); | ||
} | ||
} | ||
}); | ||
|
||
export function initialize() {} | ||
|
||
export default { | ||
name: 'component-styles', | ||
initialize | ||
}; | ||
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,21 @@ | ||
import Ember from 'ember'; | ||
|
||
const { | ||
Component, | ||
computed, | ||
Mixin, | ||
} = Ember; | ||
|
||
export default Mixin.create({ | ||
_componentIdentifier: computed({ | ||
get() { | ||
return (this._debugContainerKey || '').replace('component:', ''); | ||
} | ||
}), | ||
|
||
_shouldAddNamespacedClassName: computed({ | ||
get() { | ||
return this.get('tagName') !== '' && this.get('componentCssClassName'); | ||
} | ||
}), | ||
}); |
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 +1,44 @@ | ||
export { default, initialize } from 'ember-component-css/initializers/component-styles'; | ||
import Ember from 'ember'; | ||
import podNames from 'ember-component-css/pod-names'; | ||
import StyleNamespacingExtras from '../mixins/style-namespacing-extras'; | ||
|
||
const { | ||
Component, | ||
ComponentLookup, | ||
computed, | ||
getOwner | ||
} = Ember; | ||
|
||
ComponentLookup.reopen({ | ||
componentFor(name, owner) { | ||
owner = owner.hasRegistration ? owner : getOwner(this); | ||
|
||
if (podNames[name] && !owner.hasRegistration(`component:${name}`)) { | ||
owner.register(`component:${name}`, Component); | ||
} | ||
return this._super(...arguments); | ||
} | ||
}); | ||
|
||
Component.reopen(StyleNamespacingExtras, { | ||
componentCssClassName: computed({ | ||
get() { | ||
return podNames[this.get('_componentIdentifier')] || ''; | ||
} | ||
}), | ||
|
||
init() { | ||
this._super(...arguments); | ||
|
||
if (this.get('_shouldAddNamespacedClassName')) { | ||
this.classNames = this.classNames.concat(this.get('componentCssClassName')); | ||
} | ||
} | ||
}); | ||
|
||
export function initialize() {} | ||
|
||
export default { | ||
name: 'component-styles', | ||
initialize | ||
}; |
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 'ember-component-css/mixins/style-namespacing-extras'; |