Skip to content
New issue

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

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

Already on GitHub? # to your account

Refactor styles #161

Merged
merged 12 commits into from
Oct 23, 2018
Merged

Refactor styles #161

merged 12 commits into from
Oct 23, 2018

Conversation

earshinov
Copy link
Contributor

@earshinov earshinov commented Oct 17, 2018

A styles refactoring proposal as a follow-up to #159 (review).

This PR is on top of #159.

Copy link
Owner

@madoar madoar 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 approach of this PR a lot!

I believe the code needs some additional comments to help the reader understand what exactly happens happens and how the different mixins function together.
For example the application of .define-state(...) can be hard to understand.

Shall I merge #159 separately?

.state-circle-with-border-hover(@dot-border-width, @circle-color) {
border-color: darken(@circle-color, 10%);

li .step-indicator {
Copy link
Owner

Choose a reason for hiding this comment

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

I'm in favor of adding this and the following blocks to the previous li block:

li {
  .step-indicator {
    ...
  }

  &.current .step-indicator {
    ...
  }

  ...
}

I think this makes the code easier to read and understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@earshinov
Copy link
Contributor Author

@madoar,

I believe the code needs some additional comments to help the reader understand what exactly happens happens and how the different mixins function together.
For example the application of .define-state(...) can be hard to understand.

Yes, definitely. I did not write any comments in the first place because I was not sure if you would favor my approach.

Shall I merge #159 separately?

Yes, I think it should not be blocked by this refactoring.

@earshinov
Copy link
Contributor Author

Added code comments in 39b7430. If everything is OK, I can then apply the same refactoring procedure to the styles for horizontal layout.

// Arguments:
// @width - step indicator width
// @height - step indicator height
// @border - step indicator border
Copy link
Owner

Choose a reason for hiding this comment

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

I think the arguments need some more description.
For example, the @border argument description doesn't specify what information the argument needs to contain:

  • whether a border should be drawn (i.e. a boolean)
  • how thick a border should be drawn
  • or something entirely different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wz-color-default: #E6E6E6;
@wz-color-current: #808080;
@wz-color-done: #339933;
@wz-color-optional: #38ef38;
@wz-color-editing: #FF0000;

/*
dot definitions
*/
dot definitions
Copy link
Owner

Choose a reason for hiding this comment

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

I know this isn't really a part of this PR, but can you please change the style of the old comments:

/*
...
*/

to fit with the new ones:

// ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.state-circle-hover(@big-dot-width, @big-dot-height, @dot-border-width);
.state-circle-with-border-and-content-hover(@dot-border-width, @wz-color-default);
}
&.small ul.steps-indicator {
Copy link
Owner

Choose a reason for hiding this comment

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

Sometimes, a user of the library may want to completely override the style of the library, i.e. he doesn't want to use any existing style but define his own one.
In such a case it would be useful to define a kind of "empty" default style.

I'm not sure how this could be done best, and whether this fits in the scope of this PR.
My current approach to such questions was to recommend using a non existing layout name in [navBarLayout], but I'm not sure if this is the best approach.
What do you think about 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.

My first thought was that providing a default style is a good and easily implemented idea:

  ul.steps-indicator {
    .state-default(@color) { }
    .state-hover(@color) { }
    .state-nohover(@color) { }
    .define-style(/* ??? */);
  }

...but we will then have to decide which indicator width, height and border-width users are going to need. There will always be users unsatisfied with any assumption we make, so I'd rather not provide any defaults at all to avoid such questions.

.line(@big-dot-width, @big-dot-height, @wz-color-default);
}
// default steps shouldn't change when hovered, because they aren't clickable
li.default a:hover .step-indicator {
Copy link
Owner

Choose a reason for hiding this comment

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

Sometimes we're only selecting a css class, e.g. .step-indicator, while we're some other times selecting an element and a css class, e.g. ul.steps-indicator.
I think it would be best if we try to always use a combination of an element and a css class, because it makes it easier to identify on which element type a css class is applied.
What do you think?

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 think it would be best if we try to always use a combination of an element and a css class, because it makes it easier to identify on which element type a css class is applied.

True, unless the element type is div or span, which carry little meaning. I tend to think of div's and span's as placeholders to which some meaning is assigned by way of CSS classes, so adding div or span to CSS selectors, in my opinion, has little sense. The code is good as it is :)

@earshinov
Copy link
Contributor Author

@madoar , I have pushed another set of changes. Please review.

@madoar
Copy link
Owner

madoar commented Oct 21, 2018

I'm ok with merging this PR.
Do you want to append the changes for the horizontal layouts to this PR, or do you want to create a new one for them?

@earshinov
Copy link
Contributor Author

I'd rather add changes for the horizontal layout to this PR. I think I'll find time for it and #166 later today or tomorrow.

@earshinov
Copy link
Contributor Author

Done, please review.

@earshinov
Copy link
Contributor Author

Sorry, I was absent-minded and committed to a wrong branch. Reverted.

@madoar madoar merged commit f889758 into madoar:develop Oct 23, 2018
@earshinov earshinov deleted the refactor-styles branch December 24, 2018 14:43
earshinov added a commit to earshinov/angular-archwizard that referenced this pull request Mar 17, 2019
* master:
  - adjust version - add angular version 7 to the keywords
  - fix badges in README
  Update to angular 7 (madoar#194)
  Update the badges (madoar#193)
  Cleanup .travis.yml (madoar#191)
  Remove unnecesarry index.ts files (madoar#192)
  Apply the [stepId] field from the WizardSteps at ids in the navigation bar (madoar#186)
  Update the index.ts files (madoar#187)
  Removing barrel export and explicitly exporting each component in base index.ts.  Barrel exports of components cause @ViewChild(<className>) to give undefined in AOT builds (madoar#184)
  Declare Angular 7 compatibility in `package.json` (madoar#165)
  Refactor styles (madoar#161)
  Restore vertical nav bar layout, in particular label alignment (madoar#159)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants