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

Feature/highlight only mode #17

Merged
merged 1 commit into from
Mar 21, 2016
Merged

Conversation

MarshallOfSound
Copy link
Member

Implements what some call a "light" mode but for readabilities sake I am called it "highlight only" mode because that is what it actually does.

It disables all rules that aren't the highlight color and adds in a couple of extra ones to get the right look and feel.

As an example here is what GPM looks like with this mode active

light1
light2

The original "dark style" mode is unaffected by these changes and the old enable() method exists and works the exact same way it used to work

/cc @gmusic-utils/gmusic-theme-js @gmusic-utils/gmusic-js

@chrismou
Copy link
Member

Do you happen to have a GPDMP dev build with this integrated?

@MarshallOfSound
Copy link
Member Author

The implementation in GPMDP will have to change a "tiny" bit in order to enable this highlight only mode. Gimme a sec and I'll swing you a mac build

@MarshallOfSound
Copy link
Member Author

@chrismou This is very naive implementation (I need to change the settings window to match the styling still) but the general idea is there. I'll probably have to change the defaults to be Google's orange.

But here is the mac zip
https://mega.nz/#!mVVERDSS!-nTL6bZqrC51XekkLgHjyqF0ckkdtqGqWav6JuEH8_w

key: "enableAll",
value: function enableAll() {
this.disable();
document.querySelector('html').classList.add(CONSTANTS.CLASS_NAMESPACE);
Copy link
Member

Choose a reason for hiding this comment

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

How come the switch from body to html, out of interest?

Just wondering if this has the potential to be a breaking change, in the unlikely event that anyone's extending it and targetting .gmusic-theme.material on the body tag

Copy link
Member Author

Choose a reason for hiding this comment

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

So that the light class can go on the body while still being a subclass to the main theme classs

(If that makes any sense) 👍

@chrismou
Copy link
Member

Aside from the question, all looks good to me on the implementation front. Clicking around and everything looks as expected,

On an unrelated note, you're not actually providing the Google orange (#f16c00) as a colour option. :-P

Also the settings menu header colour is slightly off (Photoshop is telling me it's #f17800) but I figure from what you said you know about that one.

#### `enable()`
Enables the current custom theme
Is a mirror of `enableAll`, present for backwards compatibility
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 "alias" is a more common term than "mirror" =/

@twolfson
Copy link
Contributor

Left a bunch of feedback. As you might guess, I'm opposed to calling it highlight since most theming libraries call themselves dark or light.

Also, I think the creation of enableAll and enableHighlight is unnecessary. People will likely adjust colors at the same time as when they decide to use a "highlight" or "all" theme.

Therefore, it makes the most sense to make it an option in the same location:

theme.updateTheme(type: 'highlight');

If we want enforcement, then that can be done via asserts:

// Define our constants
const THEME_TYPE_ALL = 'all';
const THEME_TYPE_HIGHLIGHT = 'highlight';
const SUPPORTED_THEME_TYPES = [THEME_TYPE_ALL, THEME_TYPE_HIGHLIGHT];

// Inside the `updateTheme` method
var assert = require('assert');
updateTheme: function (options) {
  // If we received a theme, verify it's valid
  if (options.type) {
    assert.notEqual(SUPPORTED_THEME_TYPES.indexOf(options.type), -1,
      'Expected `options.type` to be in ' + JSON.stringify(SUPPORTED_THEME_TYPES) + ' but it was not.');
  }

  // Update theme properties
  this.BACK_PRIMARY = colorObject.backPrimary || this.BACK_PRIMARY;
  // ...
  this.TYPE = colorObject.type || this.TYPE;
  this.redrawTheme();
}

// We can go even further and allow people to use these constants
GMusicTheme.TYPES = {
  ALL: THEME_TYPE_ALL,
  HIGHLIGHT: THEME_TYPE_HIGHLIGHT
};
theme.updateTheme(type: GMusicTheme.TYPES.HIGHLIGHT);

@MarshallOfSound
Copy link
Member Author

@twolfson I agree with lots of your comments, but disagree with the idea that we should be calling it "light" and "dark". I specifically did not name them that because that is not what these methods do. You could use the enableAll method and still end up with what most would consider a "light" theme.

Hence I labelled them after what they literally do as opposed to what they will be primarily used for. Does that make sense?

@twolfson
Copy link
Contributor

Yea, it makes sense but I'm coming from an API design perspective. With a high level module like this, the goal should not be to describe the implementation to end users (e.g. in gmusic.js, we don't name setPlaybackTime as moveSlider).

Instead, we communicate the behavior that the user expects/is looking for. Since the library is a theming library and the canonical language is light/dark, I'm pushing for light/dark so it can stay consistent with the canon.

@chrismou
Copy link
Member

FWIW I'm not sure that applying API design principles to a library like this is entirely right, as this isn't an API - an API definitely shouldn't have methods that change layout, styles, etc. TBH, I'm not sure how I'd categorise this - a control module maybe? It's essentially a UI helper. It doesn't sit above the application, it's part of it.

IMO, this is why your example works for gmusic.js and not this - that library should never be moving a slider, it should be providing the tools to set the playback time, and the app calling it should be moving the slider itself, hence the naming. This library has a method called updateTheme, which is appropriate because it does just that.

But TBH, if we're talking about making decisions based on something that might happen in the future, I'm willing to go along with whatever call @MarshallOfSound makes on it, as long as proper thought's been given to how else this theme library could be used. If an app could use this library to create a dark theme by activating the "light theme" functionality and passing it different config values, then it probably shouldn't be called "light".

@twolfson
Copy link
Contributor

I'm also supportive of whatever @MarshallOfSound decides on as long as it's discussed thoroughly =)

