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

Default UI for /hoodie/account #75

Merged
merged 12 commits into from
Nov 27, 2016

Conversation

mbad0la
Copy link
Contributor

@mbad0la mbad0la commented Oct 6, 2016

This is in reference to hoodiehq/camp#22

Work in Progress

  • Create default assets
  • Set routes for default assets
  • Build a plain UI for logged in users
  • Build a plain UI for logged out users
  • Cosmetic changes
  • Finishing up

@gr2m
Copy link
Contributor

gr2m commented Oct 6, 2016

Tests are failing due to #3, you can ignore them.

Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

I like the clean, simple design, great starting point! Here is a preview for others

screen shot 2016-10-13 at 10 31 42

Some notes

  • Can we avoid alerts and instead show inline error messages or notifications?
  • When signing up, run sign in directly, do not ask user to sign in manually

handler: function (request, reply) {
reply.file(path.join(__dirname, '..', 'public', 'client.js'))
}
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of defining separate paths for each static asset, let’s use inert to server all assets from the public/ folder at the / root path.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll use inert. Any hoodie repository already using inert? Might help me a lot.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we use inert in the main hoodie repository to serve static assets from the Hoodie app’s public/ folder

Copy link
Contributor

Choose a reason for hiding this comment

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

instead of the three reply.file statements, you can do

server.route({
  method: 'GET',
  path: '/{p*}',
  handler: {
    directory: {
      path: path.join(__dirname, '..', 'public'),
      listing: false,
      index: true
    }
  }
})

and adjust the paths of <script src="/default/js/default.js"></script> and <link rel="stylesheet" href="/default/css/default.css"> to ./client.js and ./client.css

Open browser console and play with <code>hoodie.account</code>.
</p>
<div class="generic-loader-wrap"></div>
<script src="/default/js/default.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put all the HTML into index.html already, and just toggle it depending on the user’s state. Check out this account.html file from hoodie-app-tracker. It has a data-account-state="" property on the <body> tag, we set / change the state in common.js and we use the html attribute in CSS to toggle content in app.css

That helps a lot with a cleaner separation of content (HTML) and behavior (JS)

Hope that makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @gr2m my current implementation is better is my opinion as it helps reduce the DOM by controlling DOM manipulations through JS.

HTML is JS has faced a lot of apprehension but it is gaining a lot of acceptance lately due to React with it's JSX Syntactic Sugar.

I seriously feel that it would be easier to maintain the code using my approach, although if you do think I should follow the approach given in hoodie-app-tracker, I'll do it.

Please let me know what you think is best. I'll do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

A big objective for us is the accessibility and contributor-friendlyness of Hoodie’s code base. I agree that React and virtual DOM is fascinating, but it’s not solving problems that we have right now :) The simpler we can keep it, the better, so I’d rather like to follow the old-school approach and just use HTML and toggle content with JavaScript for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright!

border-radius: 50%;
}
.generic-loader-wrap:before {
content: url(http://hoodiehq.github.io/hoodie-css/src/content_img/animals/low-profile-dog-1.png);
Copy link
Contributor

Choose a reason for hiding this comment

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

once we use inert (see comment below), let’s put this image into the public/ folder and load it with a relative path. We try avoiding loading assets from URLs to make sure that the apps work when run locally, even when not connected to the internet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gr2m can you have a look at the html and js file now?
I've separated the html from the js file. Please comment so that I may continue finishing this up. Thanks!

margin-left: -30px;
margin-top: -40px;
color: #FFF;
}
Copy link

Choose a reason for hiding this comment

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

Can we make sure each set of rules are separated with a linebreak please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Charlotteis sure! Must have missed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

please add the empty lines and see my other comment. Otherwise it’s looking good 👍


<div data-hide="false" class="generic-loader-wrap"></div>

<div data-hide="true" class="input-forms">
Copy link

Choose a reason for hiding this comment

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

Rather than divs, which give no semantic indication of what the sections are, would section be better here for each of the 'Sign In', 'Sign Up, 'Sign Out', 'Update Account', 'Destroy' etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't follow how using section might be better here. Can you explain it a bit? I can always add an id attribute to each component in the UI.

Copy link

Choose a reason for hiding this comment

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

These are all sections of content, so sections seems to make sense.
I try not to use div wherever possible as div is not very semantic HTML.

http://html5doctor.com/lets-talk-about-semantics/ might explain better.

a better question might be, why don't you think we should use them? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Charlotteis semantically speaking, I think I get your point. I'll make the relevant changes soon.

handler: function (request, reply) {
reply.file(path.join(__dirname, '..', 'public', 'client.js'))
}
})
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of the three reply.file statements, you can do

