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

implement "server card" design #2839

Merged
merged 22 commits into from
Dec 9, 2016
Merged

implement "server card" design #2839

merged 22 commits into from
Dec 9, 2016

Conversation

trevj
Copy link
Contributor

@trevj trevj commented Dec 6, 2016

This implements much of the final "server card" design:

  • flexbox-based card layout
  • connect/disconnect graphics
  • cards expand to fill all available space when there's just one, shortening a little when there are multiple contacts

Things to note:

  • I removed the text box - we should implement the "empty server list" mock next, and rely on URL interception in the meantime.
  • I'm still checking with UX w.r.t. typography (standard Material Design, or what's in the mocks).

This change is Reviewable

@trevj
Copy link
Contributor Author

trevj commented Dec 6, 2016

Apologies, I forgot to attach screenshots.

screen shot 2016-12-05 at 7 40 54 pm

screen shot 2016-12-05 at 7 36 52 pm

screen shot 2016-12-05 at 7 36 58 pm

@fortuna
Copy link
Contributor

fortuna commented Dec 7, 2016

Are we completely removing the option of explicitly adding a server?
Also, should we make it clear there's a card by adding a margin? It would be nice to have the same UI whether it's one or more items too.

@trevj
Copy link
Contributor Author

trevj commented Dec 7, 2016

  1. Correct. I see nothing in the mocks with which to explicitly input an access code. The mocks show a screen with which to replace the server list when the server list has no entries. That isn't done yet - I don't think that mock was there when I started this PR :-)
  2. Again, I'm just going by the UX mocks.

@trevj
Copy link
Contributor Author

trevj commented Dec 7, 2016

Forgot to reference this issue:
#2815

