Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(input): update helper text and counter color #30149

Open
wants to merge 16 commits into
base: feature-8.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions core/src/components/input/input.md.solid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
--border-color: var(--highlight-color);
}

/**
* The bottom content should never have
* a border with the solid style.
*/
:host(.input-fill-solid) .input-bottom {
border-top: none;
}
Expand Down
6 changes: 4 additions & 2 deletions core/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@
border-top: var(--border-width) var(--border-style) var(--border-color);

font-size: dynamic-font(12px);

white-space: normal;
}

/**
Expand Down Expand Up @@ -340,7 +342,7 @@
.input-bottom .helper-text {
display: block;

color: #{$text-color-step-450};
color: $text-color-step-300;
}

:host(.ion-touched.ion-invalid) .input-bottom .error-text {
Expand All @@ -362,7 +364,7 @@
*/
@include margin-horizontal(auto, null);

color: #{$text-color-step-450};
color: $text-color-step-300;

white-space: nowrap;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 80 additions & 32 deletions core/src/components/input/test/bottom-content/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
<style>
.grid {
display: grid;
grid-template-columns: repeat(3, minmax(250px, 1fr));
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
grid-row-gap: 20px;
grid-column-gap: 20px;
}

h2 {
font-size: 12px;
font-weight: normal;
Expand All @@ -27,20 +28,14 @@

margin-top: 10px;
}
@media screen and (max-width: 800px) {
.grid {
grid-template-columns: 1fr;
padding: 0;
}
}

ion-input.custom-error-color {
--highlight-color-invalid: purple;
}
</style>
</head>

<body>
<body onLoad="onLoad()">
<ion-app>
<ion-header>
<ion-toolbar>
Expand All @@ -52,67 +47,120 @@
<div class="grid">
<div class="grid-item">
<h2>No Hint</h2>
<ion-input label="Email"></ion-input>
<ion-input label="Label"></ion-input>
</div>

<div class="grid-item">
<h2>No Hint: Stacked</h2>
<ion-input label="Label" label-placement="stacked"></ion-input>
</div>

<div class="grid-item">
<h2>Helper Text</h2>
<ion-input label="Label" helper-text="Helper text"></ion-input>
</div>

<div class="grid-item">
<h2>Helper Text: Stacked</h2>
<ion-input label="Label" label-placement="stacked" helper-text="Helper text"></ion-input>
</div>

<div class="grid-item">
<h2>Helper Hint</h2>
<ion-input label="Email" helper-text="Enter your email"></ion-input>
<h2>Error Text</h2>
<ion-input class="ion-touched ion-invalid" label="Label" error-text="Error text"></ion-input>
</div>

<div class="grid-item">
<h2>Error Hint</h2>
<h2>Error Text: Stacked</h2>
<ion-input
class="ion-touched ion-invalid"
label="Email"
error-text="Please enter a valid email"
label="Label"
label-placement="stacked"
error-text="Error text"
></ion-input>
</div>

<div class="grid-item">
<h2>Custom Error Color</h2>
<h2>Error Text: Custom Color</h2>
<ion-input
class="ion-touched ion-invalid custom-error-color"
label="Email"
error-text="Please enter a valid email"
label="Label"
error-text="Error text"
></ion-input>
</div>

<div class="grid-item">
<h2>Helper Text: Wrapping</h2>
<ion-input
label="Label"
helper-text="Helper text helper text helper text helper text helper text helper text helper text helper text helper text"
>
</ion-input>
</div>

<div class="grid-item">
<h2>Counter</h2>
<ion-input label="Email" counter="true" maxlength="100"></ion-input>
<ion-input label="Label" counter="true" maxlength="100"></ion-input>
</div>

<div class="grid-item">
<h2>Custom Counter</h2>
<ion-input id="custom-counter" label="Email" counter="true" maxlength="100"></ion-input>
<h2>Counter: Custom</h2>
<ion-input id="custom-counter" label="Label" counter="true" maxlength="100"></ion-input>
</div>

<div class="grid-item">
<h2>Counter with Helper</h2>
<ion-input label="Email" counter="true" maxlength="100" helper-text="Enter an email"></ion-input>
<h2>Counter: with Helper</h2>
<ion-input label="Label" counter="true" maxlength="100" helper-text="Helper text"></ion-input>
</div>

<div class="grid-item">
<h2>Counter with Error</h2>
<h2>Counter: with Error</h2>
<ion-input
class="ion-touched ion-invalid"
label="Email"
label="Label"
counter="true"
maxlength="100"
error-text="Please enter a valid email"
error-text="Error text"
></ion-input>
</div>
</div>

<script>
const customCounterInput = document.querySelector('ion-input#custom-counter');
customCounterInput.counterFormatter = (inputLength, maxLength) => {
const length = maxLength - inputLength;
return `${maxLength - inputLength} characters left`;
};
</script>
<button class="expand" onclick="toggleFill()">Toggle Fill</button>
brandyscarney marked this conversation as resolved.
Show resolved Hide resolved
</ion-content>
</ion-app>

<script>
// Hide the toggle fill button on ios mode since it's not supported
function onLoad() {
const toggleFillButton = document.querySelector('button');

if (Ionic.mode === 'ios' && toggleFillButton) {
toggleFillButton.style.display = 'none';
}
}

const customCounterInput = document.querySelector('ion-input#custom-counter');
customCounterInput.counterFormatter = (inputLength, maxLength) => {
const length = maxLength - inputLength;
return `${maxLength - inputLength} characters left`;
};

const inputs = document.querySelectorAll('ion-input');

function toggleFill() {
inputs.forEach((input) => {
switch (input.fill) {
case 'outline':
input.fill = 'solid';
break;
case 'solid':
input.fill = undefined;
break;
default:
input.fill = 'outline';
}
});
}
</script>
</body>
</html>
Loading
Loading