Skip to content

Commit 940fb84

Browse files
committed
test(input): update e2e test to improve examples
1 parent 0d273c4 commit 940fb84

File tree

2 files changed

+272
-183
lines changed

2 files changed

+272
-183
lines changed

core/src/components/input/test/bottom-content/index.html

Lines changed: 70 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
<style>
1616
.grid {
1717
display: grid;
18-
grid-template-columns: repeat(3, minmax(250px, 1fr));
18+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
1919
grid-row-gap: 20px;
2020
grid-column-gap: 20px;
2121
}
22+
2223
h2 {
2324
font-size: 12px;
2425
font-weight: normal;
@@ -27,12 +28,6 @@
2728

2829
margin-top: 10px;
2930
}
30-
@media screen and (max-width: 800px) {
31-
.grid {
32-
grid-template-columns: 1fr;
33-
padding: 0;
34-
}
35-
}
3631

3732
ion-input.custom-error-color {
3833
--highlight-color-invalid: purple;
@@ -52,67 +47,111 @@
5247
<div class="grid">
5348
<div class="grid-item">
5449
<h2>No Hint</h2>
55-
<ion-input label="Email"></ion-input>
50+
<ion-input label="Label"></ion-input>
51+
</div>
52+
53+
<div class="grid-item">
54+
<h2>No Hint: Stacked</h2>
55+
<ion-input label="Label" label-placement="stacked"></ion-input>
5656
</div>
5757

5858
<div class="grid-item">
59-
<h2>Helper Hint</h2>
60-
<ion-input label="Email" helper-text="Enter your email"></ion-input>
59+
<h2>Helper Text</h2>
60+
<ion-input label="Label" helper-text="Helper text"></ion-input>
6161
</div>
6262

6363
<div class="grid-item">
64-
<h2>Error Hint</h2>
64+
<h2>Helper Text: Stacked</h2>
65+
<ion-input label="Label" label-placement="stacked" helper-text="Helper text"></ion-input>
66+
</div>
67+
68+
<div class="grid-item">
69+
<h2>Error Text</h2>
70+
<ion-input class="ion-touched ion-invalid" label="Label" error-text="Error text"></ion-input>
71+
</div>
72+
73+
<div class="grid-item">
74+
<h2>Error Text: Stacked</h2>
6575
<ion-input
6676
class="ion-touched ion-invalid"
67-
label="Email"
68-
error-text="Please enter a valid email"
77+
label="Label"
78+
label-placement="stacked"
79+
error-text="Error text"
6980
></ion-input>
7081
</div>
7182

7283
<div class="grid-item">
73-
<h2>Custom Error Color</h2>
84+
<h2>Error Text: Custom Color</h2>
7485
<ion-input
7586
class="ion-touched ion-invalid custom-error-color"
76-
label="Email"
77-
error-text="Please enter a valid email"
87+
label="Label"
88+
error-text="Error text"
7889
></ion-input>
7990
</div>
8091

92+
<div class="grid-item">
93+
<h2>Helper Text: Wrapping</h2>
94+
<ion-input
95+
label="Label"
96+
helper-text="Helper text helper text helper text helper text helper text helper text helper text helper text helper text"
97+
>
98+
</ion-input>
99+
</div>
100+
81101
<div class="grid-item">
82102
<h2>Counter</h2>
83-
<ion-input label="Email" counter="true" maxlength="100"></ion-input>
103+
<ion-input label="Label" counter="true" maxlength="100"></ion-input>
84104
</div>
85105

86106
<div class="grid-item">
87-
<h2>Custom Counter</h2>
88-
<ion-input id="custom-counter" label="Email" counter="true" maxlength="100"></ion-input>
107+
<h2>Counter: Custom</h2>
108+
<ion-input id="custom-counter" label="Label" counter="true" maxlength="100"></ion-input>
89109
</div>
90110

91111
<div class="grid-item">
92-
<h2>Counter with Helper</h2>
93-
<ion-input label="Email" counter="true" maxlength="100" helper-text="Enter an email"></ion-input>
112+
<h2>Counter: with Helper</h2>
113+
<ion-input label="Label" counter="true" maxlength="100" helper-text="Helper text"></ion-input>
94114
</div>
95115

96116
<div class="grid-item">
97-
<h2>Counter with Error</h2>
117+
<h2>Counter: with Error</h2>
98118
<ion-input
99119
class="ion-touched ion-invalid"
100-
label="Email"
120+
label="Label"
101121
counter="true"
102122
maxlength="100"
103-
error-text="Please enter a valid email"
123+
error-text="Error text"
104124
></ion-input>
105125
</div>
106126
</div>
107127

108-
<script>
109-
const customCounterInput = document.querySelector('ion-input#custom-counter');
110-
customCounterInput.counterFormatter = (inputLength, maxLength) => {
111-
const length = maxLength - inputLength;
112-
return `${maxLength - inputLength} characters left`;
113-
};
114-
</script>
128+
<button class="expand" onclick="toggleFill()">Toggle Fill</button>
115129
</ion-content>
116130
</ion-app>
131+
132+
<script>
133+
const customCounterInput = document.querySelector('ion-input#custom-counter');
134+
customCounterInput.counterFormatter = (inputLength, maxLength) => {
135+
const length = maxLength - inputLength;
136+
return `${maxLength - inputLength} characters left`;
137+
};
138+
139+
const inputs = document.querySelectorAll('ion-input');
140+
141+
function toggleFill() {
142+
inputs.forEach((input) => {
143+
switch (input.fill) {
144+
case 'outline':
145+
input.fill = 'solid';
146+
break;
147+
case 'solid':
148+
input.fill = undefined;
149+
break;
150+
default:
151+
input.fill = 'outline';
152+
}
153+
});
154+
}
155+
</script>
117156
</body>
118157
</html>

0 commit comments

Comments
 (0)