Skip to content

Commit edc44fd

Browse files
committed
examples.layout.card #5398
1 parent 38a58dc commit edc44fd

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import Button from '../../../src/button/Base.mjs';
2+
import CheckBox from '../../../src/form/field/CheckBox.mjs';
3+
import ComboBox from '../../../src/form/field/ComboBox.mjs';
4+
import ConfigurationViewport from '../../ConfigurationViewport.mjs';
5+
import Container from '../../../src/container/Base.mjs';
6+
import NumberField from '../../../src/form/field/Number.mjs';
7+
import Radio from '../../../src/form/field/Radio.mjs';
8+
import TextField from '../../../src/form/field/Text.mjs';
9+
import Toolbar from '../../../src/toolbar/Base.mjs';
10+
11+
/**
12+
* @class Neo.examples.layout.card.MainContainer
13+
* @extends Neo.examples.ConfigurationViewport
14+
*/
15+
class MainContainer extends ConfigurationViewport {
16+
static config = {
17+
className : 'Neo.examples.layout.card.MainContainer',
18+
configItemLabelWidth: 160,
19+
configItemWidth : 280,
20+
layout : {ntype: 'hbox', align: 'stretch'}
21+
}
22+
23+
createConfigurationComponents() {
24+
let me = this,
25+
{layout} = me.exampleComponent;
26+
27+
return [{
28+
module : Radio,
29+
checked : layout.slideDirection === 'bottom-left',
30+
hideValueLabel: false,
31+
labelText : 'slideDirection',
32+
listeners : {change: me.onRadioLayoutChange.bind(me, 'slideDirection', 'horizontal')},
33+
name : 'slideDirection',
34+
valueLabelText: 'horizontal'
35+
}, {
36+
module : Radio,
37+
checked : layout.slideDirection === 'vertical',
38+
hideValueLabel: false,
39+
labelText : '',
40+
listeners : {change: me.onRadioLayoutChange.bind(me, 'slideDirection', 'vertical')},
41+
name : 'slideDirection',
42+
valueLabelText: 'vertical'
43+
}, {
44+
module : Radio,
45+
checked : layout.slideDirection === null,
46+
hideValueLabel: false,
47+
labelText : '',
48+
listeners : {change: me.onRadioLayoutChange.bind(me, 'slideDirection', null)},
49+
name : 'slideDirection',
50+
valueLabelText: 'null'
51+
}, {
52+
module : NumberField,
53+
clearable : true,
54+
labelText : 'height',
55+
listeners : {change: me.onConfigChange.bind(me, 'height')},
56+
maxValue : 300,
57+
minValue : 30,
58+
stepSize : 5,
59+
style : {marginTop: '10px'},
60+
value : me.exampleComponent.height
61+
}, {
62+
module : NumberField,
63+
clearable : true,
64+
labelText : 'width',
65+
listeners : {change: me.onConfigChange.bind(me, 'width')},
66+
maxValue : 300,
67+
minValue : 100,
68+
stepSize : 5,
69+
style : {marginTop: '10px'},
70+
value : me.exampleComponent.width
71+
}];
72+
}
73+
74+
/**
75+
* @returns {Neo.component.Base}
76+
*/
77+
createExampleComponent() {
78+
return Neo.create({
79+
module : Container,
80+
height : 300,
81+
width : 400,
82+
83+
items: [{
84+
module: Container,
85+
layout: {ntype: 'card', slideDirection: 'horizontal'},
86+
items : [{
87+
style: {backgroundColor: 'red'}
88+
}, {
89+
style: {backgroundColor: 'blue'}
90+
}]
91+
}, {
92+
module: Toolbar,
93+
flex : 'none',
94+
items : [{
95+
handler: 'onNextButtonClick',
96+
text : 'Prev'
97+
}, '->', {
98+
handler: 'onPrevButtonClick',
99+
text : 'Next'
100+
}]
101+
}]
102+
})
103+
}
104+
105+
/**
106+
* @param {Object} data
107+
*/
108+
onNextButtonClick(data) {
109+
this.exampleComponent.layout.activeIndex++;
110+
}
111+
112+
/**
113+
* @param {String} config
114+
* @param {String} value
115+
* @param {Object} opts
116+
*/
117+
onRadioLayoutChange(config, value, opts) {
118+
if (opts.value === true) { // we only want to listen to check events, not uncheck
119+
this.exampleComponent.layout[config] = value;
120+
}
121+
}
122+
123+
/**
124+
* @param {Object} data
125+
*/
126+
onPrevButtonClick(data) {
127+
this.exampleComponent.layout.activeIndex--;
128+
}
129+
}
130+
131+
Neo.setupClass(MainContainer);
132+
133+
export default MainContainer;

examples/layout/card/app.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import MainContainer from './MainContainer.mjs';
2+
3+
export const onStart = () => Neo.app({
4+
mainView: MainContainer,
5+
name : 'Neo.examples.layout.card'
6+
});

examples/layout/card/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<meta name="viewport" content="width=device-width, initial-scale=1">
5+
<meta charset="UTF-8">
6+
<title>Neo Card Layout</title>
7+
</head>
8+
<body>
9+
<script src="../../../src/MicroLoader.mjs" type="module"></script>
10+
</body>
11+
</html>

examples/layout/card/neo-config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"appPath" : "examples/layout/card/app.mjs",
3+
"basePath" : "../../../",
4+
"environment": "development",
5+
"mainPath" : "./Main.mjs"
6+
}

0 commit comments

Comments
 (0)