@chrismou I think you might be getting caught up on semantics. When I refer to API design, I mean the interface that a programmer interacts with. This can be a method call or an HTTP call.

That being said, you make a good point about a "dark highlight" and I'm more open to the naming as a result. It does irk me a little still though, maybe we could name it an "accent" color or similar.

I should note that I would still prefer "highlight" (or whatever we call it) to be set via updateTheme since most people consider enabled/disabled to be a binary state and for the previously mentioned grouping of updating a theme at the same time as its colors.

@twolfson
Copy link
Contributor

I looked up what the terms Google uses for Material design. It turns out they are primary, secondary, and accent.

https://www.google.com/design/spec/style/color.html#color-color-schemes

https://www.google.com/design/spec/style/color.html#color-text-background-colors

Maybe we should reconsider our naming scheme to be more inline with Google. For example:

  • Rename BACK_PRIMARY to PRIMARY_COLOR
  • Rename BACK_SECONDARY to SECONDARY_COLOR
  • Rename BACK_HIGHLIGHT to TERTIARY_COLOR
  • Rename FORE_PRIMARY to PRIMARY_TEXT
  • Rename FORE_SECONDARY toACCENT_COLOR

@twolfson
Copy link
Contributor

If we do reconsider our naming scheme for colors, let's do it in a separate PR to prevent overwhelming this one for reviewers x_x

@twolfson
Copy link
Contributor

Also, if we do reconsider our naming scheme for colors, let's add a visual diff test suite so we can verify we have no visual regressions. I left some notes on this in #2

@chrismou
Copy link
Member

I was just referring to the comparison with gmusic.js and the point about it being high level. I got the feeling you were focussing more on the functionality that generated the dist/ folder files than the dist files themselves, but if I've misunderstood then I stand corrected 😊

Agreed on the naming scheme change. I've had to sift through the styles a couple of times to remind myself which is primary and which is secondary (I kept thinking primary was the accent) so yeah, a name change would be welcome if it removed any ambiguity.

We should probably continue this discussion in an issue, as I suspect there'll be plenty of discussion and this chat will end up being buried when the PR gets through 👍

Same with the visual diff suite. The QAs at my work use one for testing ad generation changes, and they swear by it. Not sure which library they use though.

@MarshallOfSound MarshallOfSound force-pushed the feature/highlightOnlyMode branch 2 times, most recently from 8004964 to 4ff0d83 Compare March 12, 2016 06:43
@MarshallOfSound
Copy link
Member Author

@twolfson @chrismou

I just updated the PR.

  • Highlight specific CSS has been moved to its own CSS file to remove the inefficient regexp's
  • Couple of small things from @twolfson comments
  • Light has been renamed completely to highlight