server.route({
  method: 'GET',
  path: '/{p*}',
  handler: {
    directory: {
      path: path.join(__dirname, '..', 'public'),
      listing: false,
      index: true
    }
  }
})

and adjust the paths of <script src="/default/js/default.js"></script> and <link rel="stylesheet" href="/default/css/default.css"> to ./client.js and ./client.css

@@ -3,11 +3,47 @@
<head>
Copy link

Choose a reason for hiding this comment

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

could we add lang="en" to the <html> tag above?

<div data-hide="false" class="generic-loader-wrap"></div>

<section data-hide="true" class="input-forms">
<h3>Sign In</h3><br>
Copy link

Choose a reason for hiding this comment

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

As the first header on the page, this should not be an h3.
Headings should not be used for decoration, they are important for content navigation.

So, the first heading on a page should be an H1.

Perhaps we can have an H1 heading of "Account" and then all the h3's can be h2 subheadings?


<section data-hide="true" class="input-forms">
<h3>Sign In</h3><br>
<input name="login-username-field" type="text" placeholder="Username"><br>
Copy link

Choose a reason for hiding this comment

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

Could we add labels to all form inputs, it's more accessible. Placeholders dissapear on focus.

@mbad0la
Copy link
Contributor Author

mbad0la commented Nov 23, 2016

@gr2m @Charlotteis please have a look at the new commits

<label>USERNAME</label><br>
<input name="login-username-field" type="text"><br>
<label>PASSWORD</label><br>
<input name="login-password-field" type="password"><br>
Copy link
Contributor

Choose a reason for hiding this comment

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

two things:

  • avoid using uppercase only text because screen readers will read it out letter by letter, you can use css for that (text-transform: uppercase)
  • add the for attribute to labels and id attributes to the respective inputs, with same values, e.g.
<label for="login-username-field">Username</label><br>
<input name="username" type="text" id="login-username-field"><br>

@mbad0la
Copy link
Contributor Author

mbad0la commented Nov 23, 2016

I think it's done now. Please let me know the same 😛

Copy link
Contributor

@gr2m gr2m left a comment

Choose a reason for hiding this comment

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

looks good to me now, thanks! Ping @Charlotteis

@varjmes
Copy link

varjmes commented Nov 27, 2016

Great work @mbad0la!
This was a really good effort, thanks for bearing with us.
Approved!

@gr2m
Copy link
Contributor

gr2m commented Nov 27, 2016

I will fix the CI errors and merge 👍

@mbad0la
Copy link
Contributor Author

mbad0la commented Nov 27, 2016

Great! Thanks for being so patient 🙂

@gr2m
Copy link
Contributor

gr2m commented Nov 27, 2016

One thing that totally slipped in my review is that you used arrow functions in public/client.js, but as the code runs in browsers and we currently support browsers down to IE 10, we have to use good old es5 :) I fixed it now in
5c2c3c8

@gr2m gr2m merged commit 3b83a9a into hoodiehq-archive:master Nov 27, 2016
@mbad0la
Copy link
Contributor Author

mbad0la commented Nov 27, 2016

Oh, so sorry for that, didn't know about it and it has become kind of a reflex to write arrow functions :p

@gr2m
Copy link
Contributor

gr2m commented Nov 27, 2016

I know, same here :) no worries at all

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.

3 participants