Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
621dc13
feat(input): add new js and css props
liamdebeasi Oct 31, 2022
d24428c
chore(): copy updates
liamdebeasi Oct 31, 2022
0402ae8
test(input): move old tests to legacy directory
liamdebeasi Oct 31, 2022
7643d2d
feat(input): add legacy vs modern template rendering
liamdebeasi Oct 31, 2022
259a3a2
refactor(form): add form controller
liamdebeasi Oct 31, 2022
a989e94
chore(): update comments
liamdebeasi Oct 31, 2022
2a80a5f
chore(): update tests
liamdebeasi Oct 31, 2022
08ea3a0
chore(): add moved screenshots
liamdebeasi Oct 31, 2022
bd80054
chore(): add moved screenshots
liamdebeasi Oct 31, 2022
19f4994
chore(): fix test file
liamdebeasi Oct 31, 2022
d02c144
chore(): prettier
liamdebeasi Oct 31, 2022
cea5615
feat(input): add base functionality and tests
liamdebeasi Oct 31, 2022
8d7f0c4
feat(input): add missing fixed label
liamdebeasi Oct 31, 2022
6eabc11
feat(input): add basic help text rendering
liamdebeasi Oct 31, 2022
0259004
feat(input): add helper and error text
liamdebeasi Oct 31, 2022
5f765a0
chore(): update descriptions for clarity
liamdebeasi Oct 31, 2022
3e4f70c
test(input): make sure correct content is rendered
liamdebeasi Oct 31, 2022
232d868
test(input): make sure error color can be customized
liamdebeasi Oct 31, 2022
2f6019b
chore(): update test
liamdebeasi Oct 31, 2022
5c3bb0c
chore(): add updated snapshots
Ionitron Oct 31, 2022
f8dc97f
refactor(item): deprecate helper and error slots
liamdebeasi Nov 1, 2022
23af9da
Merge branch '2591-helper' of https://github.com/ionic-team/ionic-fra…
liamdebeasi Nov 1, 2022
516a615
chore(): a few tweaks
liamdebeasi Nov 1, 2022
2d07367
test(input): clean up tests
liamdebeasi Nov 1, 2022
fff8ed1
Merge remote-tracking branch 'origin/FW-2591' into 2591-props
liamdebeasi Nov 1, 2022
563f177
Update core/src/components/input/input.tsx
liamdebeasi Nov 1, 2022
e1696af
chore(): run build
liamdebeasi Nov 1, 2022
a17a9ae
Merge remote-tracking branch 'origin/2591-props' into 2591-template
liamdebeasi Nov 1, 2022
b458fe7
Merge remote-tracking branch 'origin/2591-template' into 2591-base
liamdebeasi Nov 1, 2022
eace2ec
Merge branch '2591-base' into 2591-helper
liamdebeasi Nov 1, 2022
f556aee
chore(input): remove justify property
liamdebeasi Nov 1, 2022
6b8131a
Update core/src/components/input/input.tsx
liamdebeasi Nov 2, 2022
e0b5cd6
feat(input): add missing fill property
liamdebeasi Nov 2, 2022
5a0f812
refactor(): explicitly add element type
liamdebeasi Nov 2, 2022
2bf7b10
test(input): mask test uses new syntax
liamdebeasi Nov 2, 2022
1cc337a
refactor(input): access props once
liamdebeasi Nov 2, 2022
9f04dd1
Merge branch '2591-base' into 2591-helper
liamdebeasi Nov 2, 2022
4272366
chore(): fix el type
liamdebeasi Nov 2, 2022
6d09ad6
Merge remote-tracking branch 'origin/2591-props' into 2591-template
liamdebeasi Nov 2, 2022
9632c22
Merge remote-tracking branch 'origin/2591-template' into 2591-base
liamdebeasi Nov 2, 2022
79ff704
Merge remote-tracking branch 'origin/2591-base' into 2591-helper
liamdebeasi Nov 2, 2022
287dcd7
chore(): sync
liamdebeasi Nov 7, 2022
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
2 changes: 2 additions & 0 deletions core/src/components/input/input.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
--padding-end: #{$input-ios-padding-end};
--padding-bottom: #{$input-ios-padding-bottom};
--padding-start: #{$input-ios-padding-start};
--border-width: #{$hairlines-width};
--border-color: #{$item-ios-border-color};