There are two other changes I want to do but not in this PR (I don't want breaking changes in this PR)

  1. Remove enable methods and move to the updateTheme method
  2. Rename all variables to follow the Google standard that @twolfson pointed out.

For now though, I think this PR should solely focus on implementing this feature not changing our API.

@MarshallOfSound MarshallOfSound force-pushed the feature/highlightOnlyMode branch from 4ff0d83 to 84a3c5a Compare March 12, 2016 06:49
@@ -1,3 +1,4 @@
{
"extends": "airbnb/base",
"parser": "babel-eslint"
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that babel-eslint has slipped into this PR. Can we relocate it to a preceeding PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't make sense for it to be in it's own PR as it literally does nothing other than add ES7 syntax support to eslint. We don't use ES7 until this commit so the history wouldn't make much sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

The purpose of breaking down PRs is typically to make the PRs smaller so there's less things for reviewers to consider when reviewing each PR.

Additionally, it makes sure that backwards compatibility doesn't break for library/build upgrades.

However, I think I meant to comment on plugins in Gruntfile rather than the .eslintrc =/

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case I think is is an exception as the addition of this and the plugins line in the gruntfile is too allow the new code to work. It would make sense from a historical standpoint to add dependencies that don't do anything in one PR and then start using them in a different PR?

I think this might be more of a debate into how to use git...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea, I think my comment is mostly pedantic. We should be fine for a small project like this.

@MarshallOfSound MarshallOfSound force-pushed the feature/highlightOnlyMode branch from aba4a24 to 6e442a4 Compare March 12, 2016 11:01
@MarshallOfSound
Copy link
Member Author

@twolfson Ta da? 😄


class GMusicTheme {
static TYPES = {
FULL: 'FULl',
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo here, we want FULL notFULl =P

@twolfson
Copy link
Contributor

Looks great, almost at the finish line.

I think we might be talking past each other again with respect to the .gmusic-theme-highlight selector. I'm saying that the highlight specific CSS (i.e. CSS not used by full) should live in a highlight.css file. This will lead to 3 CSS files:

  • common.css - CSS shared by both full and highlight modes
  • full.css - CSS only used by full mode
  • highlight.css - CSS only used by highlight mode

Then, we can keep it simple and only add/remove a single gmusic-class on body`. Then, in redraws, we generate CSS like:

// At the top
const COMMON_CSS = fs.readFileSync(__dirname + '/../build/common.css', 'utf8');
const FULL_CSS = fs.readFileSync(__dirname + '/../build/full.css', 'utf8');
const HIGHLIGHT_CSS = fs.readFileSync(__dirname + '/../build/highlight.css', 'utf8');

// In _refreshStyleSheet
let styles = COMMON_CSS;
if (this.type === GMusicTheme.TYPES.FULL) {
  styles += FULL_CSS;
} else if (this.type === GMusicTheme.TYPES.HIGHLIGHT_ONLY) {
  styles += HIGHLIGHT_CSS;
}
this.styleElement.innerHTML = this._substituteColors(styles);

@@ -74,6 +96,7 @@ window.GMusicTheme = class GMusicTheme {
this.BACK_HIGHLIGHT = colorObject.backHighlight || this.BACK_HIGHLIGHT;
this.FORE_PRIMARY = colorObject.forePrimary || this.FORE_PRIMARY;
this.FORE_SECONDARY = colorObject.foreSecondary || this.FORE_SECONDARY;
this.type = colorObject.type || this.type;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably add an assertion for colorObject.type to be kind to developers who got a typo (or miss the deprecation notice for accent when we introduce it):

static TYPES = {
  FULL: 'FULL',
  HIGHLIGHT_ONLY: 'HIGHLIGHT_ONLY',
};
static VALID_TYPES = [TYPES.FULL, TYPES.HIGHLIGHT_ONLY];

updateTheme(colorObject) {
  if (colorObject.type !== undefined && GMusicTheme.VALID_TYPES.indexOf(colorObject.type) === -1) {
    throw new Error(`\`updateTheme\` expected \`colorObject.type\` to be in ${JSON.stringify(GMusicTheme.VALID_TYPES)} ` + 
      `but it was "${colorObject.type}"`);
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, silly me. We could have used the object for an even simpler assert:

updateTheme(colorObject) {
  if (colorObject.type !== undefined && GMusicTheme.TYPES[colorObject.type] === undefined) {
    let validTypesStr = JSON.stringify(Object.keys(GMusicTheme.TYPES));
    throw new Error(`\`updateTheme\` expected \`colorObject.type\` to be in ${validTypesStr} ` +
      `but it was "${colorObject.type}"`);
  }

@MarshallOfSound MarshallOfSound force-pushed the feature/highlightOnlyMode branch 2 times, most recently from 17a6613 to 3e3d479 Compare March 21, 2016 05:28
@MarshallOfSound
Copy link
Member Author

@twolfson Finally got around to getting back to this PR. I've fixed the things you mentioned and I have also changed the default "highlight / accent" color to be Googles orange as suggested by @chrismou

I think the CSS file structure now is logical and the naming makes more sense that it did so 👍

Is this GTGN? 🌵

@@ -1,3 +1,4 @@
module.exports = {
CLASS_NAMESPACE: 'gmusic-theme',
CLASS_NAMESPACE_HIGHLIGHT: 'gmusic-theme-highlight',
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are using concatenation, then we should no longer need this highlighting class (since there's nothing to override via HTML elements).

@twolfson
Copy link
Contributor

It looks like we buried a comment that hasn't been fully addressed =/ Going to see if I can find it...

@MarshallOfSound MarshallOfSound force-pushed the feature/highlightOnlyMode branch from 3e3d479 to 1e8012b Compare March 21, 2016 05:54
@twolfson
Copy link
Contributor

Alright, so it looks like we agreed on updating refreshStyleSheet but haven't done the changes to it. Here are the relevant comments:

#17 (comment)

#17 (comment)

To extend on them further, it looks like the majority of the lines in highlight.css should be relocated to a common.css. That is, these lines:

/* Use the custom colors like so
* <<COLOR_NAME>>
* E.g. backSecondary is "<<BACK_SECONDARY>>"
*/
#loading-progress-bar {
border: none;
}
#player.material paper-icon-button.playing > iron-icon::before {
content: '';
display: block;
position: absolute;
z-index: -1;
border-radius: 100%;
height: calc(100% - 16px);
width: calc(100% - 16px);
top: 8px;
left: 8px;
}
.cluster-text-protection::before,
.cluster-text-protection {
background: transparent;
}
.nav-item-container:not(:focus):hover iron-icon {
color: <<FORE_SECONDARY>>;
}
#nav_collections .nav-item-container:focus iron-icon,
.nav-item-container:focus iron-icon {
color: <<FORE_SECONDARY>>;
}
.fade-out:after {
display: none;
}
.column.col-0 .material-card:first-child .image-wrapper {
padding-top: 0;
}
.goog-menu .goog-menuitem.selected .goog-menuitem-content,
.goog-menu .goog-menuitem.selected .goog-menuitem-content:hover {
color: <<FORE_SECONDARY>>;
}
.paper-progress-1 #primaryProgress.paper-progress {
background-color: <<FORE_SECONDARY>>;
}
.album-view .material-container-details .info .title .explicit {
background-color: <<FORE_SECONDARY>>;
}
.paper-input-container-0 .input-content.label-is-highlighted.paper-input-container label,
.paper-input-container-0 .input-content.label-is-highlighted.paper-input-container .paper-input-label {
color: <<FORE_SECONDARY>>;
}
.paper-input-container-0 .add-on-content.is-highlighted.paper-input-container * {
color: <<FORE_SECONDARY>>;
}
.material-container-details paper-fab,
#current-loading-progress {
background-color: <<FORE_SECONDARY>>;
}
#player.material .material-player-middle paper-icon-button[data-id="play-pause"]:not([disabled]) {
color: <<FORE_SECONDARY>>;
}
#loading-overlay.material paper-spinner .circle,
#loading-overlay.material paper-spinner-lite .circle {
border-color: <<FORE_SECONDARY>><<NOTIMPORTANT>>;
}
a.primary {
color: <<FORE_SECONDARY>>;
}
paper-button.material-primary {
background-color: <<FORE_SECONDARY>>;
}
paper-checkbox #checkbox.checked {
border-color: <<FORE_SECONDARY>>;
background-color: <<FORE_SECONDARY>>;
}
paper-checkbox #ink {
color: <<FORE_SECONDARY>>;
}
paper-toggle-button[checked] .toggle-button {
background-color: <<FORE_SECONDARY>>;
}
paper-toggle-button[checked] .toggle-bar {
background-color: <<FORE_SECONDARY>>;
}
paper-toggle-button[checked] .toggle-ink {
color: <<FORE_SECONDARY>>;
}
.paper-slider-0 #sliderKnobInner.paper-slider,
#sliderKnobInner.paper-slider,
.paper-progress-0 #primaryProgress.paper-progress {
background-color: <<FORE_SECONDARY>>;
}
.nav-item-container.selected iron-icon {
color: <<FORE_SECONDARY>>;
}
.upload-dialog-title {
background-color: <<FORE_SECONDARY>>;
}
.paper-input-container-0 .focused-line.paper-input-container {
background-color: <<FORE_SECONDARY>>;
}
.rating-container li {
-webkit-filter: invert(1);
}
#player.material .material-player-middle paper-icon-button[data-id="repeat"][value="LIST_REPEAT"],
#player.material .material-player-middle paper-icon-button[data-id="repeat"][value="SINGLE_REPEAT"],
#player.material .material-player-middle paper-icon-button[data-id="shuffle"][value="ALL_SHUFFLE"],
#player.material .material-player-middle paper-icon-button[data-id="repeat"][value="LIST_REPEAT"],
#player.material .material-player-middle paper-icon-button[data-id="repeat"][value="SINGLE_REPEAT"],
#player.material .material-player-middle paper-icon-button[data-id="shuffle"][value="ALL_SHUFFLE"] {
color: <<FORE_SECONDARY>>;
}
.cluster .lane-button core-icon,
.cluster .lane-button iron-icon,
#player.material .material-player-middle paper-icon-button[data-id="repeat"].active,
#player.material .material-player-middle paper-icon-button[data-id="shuffle"].active,
#player.material #material-player-right-wrapper paper-icon-button[data-id="queue"].opened {
color: <<FORE_SECONDARY>>;
}
.song-row .explicit,
.material-card .explicit {
background-color: <<FORE_SECONDARY>>;
}
.material-detail-view .material-container-details .read-more-button {
color: <<FORE_SECONDARY>>;
}
.goog-buttonset-default {
background-color: <<FORE_SECONDARY>>;
}
button.goog-buttonset-default,
button.goog-buttonset-default:hover {
background-color: <<FORE_SECONDARY>>;
}
.top-charts-view .song-row [data-col="index"] .column-content,
.material-card .details .left-items .index,
.more-songs-container {
color: <<FORE_SECONDARY>>;
}

