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

Make it sexier in macOS #336

Merged
merged 12 commits into from
Mar 29, 2017
Merged

Make it sexier in macOS #336

merged 12 commits into from
Mar 29, 2017

Conversation

edipox
Copy link
Contributor

@edipox edipox commented Feb 2, 2017

@RocketChat/core

Changes to make it look cooler in macOS by removing the titlebar

screen shot 2017-02-02 at 10 57 30

@CLAassistant
Copy link

CLAassistant commented Feb 2, 2017

CLA assistant check
All committers have signed the CLA.

@alexbrazier
Copy link
Contributor

What happens if you hide the server list?

@alexbrazier
Copy link
Contributor

@edipox This looks good, but the only issue is that if you hide the server list it looks like this:
image

Are you able to make it so that when you toggle the server list you get the original title bar back?

@edipox
Copy link
Contributor Author

edipox commented Feb 15, 2017

@alexbrazier thank you! Setting the title bar back is a good idea too. From my side I have another idea for possible ways to fix this. But I couldn't go back to it yet

@edipox
Copy link
Contributor Author

edipox commented Feb 16, 2017

@alexbrazier I tried to add the title bar back but I couldn't. I don't know if that is possible without re creating the window. So the solution I came with is... kind of a hack: injecting css in the webview content to fix the issue. It's an ugly hack but it works

example

@alexbrazier
Copy link
Contributor

Awesome @edipox , looks good. I think you are right that you have to inject css, but I found a function to do it without having to execute javascript using insertCSS.

@@ -131,6 +132,11 @@ class SideBar extends EventEmitter {
img.src = `${hostUrl}/assets/favicon.svg?v=${Math.round(Math.random()*10000)}`;
}

fixTitleBar () {
const fixScript = 'document.body.innerHTML = document.body.innerHTML + "<style>.side-nav{ margin-top: 15px; }</style>"';
document.getElementsByTagName('webview')[0].executeJavaScript(fixScript);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will always add the margin even if you show the side bar. It will also only work on the first server.

Try moving the CSS injection to the show and hide functions like this in hide:

document.querySelectorAll('webview').forEach((webviewObj) => webviewObj.insertCSS('aside.side-nav{margin-top:15px;overflow:hidden;}'));

And this in show:

document.querySelectorAll('webview').forEach((webviewObj) => webviewObj.insertCSS('aside.side-nav{margin-top:0;overflow:auto;}'));

You could also create an injectCSS function in the webview class to reduce this duplicated code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Awesome suggestions! Thanks @alexbrazier I'll go for that later

@edipox
Copy link
Contributor Author

edipox commented Feb 22, 2017

Hi @alexbrazier I followed your suggestions. I had to create some functions because I needed to do the fix for the first render. I also added an animation for the server list hide event.

@edipox
Copy link
Contributor Author

edipox commented Feb 23, 2017

Fixed conflicts with develop

@@ -192,12 +192,20 @@ class SideBar extends EventEmitter {
document.body.classList.add('hide-server-list');
localStorage.setItem('sidebar-closed', 'true');
this.emit('hide');
if (process.platform === 'darwin') {
[].forEach.call(document.getElementsByTagName('webview'),
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use querySelectorAll('webview') you can use forEach like document.querySelectorAll('webview').forEach(... instead of using [].forEach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first time I tried I got an error that's why a went getElementsByTagName, but I guess the error was related to something else because it's working now 👍

@engelgabriel engelgabriel modified the milestone: 2.5.0 Mar 1, 2017
Copy link
Member

@rodrigok rodrigok left a comment

Choose a reason for hiding this comment

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

I'm not able to drag the application window

Copy link
Member

@rodrigok rodrigok left a comment

Choose a reason for hiding this comment

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

There is a strange color diff when I'm using a different color for sidebar
image

@engelgabriel engelgabriel modified the milestones: 2.6.0, 2.5.0 Mar 5, 2017
@edipox
Copy link
Contributor Author

edipox commented Mar 5, 2017

Hi @rodrigok I couldn't reproduce the color diff bug.
But I could somehow reproduce the one related to drag the application window.

example

As you can see in the gif, initially I was able to drag the window, but when I open the dev tools I lost the ability to drag the window as I normally do, this seems to be a known electron issue given that another user experienced it here: electron/electron#3329 (comment)

In the final part of the gif you can see that I was still able to drag the window with dev tools open (inner layout) by using the resize windows controls. Here you can find another example of this: electron/electron#3329 (comment)

@alexbrazier
Copy link
Contributor

@rodrigok For me colour difference only seems to exist after you change the colour. If you reload the server, or application then it picks up the correct colour. Is it the same for you?

@rodrigok
Copy link
Member

@alexbrazier Yeap, you'r right.

@edipox Yes, the DD works if I close the dev tools

@rodrigok
Copy link
Member

@engelgabriel What do you think? Can we merge this?

@engelgabriel engelgabriel merged commit 58568e1 into RocketChat:develop Mar 29, 2017
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.

5 participants