font-size: $input-ios-font-size;
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/components/input/input.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
--padding-end: #{$input-md-padding-end};
--padding-bottom: #{$input-md-padding-bottom};
--padding-start: #{$input-md-padding-start};
--border-width: 1px;
--border-color: #{$item-md-border-color};

font-size: $input-md-font-size;
}
Expand Down
74 changes: 66 additions & 8 deletions core/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
* @prop --highlight-color-valid: The color of the highlight on the input when valid
* @prop --highlight-color-invalid: The color of the highlight on the input when invalid
*
* @prop --border-color: Color of the input border
* @prop --border-radius: Radius of the input border
* @prop --border-style: Style of the input border
* @prop --border-width: Width of the input border
* @prop --border-color: Color of the border below the input when using helper text, error text, or counter
* @prop --border-radius: Radius of the input
* @prop --border-style: Color of the border below the input when using helper text, error text, or counter
* @prop --border-width: Color of the border below the input when using helper text, error text, or counter
*/
--placeholder-color: initial;
--placeholder-font-style: initial;
Expand All @@ -38,13 +38,13 @@
--padding-start: 0;
--background: transparent;
--color: initial;
--border-style: solid;
--highlight-color-focused: #{ion-color(primary, base)};
--highlight-color-valid: #{ion-color(success, base)};
--highlight-color-invalid: #{ion-color(danger, base)};

display: flex;
position: relative;

flex: 1;
align-items: center;

width: 100%;

/* stylelint-disable-next-line all */
Expand All @@ -58,6 +58,13 @@
z-index: $z-index-item-input;
}

:host(.legacy-input) {
display: flex;

flex: 1;
align-items: center;
}

:host-context(ion-item:not(.item-label)) {
--padding-start: 0;
}
Expand Down Expand Up @@ -200,3 +207,54 @@

opacity: 1;
}

// Input Wrapper
// ----------------------------------------------------------------
.input-wrapper {
display: flex;

flex-grow: 1;

align-items: center;
}

// Input Bottom Content
// ----------------------------------------------------------------

.input-bottom {
@include padding(5px, 0, 0, 0);

display: flex;

justify-content: space-between;

border-top: var(--border-width) var(--border-style) var(--border-color);

font-size: 12px;
}

// Input Hint Text
// ----------------------------------------------------------------

/**
* Error text should only be shown when .ion-invalid is
* present on the input. Otherwise the helper text should
* be shown.
*/
.input-bottom .error-text {
display: none;

color: var(--highlight-color-invalid);
}

.input-bottom .helper-text {
display: block;
}

:host(.ion-invalid) .input-bottom .error-text {
display: block;
}

:host(.ion-invalid) .input-bottom .helper-text {
display: none;
}
129 changes: 79 additions & 50 deletions core/src/components/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,31 @@ export class Input implements ComponentInterface {
return this.getValue().length > 0;
}

/**
* Renders the helper text or error text values
*/
private renderHintText() {
const { helperText, errorText } = this;

return [<div class="helper-text">{helperText}</div>, <div class="error-text">{errorText}</div>];
}

/**
* Responsible for rendering helper text,
* error text, and counter. This element should only
* be rendered if hint text is set or counter is enabled.
*/
private renderBottomContent() {
const { helperText, errorText } = this;

const hasHintText = helperText !== undefined || errorText !== undefined;
if (!hasHintText) {
return;
}

return <div class="input-bottom">{this.renderHintText()}</div>;
}

