Compare commits

..

1 Commits

Author SHA1 Message Date
Liam DeBeasi
243cf92600 add poc 2024-02-09 10:04:11 -05:00
4 changed files with 96 additions and 7 deletions

View File

@@ -1290,7 +1290,6 @@ export namespace Components {
* Works with the min and max attributes to limit the increments at which a value can be set. Possible values are: `"any"` or a positive floating point number.
*/
"step"?: string;
"togglePassword": boolean;
/**
* The type of control to display. The default type is text.
*/
@@ -1949,6 +1948,9 @@ export namespace Components {
*/
"mode"?: "ios" | "md";
}
interface IonPasswordStrength {
"strength"?: 'weak' | 'medium' | 'strong';
}
interface IonPicker {
/**
* If `true`, the picker will animate.
@@ -4036,6 +4038,12 @@ declare global {
prototype: HTMLIonNoteElement;
new (): HTMLIonNoteElement;
};
interface HTMLIonPasswordStrengthElement extends Components.IonPasswordStrength, HTMLStencilElement {
}
var HTMLIonPasswordStrengthElement: {
prototype: HTMLIonPasswordStrengthElement;
new (): HTMLIonPasswordStrengthElement;
};
interface HTMLIonPickerElementEventMap {
"ionPickerDidPresent": void;
"ionPickerWillPresent": void;
@@ -4673,6 +4681,7 @@ declare global {
"ion-nav": HTMLIonNavElement;
"ion-nav-link": HTMLIonNavLinkElement;
"ion-note": HTMLIonNoteElement;
"ion-password-strength": HTMLIonPasswordStrengthElement;
"ion-picker": HTMLIonPickerElement;
"ion-picker-column": HTMLIonPickerColumnElement;
"ion-picker-column-internal": HTMLIonPickerColumnInternalElement;
@@ -6022,7 +6031,6 @@ declare namespace LocalJSX {
* Works with the min and max attributes to limit the increments at which a value can be set. Possible values are: `"any"` or a positive floating point number.
*/
"step"?: string;
"togglePassword"?: boolean;
/**
* The type of control to display. The default type is text.
*/
@@ -6608,6 +6616,9 @@ declare namespace LocalJSX {
*/
"mode"?: "ios" | "md";
}
interface IonPasswordStrength {
"strength"?: 'weak' | 'medium' | 'strong';
}
interface IonPicker {
/**
* If `true`, the picker will animate.
@@ -8129,6 +8140,7 @@ declare namespace LocalJSX {
"ion-nav": IonNav;
"ion-nav-link": IonNavLink;
"ion-note": IonNote;
"ion-password-strength": IonPasswordStrength;
"ion-picker": IonPicker;
"ion-picker-column": IonPickerColumn;
"ion-picker-column-internal": IonPickerColumnInternal;
@@ -8226,6 +8238,7 @@ declare module "@stencil/core" {
"ion-nav": LocalJSX.IonNav & JSXBase.HTMLAttributes<HTMLIonNavElement>;
"ion-nav-link": LocalJSX.IonNavLink & JSXBase.HTMLAttributes<HTMLIonNavLinkElement>;
"ion-note": LocalJSX.IonNote & JSXBase.HTMLAttributes<HTMLIonNoteElement>;
"ion-password-strength": LocalJSX.IonPasswordStrength & JSXBase.HTMLAttributes<HTMLIonPasswordStrengthElement>;
"ion-picker": LocalJSX.IonPicker & JSXBase.HTMLAttributes<HTMLIonPickerElement>;
"ion-picker-column": LocalJSX.IonPickerColumn & JSXBase.HTMLAttributes<HTMLIonPickerColumnElement>;
"ion-picker-column-internal": LocalJSX.IonPickerColumnInternal & JSXBase.HTMLAttributes<HTMLIonPickerColumnInternalElement>;

View File

@@ -153,8 +153,6 @@ export class Input implements ComponentInterface {
this.emitStyle();
}
@Prop() togglePassword = false;
/**
* A hint to the browser for which enter key to display.
* Possible values: `"enter"`, `"done"`, `"go"`, `"next"`,
@@ -838,9 +836,7 @@ export class Input implements ComponentInterface {
<ion-icon aria-hidden="true" icon={mode === 'ios' ? closeCircle : closeSharp}></ion-icon>
</button>
)}
<slot name="end">
{ this.togglePassword && <button>Hello World</button> }
</slot>
<slot name="end"></slot>
</div>
{shouldRenderHighlight && <div class="input-highlight"></div>}
</label>

View File

@@ -0,0 +1,34 @@
import type { ComponentInterface } from '@stencil/core';
import { Component, Host, Prop, h } from '@stencil/core';
const progressBarValue: any = {
'weak': {
value: 0.2,
},
'medium': {
value: 0.6,
},
'strong': {
value: 1,
}
}
@Component({
tag: 'ion-password-strength',
shadow: true
})
export class PasswordStrength implements ComponentInterface {
@Prop() strength?: 'weak' | 'medium' | 'strong';
render() {
// TODO need a mode virtual prop
// TODO need to add colors
const data = this.strength !== undefined ? progressBarValue[this.strength] : undefined;
return (
<Host>
<ion-progress-bar value={data?.value || 0}></ion-progress-bar>
{ this.strength !== undefined && <slot name={this.strength}></slot> }
</Host>
);
}
}

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Password Strength - Basic</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>
</head>
<body class="ion-padding">
<ion-input label="Password" type="password" fill="outline"></ion-input>
<br />
<ion-password-strength>
<div slot="weak">Your password is weak</div>
<div slot="medium">Your password is medium</div>
<div slot="strong">Your password is strong</div>
</ion-password-strength>
<script>
const input = document.querySelector('ion-input');
const ps = document.querySelector('ion-password-strength');
input.addEventListener('ionInput', () => {
const val = input.value;
if (val.length === 0) {
ps.strength = undefined;
} else if (val.length < 4) {
ps.strength = 'weak';
} else if (val.length < 8) {
ps.strength = 'medium';
} else {
ps.strength = 'strong';
}
});
</script>
</body>
</html>