Then, the concatenation from #17 (comment) should be usable:

let styles = COMMON_CSS;
if (this.type === GMusicTheme.TYPES.FULL) {
  styles += FULL_CSS;
} else if (this.type === GMusicTheme.TYPES.HIGHLIGHT_ONLY) {
  styles += HIGHLIGHT_CSS;
}

@MarshallOfSound MarshallOfSound force-pushed the feature/highlightOnlyMode branch from 1e8012b to f2a91a7 Compare March 21, 2016 06:05
@MarshallOfSound
Copy link
Member Author

@twolfson Finally clicked onto what you were saying this whole time 👍

I switched up your if statement to a switch but yeah. #Igetitnow 👍

@@ -56,7 +56,7 @@ included will not be changed from the defaults. `enabled` is set to false by de

### States

#### `enable()`
#### `enable`
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 accidentally deleted the parentheses here. We should prob keep them to be consistent with the rest of the methods

@twolfson
Copy link
Contributor

Looks good. Left a few pedantic comments. Feel free to ship with or without them :shipit:

@twolfson
Copy link
Contributor

Also, I know we have been doing a lot of patch releases but this should prob be a minor release =P

@MarshallOfSound MarshallOfSound force-pushed the feature/highlightOnlyMode branch from f2a91a7 to 0641f32 Compare March 21, 2016 12:05
@MarshallOfSound
Copy link
Member Author

Fixed up a couple of pedantics.

Left the default case as it is a linting thing 🌵

I'll land this in a minor once travis finishes

@chrismou
Copy link
Member

👍

MarshallOfSound added a commit that referenced this pull request Mar 21, 2016
@MarshallOfSound MarshallOfSound merged commit 47cd8b0 into master Mar 21, 2016
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