private renderInput() {
const { disabled, readonly, inputId } = this;
const mode = getIonMode(this);
Expand All @@ -526,57 +551,60 @@ export class Input implements ComponentInterface {
'has-focus': this.hasFocus,
})}
>
<label htmlFor={inputId}>{this.label}</label>
<input
class="native-input"
ref={(input) => (this.nativeInput = input)}
id={inputId}
disabled={disabled}
accept={this.accept}
autoCapitalize={this.autocapitalize}
autoComplete={this.autocomplete}
autoCorrect={this.autocorrect}
autoFocus={this.autofocus}
enterKeyHint={this.enterkeyhint}
inputMode={this.inputmode}
min={this.min}
max={this.max}
minLength={this.minlength}
maxLength={this.maxlength}
multiple={this.multiple}
name={this.name}
pattern={this.pattern}
placeholder={this.placeholder || ''}
readOnly={readonly}
required={this.required}
spellcheck={this.spellcheck}
step={this.step}
size={this.size}
type={this.type}
value={value}
onInput={this.onInput}
onChange={this.onChange}
onBlur={this.onBlur}
onFocus={this.onFocus}
onKeyDown={this.onKeydown}
{...this.inheritedAttributes}
/>
{this.clearInput && !readonly && !disabled && (
<button
aria-label="reset"
type="button"
class="input-clear-icon"
onPointerDown={(ev) => {
/**
* This prevents mobile browsers from
* blurring the input when the clear
* button is activated.
*/
ev.preventDefault();
}}
onClick={this.onClearButtonClick}
<div class="input-wrapper">
<label htmlFor={inputId}>{this.label}</label>
<input
class="native-input"
ref={(input) => (this.nativeInput = input)}
id={inputId}
disabled={disabled}
accept={this.accept}
autoCapitalize={this.autocapitalize}
autoComplete={this.autocomplete}
autoCorrect={this.autocorrect}
autoFocus={this.autofocus}
enterKeyHint={this.enterkeyhint}
inputMode={this.inputmode}
min={this.min}
max={this.max}
minLength={this.minlength}
maxLength={this.maxlength}
multiple={this.multiple}
name={this.name}
pattern={this.pattern}
placeholder={this.placeholder || ''}
readOnly={readonly}
required={this.required}
spellcheck={this.spellcheck}
step={this.step}
size={this.size}
type={this.type}
value={value}
onInput={this.onInput}
onChange={this.onChange}
onBlur={this.onBlur}
onFocus={this.onFocus}
onKeyDown={this.onKeydown}
{...this.inheritedAttributes}
/>
)}
{this.clearInput && !readonly && !disabled && (
<button
aria-label="reset"
type="button"
class="input-clear-icon"
onPointerDown={(ev) => {
/**
* This prevents mobile browsers from
* blurring the input when the clear
* button is activated.
*/
ev.preventDefault();
}}
onClick={this.onClearButtonClick}
/>
)}
</div>
{this.renderBottomContent()}
</Host>
);
}
Expand Down Expand Up @@ -607,6 +635,7 @@ For inputs that do not have a visible label, developers should use "aria-label"
[mode]: true,
'has-value': this.hasValue(),
'has-focus': this.hasFocus,
'legacy-input': true,
})}
>
<input
Expand Down
80 changes: 80 additions & 0 deletions core/src/components/input/test/bottom-content/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Input - Bottom Content</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
<script src="../../../../../scripts/testing/scripts.js"></script>
<script nomodule src="../../../../../dist/ionic/ionic.js"></script>
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
<style>
.grid {
display: grid;
grid-template-columns: repeat(3, minmax(250px, 1fr));
grid-row-gap: 20px;
grid-column-gap: 20px;
}
h2 {
font-size: 12px;
font-weight: normal;

color: #6f7378;

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>
<ion-app>
<ion-header>
<ion-toolbar>
<ion-title>Input - Basic</ion-title>
</ion-toolbar>
</ion-header>

<ion-content id="content" class="ion-padding">
<div class="grid">
<div class="grid-item">
<h2>No Hint</h2>
<ion-input label="Email"></ion-input>
</div>

<div class="grid-item">
<h2>Helper Hint</h2>
<ion-input label="Email" helper-text="Enter your email"></ion-input>
</div>

<div class="grid-item">
<h2>Error Hint</h2>
<ion-input class="ion-invalid" label="Email" error-text="Please enter a valid email"></ion-input>
</div>

<div class="grid-item">
<h2>Custom Error Color</h2>
<ion-input
class="ion-invalid custom-error-color"
label="Email"
error-text="Please enter a valid email"
></ion-input>
</div>
</div>
</ion-content>
</ion-app>
</body>
</html>
Loading