Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

squash changes v1.0 #1

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open

squash changes v1.0 #1

wants to merge 14 commits into from

Conversation

fallemand
Copy link
Owner

Issue

Dejo en el PR solo los cambios realizados sobre la base generada por el ui-component.

Copy link

@joelalejandro joelalejandro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Está genial el laburo del componente, @fallemand. Hay cosas que se pueden hacer con un poco más de claridad o más simples, te dejé un par de comments. ^^

<form>
<div class="ui-telephone">
<div class="ui-telephone__number">
<input id="telephone" type="text" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ojo con los selectores #id. Siempre es preferible (para componentes UI especialmente) utilizar [data-js] como selector para integraciones con JavaScript, como sugiere este artículo.

@@ -0,0 +1,11 @@
{
'required': 'Completa este dato.',
Copy link

@joelalejandro joelalejandro Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Para documentos JSON se utiliza " en vez de '. Más información acá.

this.countriesList = require('./country-list');
this.field = arguments[0];
this.classNames = {
tel : 'ui-telephone',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En este caso, como classNames funciona como un hash map, las claves deberían estar entrecomilladas y no irían los espacios antes del :.

this.field = arguments[0];
this.classNames = {
tel : 'ui-telephone',
telError : ' ui-telephone--error',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Los espacios delante del nombre de la clase pueden evitarse haciendo a la hora de implementar algo como esto:

['tel', 'telSuccess'].map(function(k) { 
  return component.classNames[k]; 
}).join(' ');  // returns 'ui-telephone ui-telephone--success'

//----------------------------------------------------
// Define our constructor
//----------------------------------------------------
global.jsTelephoneInput = function() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se podrían enumerar directamente los parámetros en vez de depender de arguments que le quita un poco de legibilidad al constructor.

global.jsTelephoneInput = function(field, settings) {
// ...

};

//Checks parameters written as html attributes
for (var parameter in defaults) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Para iterar en un objeto, es más seguro utilizar Object.keys para no leer propiedades de forma inesperada (for..in entra al prototype).

variable = validation.innerHTML.substring(start + 2, end);
validation.innerHTML = (start > -1) ? validation.innerHTML.replace('##' + variable + '##', getTextToRepalce(variable) ) : validation.innerHTML;

function getTextToRepalce(variable) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acá debería ser getTextToReplace.


// Creates list of countries
function createCountriesList(elements) {
for (var i = 0; i < component.countriesList.length; i += 1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esto también se puede resolver utilizando Array.forEach, que ya tiene soporte completo en todos los browsers, pudiendo hacer:

component.countriesList.forEach(function(country) {
  // ...
  listItem.innerHTML += '<span class="' + component.classNames.telFlagsListItemName + '">' + country[0] + '</span>';
  // ...
});

top: 50%;
right: 0;
border: 4px solid transparent;
content: "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Para qué figura content: "" si no se asignada nada?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelalejandro El content debe estar, sino no se renderiza el elemento.

&.ui-telephone__flag-icon--np {
background-color: transparent;
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aparentemente el sprite de flags incluye muchísimas banderas que no usamos. ¿Se podrían sacar?

</div>
</form>

<h3>Resultado</h3>
Copy link

@HGARZON HGARZON Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ojo que no existen ni el <h1> ni el <h2>. Para que el contenido sea accesibilidad es necesario que el orden de los headings sea natural (<h1>, <h2>, <h3>, etc...).

Copy link

@francomanzmeli francomanzmeli Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agrego, tiene que haber solamente un h1 por template, el resto lo podes manejar.

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Telephone </title>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si el lang es "es", no debería decir "Teléfono"? O podría ser algo más descriptivo onda "Validación internacional de Teléfono con JS"

<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://http2.mlstatic.com/secure/org-img/ch/ui/1.1.1/chico.min.css" rel="stylesheet" type="text/css">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podrías usar la última versión de chico? 2.0.5 sino me equivoco...


//Check if parameters exists.
if(!arguments[0] || !arguments[1] || typeof arguments[1] !== "object") {
console.log('js-telephone-input: field or parameters are not defined');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Los console.log no deberían borrarse?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HGARZON ahora ví este - es un control de errores, la otra alternativa es tirar un throw new Error('...').

</thead>
<tbody>
<tr>
<td>required</td>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podes agregar scope="row" como hiciste a los th pero aplicado a los td

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants