I`m trying to create a custom component for my ExtJS application (using extjs 6.0 and modern toolkit)
I`ve generated a new app and added a new View (extending Ext.Component), put some logic there. I am able to create this component with xtype but get stuck with theming.
So the question is: how to add a new component correctly (inside framework source / as a view in the app / somewhere else) and where to put sass for the component (generate a custom theme and insert it there / somewhere else)?
Component (located in app/view/components folder):
Ext.define("WebTest.view.components.IconButton", {
extend: 'Ext.Component',
xtype: 'iconbutton',
cachedConfig: {
pressedCls: Ext.baseCSSPrefix + 'iconbutton-pressing',
iconCls: null
},
config: {
handler: null,
scope: null,
baseCls: Ext.baseCSSPrefix + 'iconbutton' + ' ' + Ext.baseCSSPrefix + 'iconalign-center'
},
template: [
{
tag: 'span',
className: Ext.baseCSSPrefix + 'iconbutton-icon',
reference: 'iconElement'
}
],
............
ADDED:
I have tried different methods of adding component and theme (the goal is to change standard CSS and add custom).
Acceptable way (for me) is to put the custom component into ux.button folder
(as @Alexander mentioned) and to generate a new theme. Because of usage of two (in my case) different namespaces there is a need to clear namespace parameter in themes package.json. This gives an opportunity to add custom styles to src\MyAppNs\...\MyComponentClassName.scss
and also add or override for standard components (i.e. var\Ext\Component.scss
)
Also tried to use workspace, but this way is better for sharing components and themes between several applications. In this case component could be added as a package (like theme in the first way).
Finally, tried to add custom component to the framework source, but noticed that SenchaCMD does not support acting this way. Think, that it is not acceptable.