Skip to content

Commit d2f388a

Browse files
mm-form WIP
1 parent 6783ece commit d2f388a

9 files changed

Lines changed: 162 additions & 150 deletions

File tree

src/mm-form-message/mm-form-message.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<dom-module id="mm-form-message">
1212
<link rel="import" type="css" href="mm-form-message.css"/>
1313
<template>
14-
<mm-inline-box id="inputError" type="{{type}}" fitparent>{{message}}</mm-inline-box>
14+
<mm-inline-box id="inputError" type="{{type}}" visible$="{{visible}}" fitparent>{{message}}</mm-inline-box>
1515
</template>
1616
</dom-module>
1717

src/mm-form-message/mm-form-message.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
},
2020
message: {
2121
type: String
22+
},
23+
visible: {
24+
type: Boolean,
25+
value: false
2226
}
2327
},
2428

src/mm-form-message/mm-form-message.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@
99
:host {
1010
display: block;
1111
position: relative;
12+
}
13+
14+
mm-inline-box {
15+
display: none;
16+
}
17+
18+
mm-inline-box[visible] {
19+
display: block;
1220
}

src/mm-form/index.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646

4747
<!-- row 1 -->
4848
<div class="col" span="1">
49-
<mm-input fitparent name="input" placeholder="Type a Number" value="123"></mm-input>
49+
<mm-input fitparent name="input" placeholder="Type a Number"></mm-input>
5050
</div>
5151

5252
<div class="col" span="1">
53-
<mm-dropdown fitparent name="dropdown" placeholder="Select an Item" value="List Item 1">
53+
<mm-dropdown fitparent name="dropdown" placeholder="Select an Item">
5454
<mm-list-item>List Item 1</mm-list-item>
5555
<mm-list-item>List Item 2</mm-list-item>
5656
<mm-list-item>List Item 3</mm-list-item>
@@ -59,7 +59,7 @@
5959
</div>
6060

6161
<div class="col" span="2">
62-
<mm-group fitparent unresolved name="radio" value="Red">
62+
<mm-group fitparent unresolved name="radio">
6363
<mm-radio>
6464
<label>Red</label>
6565
</mm-radio>
@@ -89,7 +89,7 @@
8989

9090
<script>
9191

92-
var formData = {
92+
var data = {
9393
'input' : {
9494
validation: 'int|empty',
9595
errorMsg: 'You need to type a number',
@@ -101,7 +101,9 @@
101101
label: 'Select an Item'
102102
},
103103
'radio' : {
104-
validation: 'empty',
104+
validation: function(name, value, data) {
105+
return data[name] === 'Red' && value === 'Red';
106+
},
105107
errorMsg: 'You need to select a color',
106108
label: 'Select a Color'
107109
}
@@ -110,7 +112,7 @@
110112
window.addEventListener('WebComponentsReady', function(e) {
111113
var testForm = document.querySelector('#testForm');
112114

113-
testForm.data = formData;
115+
testForm.data = data;
114116

115117
testForm.addEventListener('serialize-form', function(e){
116118
console.log('serialize-form', e.detail);

0 commit comments

Comments
 (0)