return new UproxyServerRepository(
getLocalStorage(), core, vpnDevice);
} catch (e) {
console.warn('local storage unavailable');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need this mock repository?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I have something to pass to UproxyServerRepository when testing in Chrome.

chrome.app.window.create('index_vulcanized.html', null, (appWindow) => {
chrome.app.window.create('index_vulcanized.html', {
// When running as a Chrome extension for the first time,
// open in a nice Nexus 5-like 16:9 aspect ratio (vertically).
Copy link
Contributor

Choose a reason for hiding this comment

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

Why Nexus 5 ratio?

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 figured it's a common aspect ratio. I replaced the explicit reference to a Nexus 5 with a pretty swish list of all common mobile devices.

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Copy link
Contributor

Choose a reason for hiding this comment

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

The connected icon is svg, but the disconnected is png. Should we stick to svg?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's weird - but that's what I got with UX. I will follow up with 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.

Now 100% SVG!

@@ -82,3 +120,19 @@ Promise.all([serversListPagePromise, intents.GetGlobalIntentInterceptor()]).then
}
}
);

// Add some mock servers if we are running as a Chrome extension.
serversListPagePromise.then((serverListPage) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

For platform-specific code, I think it's cleaner if we use implementation replacement.
In this case, we could replace the ServerRepository with one containing the two demo servers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting idea. That would also let me mock out unreachable servers which is a limitation of the current approach. Let me get back to you on this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I did this - now if localStorage is unavailable a mock ServerRepository is returned. This allows me easily mock unreachable server behaviour and in doing so I discovered a bug in server_list.ts - thanks :-)

}));
} catch (e) {
console.warn('could not load servers: ' + e.message);
return Promise.resolve([]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's throw and let the client decide how to handle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


private disconnected(msg: string) {
this.switchState(State.DISCONNECTED);
this.status.innerHTML = msg;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use this.status.textContent instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}

this.switchState(State.CONNECTING);
this.status.innerHTML = 'Connecting...';
Copy link
Contributor

Choose a reason for hiding this comment

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

Use this.status.textContent instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice. Done throughout.

public pressAddServer(): Promise<ServerEntryComponent> {
return this.servers.addServer(this.addTokenText.value).then((server) => {
public enterAccessCode(code: string) {
return this.servers.addServer(code).then((server) => {
this.addServer(server);
});
}

private addServer(server: Server) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call this addServerCard and change enterAccessCode to addServer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

resolve(new ServerListPage(appWindow.contentWindow.document.body, servers));
const listElem = appWindow.contentWindow.document.body.querySelector('#server-list') as HTMLElement;
const serverListPage = new ServerListPage(listElem, servers);
appWindow.contentWindow.addEventListener('resize', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

When would a resize trigger? Do we really need to listen to this event?

Copy link
Contributor Author

@trevj trevj Dec 7, 2016

Choose a reason for hiding this comment

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

Correct, it will never trigger on a mobile device. I found it useful during developing but would agree it's not strictly necessary and adding it was quite messy. Happy to remove if you'd prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should instead use CSS + class names for the positioning of the elements.
For example, we could have a class for regular cards, and a class for when it's a single card.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, might be possible. I'll have to experiment a bit with that.

}
</style>

<style is="custom-style">
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this custom-style?

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'm using it so I can re-use the Material Design colour vars.

I found some more info on this attribute here:
https://www.polymer-project.org/1.0/docs/api/custom-style

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move all the style into this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can't because those styles only to web components - if we try to hide, say, the scrollbar here then that fails. I don't very much like this limitation but was quite happy to be able to import colours and opacity...

@trevj
Copy link
Contributor Author

trevj commented Dec 7, 2016

Update: I had broken server persistence. It's now basically identical to master except it can handle the exceptions thrown by the new mock storage.

@fortuna
Copy link
Contributor

fortuna commented Dec 8, 2016

Reviewed 4 of 8 files at r1.
Review status: 4 of 8 files reviewed at latest revision, 8 unresolved discussions.


src/cca/scripts/background.ts, line 86 at r1 (raw file):

Previously, trevj wrote…

I figured it's a common aspect ratio. I replaced the explicit reference to a Nexus 5 with a pretty swish list of all common mobile devices.

I wonder if this is needed at all. If you resize the window, won't it accommodate things automatically?


Comments from Reviewable

@fortuna
Copy link
Contributor

fortuna commented Dec 8, 2016

Reviewed 1 of 1 files at r2, 1 of 2 files at r5, 2 of 2 files at r7.
Review status: all files reviewed at latest revision, 6 unresolved discussions.


Comments from Reviewable

@trevj
Copy link
Contributor Author

trevj commented Dec 9, 2016

OK, I was able to use only CSS to control the card height. PTAL!

@fortuna
Copy link
Contributor

fortuna commented Dec 9, 2016

👍


Reviewed 3 of 4 files at r10, 3 of 4 files at r11.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


src/cca/index.html, line 83 at r11 (raw file):

        real Android device will be this short.
      */
      min-height: 300px;

Not for this PR, but we should move away from using px and use some density independent unit instead, such as pt or em. See https://www.tutorialspoint.com/css/css_measurement_units.htm


src/cca/ui_components/server_card.ts, line 80 at r11 (raw file):

    this.switchState(State.DISCONNECTING);
    this.status.textContent = 'Disconnecting...';
    this.button.setAttribute('src', '../../assets/button/disconnected.svg');

I think it's more maintainable if we avoid .. in paths, restricting relative paths only for descendants and absolute paths otherwise.. Do you know if /assets/button/disconnected.svgworks? Or maybe /www//assets/button/disconnected.svg?


Comments from Reviewable

@trevj
Copy link
Contributor Author

trevj commented Dec 9, 2016

I tried using chrome.extension.getURL to avoid relative URLs but it doesn't seem to be available when I load the app in Chrome:
https://developer.chrome.com/extensions/extension#method-getURL

I think we should leave that for a future PR.

@fortuna
Copy link
Contributor

fortuna commented Dec 9, 2016

Sounds good to me 👍

@trevj trevj merged commit 1f480e4 into master Dec 9, 2016
@trevj trevj deleted the trevj-big-button branch December 12, 2016 16:30
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.

2 participants