Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="root"></div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');

:root {
  --dark-green: hsl(147, 26%, 27%);
  --green: hsl(148, 26%, 48%);
  --light-green: hsl(149, 34%, 88%);
  --white: hsl(0, 0%, 100%);
  --space: 20px;
  --color: hsl(0, 0%, 20%);
  --color-focus: hsl(0, 0%, 50%);
  --transition: all 0.2s ease-out;
}

*,
*:before,
*:after {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
html {
  box-sizing: border-box;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1;
  color: var(--color);
}

.App {
  min-height: 100vh;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  font-family: 'Montserrat', sans-serif;
  letter-spacing: 0.4px;
}

.github-button {
  position: absolute;
  display: inline-block;
  padding: 12px 14px;
  color: var(--white);
  background: #222;
  text-decoration: none;
  border-radius: 4px;
  right: 4%;
  top: 4%;
  font-size: 14px;
  font-weight: 600;
}

.form-box {
  width: 320px;
  max-width: 320px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
}

.validation-box {
  padding: var(--space);
  background: var(--dark-green);
  margin-bottom: var(--space);
  border-radius: 8px;
  -webkit-box-shadow: 0px 10px 43px 0px rgba(0, 0, 0, 0.12);
  -moz-box-shadow: 0px 10px 43px 0px rgba(0, 0, 0, 0.12);
  box-shadow: 0px 10px 43px 0px rgba(0, 0, 0, 0.12);
  list-style: none;
  font-size: 0.875em;
  font-weight: 600;
  color: var(--white);
}

.validation-item {
  position: relative;
  padding-left: calc(var(--space) + 8px);
}

.validation-item:not(:last-child) {
  margin-bottom: 16px;
}

.validation-item.done {
  color: hsla(0, 0%, 100%, 40%);
}

.validation-icon {
  position: absolute;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  left: 0px;
}

.check {
  stroke-dasharray: 45;
  stroke-dashoffset: 45;
  animation: check 0.2s 0.1s ease-in-out forwards;
}

@keyframes check {
  0% {
    stroke-dashoffset: 45;
  }
  100% {
    stroke-dashoffset: 20;
  }
}

.form-field {
  display: flex;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  -webkit-box-shadow: 0px 10px 43px 0px rgba(0, 0, 0, 0.12);
  -moz-box-shadow: 0px 10px 43px 0px rgba(0, 0, 0, 0.12);
  box-shadow: 0px 10px 43px 0px rgba(0, 0, 0, 0.12);
}

.form-field:active {
  transform: scale(0.98);
  transition: var(--transition);
}

@font-face {
  font-family: 'fontello';
  src: url('https://github.com/erenesto/interactive-password-validator/blob/master/src/assets/font/fontello.eot');
  src: url('https://github.com/erenesto/interactive-password-validator/blob/master/src/assets/font/fontello.eot') format('embedded-opentype'),
    url('https://github.com/erenesto/interactive-password-validator/blob/master/src/assets/font/fontello.woff') format('woff'),
    url('https://github.com/erenesto/interactive-password-validator/blob/master/src/assets/font/fontello.ttf') format('truetype'),
    url('https://github.com/erenesto/interactive-password-validator/blob/master/src/assets/font/fontello.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

.form-input {
  padding-left: var(--space);
  padding-bottom: 2px;
  padding-top: 25px;
  padding-right: 80px;
  width: 100%;
  font-size: 18px;
  font-family: 'fontello';
  font-style: normal;
  font-weight: normal;
  speak: none;
  font-variant: normal;
  text-transform: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 8px;
  font-size: 2.4em;
  height: 40px;
  overflow: hidden;
  color: transparent;
  text-shadow: 0 0 0 var(--green);
}

.form-label {
  position: absolute;
  font-size: 120%;
  padding-left: var(--space);
  transition: var(--transition);
  width: calc(100% - 80px);
  border-radius: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-weight: 600;
  z-index: 1;
}

.form-input:focus {
  outline: none;
}

.form-input:focus + .form-label {
  font-size: 0.875em;
  color: var(--color-focus);
  background-color: transparent;
  top: 20px;
}

.form-label::before {
  content: '';
  position: absolute;
  height: 340%;
  top: -25px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--white);
  z-index: -1;
  transition: var(--transition);
}

.form-input:focus + .form-label::before {
  background-color: transparent;
  opacity: 0;
}

.form-input-lock {
  position: absolute;
  height: 100%;
  width: 80px;
  right: 0;
}

.lock-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  transition: all 0.3s cubic-bezier(0.16, 0.92, 0.31, 1.85);
}

.lock-icon path {
  fill: var(--green);
  opacity: 0.4;
}

.lock-icon.locked {
  transform: translate(-50%, -50%) scale(1.4);
  transform-origin: center;
}

.lock-icon.locked path {
  opacity: 1;
}

@media only screen and (max-height: 320px) {
  .validation-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
  .validation-item {
    width: 40%;
  }
}
              
            
!

JS

              
                /*
design: https://dribbble.com/shots/7259090-Password-Validation
design by Neven Solidov.
*/

const bg = 'https://raw.githubusercontent.com/erenesto/interactive-password-validator/d4344fd1a7620393a18d18a17ffb9dcf95f6887f/src/assets/bg.svg'

const lockIcon = {
  open: '0h-3v2h4a2',
  closed: '0v2h1a2',
};

const validationNames = [
  { id: 'lowercase', name: 'Lower-case' },
  { id: 'uppercase', name: 'Upper-case' },
  { id: 'number', name: 'Number' },
  { id: 'minChar', name: 'More than 8 characters' },
];

const validationObj = {
  lowercase: false,
  uppercase: false,
  number: false,
  minChar: false,
};

const validationReducer = (state, action) => {
  switch (action.type) {
    case 'lowercase':
      return { ...state, lowercase: action.payload };
    case 'uppercase':
      return { ...state, uppercase: action.payload };
    case 'number':
      return { ...state, number: action.payload };
    case 'minChar':
      return { ...state, minChar: action.payload };
    default:
      return state;
  }
};

function App() {
  const [lock, setLock] = React.useState(lockIcon.open);
  const [isLocked, setIsLocked] = React.useState(false);
  const [state, dispatch] = React.useReducer(validationReducer, validationObj);

  const handleChange = (e) => {
    const validatePass = validate(e.target.value.trim());
    setIsLocked(validatePass);
  };

  const validate = (value) => {
    const checkLength = value.length >= 8;
    const checkLowerCase = /[a-z|ç|ş|ö|ü|ı|ğ]/u.test(value);
    const checkUpperCase = /[A-Z|Ç|Ş|Ö|Ü|İ|Ğ]/u.test(value);
    const checkNumber = /[0-9]/.test(value);

    if (checkLength) {
      dispatch({ type: 'minChar', payload: true });
    } else {
      dispatch({ type: 'minChar', payload: false });
    }

    if (checkLowerCase) {
      dispatch({ type: 'lowercase', payload: true });
    } else {
      dispatch({ type: 'lowercase', payload: false });
    }

    if (checkUpperCase) {
      dispatch({ type: 'uppercase', payload: true });
    } else {
      dispatch({ type: 'uppercase', payload: false });
    }

    if (checkNumber) {
      dispatch({ type: 'number', payload: true });
    } else {
      dispatch({ type: 'number', payload: false });
    }

    const isAllGood =
      checkLength && checkUpperCase && checkLowerCase && checkNumber;

    return isAllGood;
  };

  React.useEffect(() => {
    if (isLocked) {
      const timeout = setTimeout(() => {
        setLock(lockIcon.closed);
      }, 700);
      return () => clearTimeout(timeout);
    } else {
      setLock(lockIcon.open);
    }
  }, [isLocked]);

  return (
    <div className="App" style={{ backgroundImage: `url(${bg})` }}>
      <div className="form-box">
        <ValidationItems state={state} />
        <FormField
          lock={lock}
          handleChange={handleChange}
          isLocked={isLocked}
        />
       
      </div>
       <a className="github-button" href="https://github.com/erenesto/interactive-password-validator" target="_blank">★ on Github</a>
    </div>
  );
}

const ValidationIcon = ({ isDone }) => {
  return isDone ? (
    <svg width="14" height="12" fill="none" xmlns="http://www.w3.org/2000/svg">
      <polyline
        className="check"
        points="1,7 5,11 13,1"
        fill="none"
        stroke="#FFFFFF"
        strokeWidth="2px"
        strokeLinecap="round"
      />
    </svg>
  ) : (
    <svg width="12" height="12" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 6A6 6 0 110 6a6 6 0 0112 0z" fill="#5B9A78" />
    </svg>
  );
};

const ValidationItems = ({ state }) => (
  <ul className="validation-box">
    {validationNames.map((item) => (
      <li
        className={
          state[item.id] === true ? `done validation-item` : 'validation-item'
        }
        key={item.id}>
        <span className="validation-icon">
          <ValidationIcon isDone={state[item.id]} />
        </span>
        {item.name}
      </li>
    ))}
  </ul>
);

const FormField = ({ lock, handleChange, isLocked }) => {
  return (
    <div className="form-field">
      <input
        className="form-input"
        id="password"
        type="password"
        onChange={handleChange}
      />
      <label className="form-label" htmlFor="password">
        Password
      </label>
      <div className="form-input-lock">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          className={`lock-icon ${isLocked && `locked`}`}
          width="20"
          height="20">
          <path
            d={`M4 8V6a6 6 0 1112 ${lock} 2 0 012 2v8a2 2 0 01-2 2H3a2 2 0 01-2-2v-8c0-1.1.9-2 2-2h1zm5 6.73V17h2v-2.27a2 2 0 10-2.009-.005L9 14.73zM7 6v2h6V6a3 3 0 10-6 0z`}
          />
        </svg>
      </div>
    </div>
  );
};



ReactDOM.render(<App />, document.getElementById('root'));
              
            
!
999px

Console