@createnl/secure-password-input
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -11,8 +11,8 @@ import React, { forwardRef, useState, } from 'react'; | ||
return (React.createElement("label", { "aria-label": hideLabel ? label : undefined, className: `spi-password-input ${className}` }, | ||
!hideLabel && React.createElement(InputLabel, { text: label, className: "spi-password-input__label" }), | ||
!hideLabel && (React.createElement(InputLabel, { text: label, className: "spi-password-input__label custom-spi__label" })), | ||
React.createElement("div", { className: "spi-password-input__field-container" }, | ||
React.createElement(Input, Object.assign({}, inputProps, { ref: ref, type: passwordIsVisible ? 'text' : 'password', tabIndex: tabIndex, disabled: disabled, onChange: handleChange, className: "spi-password-input__field" })), | ||
React.createElement(Button, { text: passwordIsVisible ? 'Verberg wachtwoord' : 'Toon wachtwoord', tabIndex: tabIndex, disabled: disabled, onClick: toggleVisibility, className: "spi-password-input__visibility-button" }, | ||
React.createElement(Icon, { name: `visibility-${passwordIsVisible ? 'on' : 'off'}`, className: "spi-password-input__visibility-icon" }))))); | ||
React.createElement(Input, Object.assign({}, inputProps, { ref: ref, type: passwordIsVisible ? 'text' : 'password', tabIndex: tabIndex, disabled: disabled, onChange: handleChange, className: "spi-password-input__field custom-spi__input" })), | ||
React.createElement(Button, { text: passwordIsVisible ? 'Verberg wachtwoord' : 'Toon wachtwoord', tabIndex: tabIndex, disabled: disabled, onClick: toggleVisibility, className: "spi-password-input__visibility-button custom-spi__button" }, | ||
React.createElement(Icon, { name: `visibility-${passwordIsVisible ? 'on' : 'off'}`, className: "spi-password-input__visibility-icon custom-spi__button-icon" }))))); | ||
}); | ||
export default PasswordInput; |
@@ -23,4 +23,4 @@ import React, { forwardRef, useState, } from 'react'; | ||
return (React.createElement("div", { className: `spi-secure-password-input ${className}` }, | ||
React.createElement(PasswordInput, Object.assign({}, inputProps, { ref: ref, minLength: minimumLength, onChange: handleChange, className: "spi-secure-password-input__input" })), | ||
adviceLinkText && adviceLinkURL && (React.createElement("a", { href: adviceLinkURL, target: "_blank", rel: "noopener noreferrer", className: "spi-secure-password-input__advice-link" }, adviceLinkText)), | ||
React.createElement(PasswordInput, Object.assign({}, inputProps, { ref: ref, minLength: minimumLength, onChange: handleChange })), | ||
adviceLinkText && adviceLinkURL && (React.createElement("a", { href: adviceLinkURL, target: "_blank", rel: "noopener noreferrer", className: "spi-secure-password-input__advice-link custom-spi__advice-link" }, adviceLinkText)), | ||
password && React.createElement(SecurePasswordMeter, { strength: strength }), | ||
@@ -27,0 +27,0 @@ password && React.createElement(SecurePasswordFeedback, { warning: warning, suggestions: suggestions }))); |
import React from 'react'; | ||
const SecurePasswordFeedback = ({ warning, suggestions }) => (React.createElement("div", { className: "spi-secure-password-input__feedback" }, | ||
warning && (React.createElement("p", { className: "spi-secure-password-input__warning" }, | ||
warning && (React.createElement("p", { className: "spi-secure-password-input__warning custom-spi__warning" }, | ||
React.createElement("strong", null, warning))), | ||
suggestions && (React.createElement("ul", { className: "spi-secure-password-input__suggestion-list" }, suggestions.map(suggestion => (React.createElement("li", { key: suggestion, className: "spi-secure-password-input__suggestion" }, suggestion))))))); | ||
suggestions && (React.createElement("ul", { className: "spi-secure-password-input__suggestion-list custom-spi__suggestion-list" }, suggestions.map(suggestion => (React.createElement("li", { key: suggestion, className: "spi-secure-password-input__suggestion custom-spi__suggestion" }, suggestion))))))); | ||
export default SecurePasswordFeedback; |
@@ -6,5 +6,5 @@ import React from 'react'; | ||
return (React.createElement(React.Fragment, null, | ||
React.createElement("p", { className: "spi-secure-password-input__strength-label" }, strengthFeedback), | ||
React.createElement("meter", { min: 0, max: 4, value: strength, className: "spi-secure-password-input__strength-meter" }))); | ||
React.createElement("p", { className: "spi-secure-password-input__strength-label custom-spi__strength-label" }, strengthFeedback), | ||
React.createElement("meter", { min: 0, max: 4, value: strength, className: "spi-secure-password-input__strength-meter custom-spi__strength-meter" }))); | ||
}; | ||
export default SecurePasswordMeter; |
{ | ||
"name": "@createnl/secure-password-input", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "A password input that provides user with rating and advice on how secure their password is, based on ZXCVBN", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
115
README.md
@@ -15,3 +15,3 @@ # Create — Secure Password Input | ||
- Callback on input; provides callback with password and score | ||
- Custom styling with CSS variables | ||
- Custom styling support | ||
@@ -65,3 +65,3 @@ | ||
| `minimumLength` | Number | `8` | Set the minimum length requirement of the password input | ||
| `minimumScore` | 0 | 1 | 2 | 3 | 4 | `2` | Set the minimum score requirement of the password input ([See score table](#score-table)) | ||
| `minimumScore` | 0 | 1 | 2 | 3 | 4 | `2` | Set the minimum score requirement of the password input ([Score table](#score-table)) | ||
| `adviceLinkText` | String | - | Optional text where you could direct the user to an external document with password advice (only renders if there is also a URL given within the `adviceLinkURL` prop) | ||
@@ -71,3 +71,3 @@ | `adviceLinkURL` | String | - | Link that navigates to desired external URL (only works if the `adviceLinkText` has content) | ||
| `tabIndex` | -1 | 0 | `0` | Determine if the input, and it's interactive child elements, are reachable with keyboard navigation | ||
| `className` | String | - | Add a custom CSS class | ||
| `className` | String | - | Add a custom CSS class, this functions as the parent class ([Custom styling usage](#custom-styling)) | ||
| HTML defaults | - | - | Default attributes of the HTML `input` element, that are not featured in this table | ||
@@ -88,63 +88,62 @@ | ||
## Custom styling | ||
Want to add your own styling to the password input? It makes use of native CSS variables, so it's easy to update the values that are available, within just one CSS rule. | ||
Want to add your own styling to the password input? It makes use of some native CSS variables, so it's easy to update multiple values at once. Other CSS can be added via dedicated selectors for specific elements. | ||
```css | ||
/* | ||
Custom class of the Secure Password Input (SPI) | ||
Shown values are used as defaults, if no custom styling is given | ||
Custom CSS of the Secure Password Input (SPI) | ||
Shown values are CSS-variables which you can change to your liking | ||
Note: The name of the parent class is customizable, though the child classes retain their 'custom-spi' prefix. | ||
*/ | ||
.custom-class-name { | ||
--SPI-theme-color-primary: red; | ||
--SPI-theme-color-white: white; | ||
--SPI-theme-color-black: black; | ||
--SPI-font-family: system-ui, sans-serif; | ||
--SPI-font-size: 1rem; | ||
--SPI-label-margin: 0 0 .625rem; | ||
--SPI-label-font-size: inherit; | ||
--SPI-label-font-weight: bold; | ||
--SPI-input-width: 100%; | ||
--SPI-input-height: auto; | ||
--SPI-input-margin: 0; | ||
--SPI-input-padding: .5rem; | ||
--SPI-input-border-radius: 0; | ||
--SPI-input-border: 1px solid var(--SPI-theme-color-black); | ||
--SPI-input-background-color: transparent; | ||
--SPI-visibility-button-padding: .5rem; | ||
--SPI-visibility-button-color: var(--SPI-theme-color-white); | ||
--SPI-visibility-button-border: 1px solid var(--SPI-theme-color-black); | ||
--SPI-visibility-button-background-color: var(--SPI-theme-color-primary); | ||
--SPI-visibility-icon-size: 1rem; | ||
--SPI-advice-link-margin: .625rem 0 0; | ||
--SPI-advice-link-font-size: inherit; | ||
--SPI-advice-link-color: var(--SPI-theme-color-primary); | ||
--SPI-strength-label-margin: .625rem 0 0; | ||
--SPI-strength-label-font-size: inherit; | ||
--SPI-strength-meter-width: 100%; | ||
--SPI-strength-meter-height: .5rem; | ||
--SPI-strength-meter-margin: .625rem 0 0; | ||
--SPI-strength-meter-background-color: var(--SPI-theme-color-black); | ||
--SPI-strength-meter-color-weak: #ff0018; | ||
--SPI-strength-meter-color-soso: #ff6800; | ||
--SPI-strength-meter-color-good: #ffe800; | ||
--SPI-strength-meter-color-strong: #00ff68; | ||
--SPI-warning-margin: .625rem 0 0; | ||
--SPI-warning-font-size: inherit; | ||
--SPI-suggestion-list-margin: .625rem 0 0; | ||
--SPI-suggestion-list-padding: 0 0 0 1rem; | ||
--SPI-suggestion-margin: .5rem 0 0; | ||
--SPI-suggestion-font-size: inherit; | ||
.custom-spi { | ||
--SPI-color-primary: red; | ||
--SPI-color-white: white; | ||
--SPI-color-black: black; | ||
--SPI-color-strength-weak: #ff0018; | ||
--SPI-color-strength-soso: #ff6800; | ||
--SPI-color-strength-good: #ffe800; | ||
--SPI-color-strength-strong: #00ff68; | ||
} | ||
.custom-spi .custom-spi__label { | ||
/* Custom styles for the input label */ | ||
} | ||
.custom-spi .custom-spi__input { | ||
/* Custom styles for the password input */ | ||
} | ||
.custom-spi .custom-spi__button { | ||
/* Custom styles for the reveal/hide password button */ | ||
} | ||
.custom-spi .custom-spi__button-icon { | ||
/* Custom styles for the reveal/hide password button icon */ | ||
} | ||
.custom-spi .custom-spi__advice-link { | ||
/* Custom styles for the advice link */ | ||
} | ||
.custom-spi .custom-spi__strength-label { | ||
/* Custom styles for the strength indicator text */ | ||
} | ||
.custom-spi .custom-spi__strength-meter { | ||
/* Custom styles for the strength indicator meter */ | ||
} | ||
.custom-spi .custom-spi__warning { | ||
/* Custom styles for the warning text */ | ||
} | ||
.custom-spi .custom-spi__suggestion-list { | ||
/* Custom styles for the suggestion list */ | ||
} | ||
.custom-spi .custom-spi__suggestion { | ||
/* Custom styles for the suggestion text */ | ||
} | ||
``` | ||
@@ -151,0 +150,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
89134
1870
150