-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from stone-payments/task/CMPDC-970
CMPDC-970: Moves Login from sling-web
- Loading branch information
Showing
10 changed files
with
231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# sling-web-component-snackbar | ||
|
||
## Install | ||
|
||
``` | ||
npm instal sling-web-component-login | ||
``` | ||
|
||
## Tag | ||
|
||
```HTML | ||
<sling-login></sling-login> | ||
``` | ||
|
||
## Dependencies | ||
|
||
* **sling-web-component-input** | ||
* **sling-web-component-button** | ||
* **sling-helpers** | ||
|
||
## Events | ||
|
||
This component does not emit events. | ||
|
||
## Examples | ||
|
||
All component examples can be emulated using the `npm start sling-web-component-login` command. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "sling-web-component-login", | ||
"version": "1.5.0", | ||
"description": "Sling Login component", | ||
"author": "Stone Pagamentos", | ||
"module": "src/index.js", | ||
"main": "dist/cjs/es5/index.js", | ||
"jsnext:main": "dist/es/es6/index.js", | ||
"browser": "dist/iife/es6/index.js", | ||
"dependencies": { | ||
"sling-web-component-button": "^1.5.0", | ||
"sling-web-component-input": "^1.5.0", | ||
"sling-helpers": "^1.5.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<script src="../../../scripts/helpers/injectDependencies.js"></script> | ||
<title>sling-login</title> | ||
</head> | ||
<body> | ||
<sling-login></sling-login> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
:host .login { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
:host .login__title { | ||
font: var(--typography-title); | ||
color: var(--color-white-label-grey); | ||
text-transform: uppercase; | ||
} | ||
|
||
:host .login__error { | ||
color: var(--color-danger); | ||
text-align: center; | ||
font: var(--typography-caption); | ||
margin-top: 0; | ||
} | ||
|
||
/* for compatibility */ | ||
|
||
sling-login .login { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
sling-login .login__title { | ||
font: var(--typography-title); | ||
color: var(--color-white-label-grey); | ||
text-transform: uppercase; | ||
} | ||
|
||
sling-login .login__error { | ||
color: var(--color-danger); | ||
text-align: center; | ||
font: var(--typography-caption); | ||
margin-top: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { isFunction } from 'sling-helpers'; | ||
import 'sling-web-component-button'; | ||
import 'sling-web-component-input'; | ||
|
||
export class ScLogin extends HTMLElement { | ||
constructor() { | ||
super(); | ||
this.handleClick = this.handleClick.bind(this); | ||
this.attachShadow({ mode: 'open' }); | ||
} | ||
|
||
get errorMessage() { | ||
return this._errorMessage; | ||
} | ||
|
||
set errorMessage(value) { | ||
this._errorMessage = value; | ||
this.handleError(value); | ||
} | ||
|
||
connectedCallback() { | ||
this.shadowRoot.innerHTML = ` | ||
<style> | ||
@import url('sling-web-component-login/src/index.css'); | ||
</style> | ||
<div class="login"> | ||
<p class="login__title"> | ||
Acesse Sua Conta | ||
</p> | ||
<sling-input | ||
id="email" | ||
required="true" | ||
type="email" | ||
label="Email"> | ||
</sling-input> | ||
<sling-input | ||
id="pw" | ||
required="true" | ||
type="password" | ||
label="Senha"> | ||
</sling-input> | ||
<p class="login__error"></p> | ||
<sling-button color="success">Entrar</sling-button> | ||
</div> | ||
`; | ||
this.setupLogin(); | ||
} | ||
|
||
handleClick() { | ||
if (isFunction(this.onSubmit)) { | ||
this.$login__error.innerText = ''; | ||
const email = this.$email.value; | ||
const password = this.$password.value; | ||
this.onSubmit({ email, password }); | ||
} | ||
} | ||
|
||
handleError(value) { | ||
this.$login__error.innerText = value; | ||
} | ||
|
||
setupLogin() { | ||
this.$login__error = this.shadowRoot.querySelector('.login__error'); | ||
this.$email = this.shadowRoot.querySelector('#email'); | ||
this.$password = this.shadowRoot.querySelector('#pw'); | ||
this.$button = this.shadowRoot.querySelector('sling-button'); | ||
this.$button.addEventListener('click', this.handleClick); | ||
} | ||
|
||
disconnectedCallback() { | ||
this.$button.removeEventListener('click', this.handleClick); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/sling-web-component-login/src/component/Login.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-disable */ | ||
import { Login } from './Login.js'; | ||
|
||
// TODO Write me! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import url('assets/Login.css'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { registerComponent } from 'sling-helpers'; | ||
import { ScLogin } from './component/Login.js'; | ||
|
||
registerComponent('sling-login', ScLogin); |