Coder Social home page Coder Social logo

raulfdm / emails-input Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 374 KB

Miro code challenge

Home Page: https://raulmelo-emails-input.netlify.app

License: MIT License

CSS 9.05% HTML 15.93% TypeScript 62.36% JavaScript 12.66%
pub-sub typescript email-input

emails-input's Introduction

Demo

EmailsInput.js

Miro Front-end Engineer test

A vanilla JavaScript input to handle multiple emails in tag input format.

Stack

This lib has 0 production dependencies.

For development mode, it's using:

  • tsdx - Zero-config CLI for TypeScript package development
    • TypeScript
    • Jest
  • live-server - A simple development http server with live reload capability
  • Cypress - End-to-End tests

Demo

If you want to see it in action, you can access https://raulmelo-emails-input.netlify.app/. To see the code of this page, check the index.html file.

Usage

First, you need to be sure you have in you project both emails-input.css and emails-input.js.

Then, load them into your html file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My App</title>
    <!-- CSS import -->
    <link rel="stylesheet" href="emails-input.css" />
  </head>
  <body>
    <!-- JS Import -->
    <script src="emails-input.js"></script>
  </body>
</html>

Doing that, a function called EmailsInput will be globally available.

Now, you can create a root element and pass its reference to EmailsInput:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My App</title>
    <link rel="stylesheet" href="emails-input.css" />
  </head>
  <body>
    <div id="emails-input"></div>

    <script src="emails-input.js"></script>
    <!-- Always after the script -->
    <script>
      var inputContainerNode = document.querySelector('#emails-input');
      var emailsInput = EmailsInput(inputContainerNode);
    </script>
  </body>
</html>

The input will be attached to your root node.

Development

To run this lib in your machine, after clone this repo, install all dependencies:

yarn install

Then, run:

yarn start

This will start the lib itself in a watch mode and also a http server (http://localhost:8080) with ./index.html as entry point.

Tests

Unit

To run once the unit tests, you can use the command:

yarn test

Or:

yarn test --watch

To active jest watcher.

E2E

Before continue, make sure the local server isn't running. The following command needs the port 8080 free.

There are 2 ways to check the End-to-End tests.

  1. opening and see it running in a dashboard:
yarn test:e2e:open
  1. running in the terminal (CI mode):
yarn test:e2e:run

Build

To check the build files, you can simply run:

yarn build

All assets will be generated into dist/ folder.

TODO

  • Move to Netlify to have previews
  • Setup Cypress against published version on CI

License

LICENSE

emails-input's People

Contributors

raulfdm avatar

Watchers

 avatar  avatar  avatar

emails-input's Issues

[Requirement] Change initial implementation

Now, we're rendering everything in the HTML, however we need to inject the content via JS

<div id="emails-input"></div>
<script src="emails-input.js"></script>
<script>
var inputContainerNode = document.querySelector('#emails-input');
var emailsInput = EmailsInput(inputContainerNode, ...);
</script>

[Requirement] Add emails

  • Email block should be created by pressing Enter, entering comma, or by losing focus on the input field.
  • A Block can be deleted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.