-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat(stark-ui): implement the button's theme #517
feat(stark-ui): implement the button's theme #517
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small remark
@@ -4,27 +4,27 @@ | |||
<div *ngFor="let action of actionBarConfig.actions; trackBy: trackAction" [id]="actionBarId + '-' + action.id" | |||
(click)="onClick(action, $event)" class="stark-action-bar--action"> | |||
<ng-container *ngIf="action.isVisible !== false"> | |||
<button [ngClass]="action.className" [matTooltip]="action.labelSwitchFunction ? action.labelActivated : action.label" [disabled]="!action.isEnabled" mat-icon-button> | |||
<mat-icon starkSvgViewBox [svgIcon]="action.iconSwitchFunction ? action.iconActivated : action.icon"></mat-icon> | |||
<button color="primary" [ngClass]="action.className" [matTooltip]="action.labelSwitchFunction ? action.labelActivated : action.label" [disabled]="!action.isEnabled" mat-icon-button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why force setting primary color?
Maybe should we provide a new property in the interface to set a color? Which is an optional string and, if it is not set, we can set primary by default. What do you think about this? 😊
</button> | ||
<label class="action-label" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended" translate>{{ action.label }}</label> | ||
</ng-container> | ||
</div> | ||
</div> | ||
|
||
<div *ngIf="mode === 'full' || alternativeActions" class="alt-actions"> | ||
<button class="extend-action-bar" mat-icon-button *ngIf="mode === 'full'" (click)="toggleExtendedActionBar()"> | ||
<mat-icon starkSvgViewBox svgIcon="dots-horizontal"></mat-icon> | ||
<button class="extend-action-bar" color="primary" mat-icon-button *ngIf="mode === 'full'" (click)="toggleExtendedActionBar()"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why force setting primary color?
Maybe should we provide a new property in the interface to set a color? Which is an optional string and, if it is not set, we can set primary by default. What do you think about this? 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a feature coming from Angular Material, nothing added on our side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what @SuperITMan is talking about is the fact that we "enforce" the primary color on the action buttons. I'm also not sure if we should enforce such color, what if the developer wants a different color? How can he change the color without affecting the primary color of other buttons?
As I mentioned the other day, I think the safest approach will be not to use the Angular Material color
directive in the Stark packages but only in the client apps like the showcase and the starter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want a closest integration with Angular Material, I think we should keep the directive that they provide. Now I have extend the 3 default colors to add the one we were using before. Then the end user could use Angular Material button with our custom colors, I think that provide the most flexibility.
Imagine if we give up on the color attr and they write this:
<button color="primary" class="stark-alert" mat-raised-button>Primary or Alert?</button>
Then this button have 2 styles defined, so one should override the other
With this notation:
<button color="alert" mat-raised-button>Alert</button>
There is no confusion and we stay inline with Angular Material
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we really want to override the color we can do it through a mixin that I have created, which use actually the angular material mixin for buttons.
The code for end user will be:
.my-custom-button {
@include stark-button-color(#fff, #222); //(color, text-color)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@catlabs What do you think if we add a property in StarkAction ?
Now, we have something like this:
export interface StarkAction {
// ...
isEnabled: boolean;
label: string;
// ...
}
But we could have something else like:
export interface StarkAction {
// ...
isEnabled: boolean;
label: string;
buttonColor: string; // <-------
// ...
}
Then, in the component, we could have this:
<button color="action.buttonColor ? action.buttonColor : 'alert'" mat-raised-button>Alert</button>
What do you think about this ?
We continue to use Angular Material as it should be but we give more abilities to choose the color of the button.
I don't think we should use @mixin
function to change the color of the button...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well yeah that's an idea, we talked about it with @christophercr actually, I ll do that and repush the change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, but then we should think about what are the possible colors we would accept; any? just primary, accent and alert?
If we accept any, in case a new color is given, then it means that the developer should also "create" that color with the Angular Material mixins which at the end willl be the same effort that the one @catlabs mentioned above in order to override the color.
So, I don't know if this approach of having a buttonColor in the interface will make things easier or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right Christopher 😊
We could do so
{
//...
buttonColor: "primary" | "alert" | "accent";
}
What do you think about this?
And if they want more flexibility, they will have to play with @mixin
function 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well yeah that's the idea, they can either enter one of the seven colors we provide (primary, warn,accent,success,alert,alt,neutral,white) or a custom one, then they will have to play with the mixin
@@ -31,7 +42,7 @@ | |||
</a> | |||
</mat-nav-list> | |||
</mat-sidenav> | |||
<mat-sidenav-content class="px4 py2"> | |||
<mat-sidenav-content class="px4 py2"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these classes for? Where are they defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed 2 weeks ago, those classes are coming from basscss. It provides some global classes (padding in this case) which is convenient to avoid having extra css on our side.
Regarding sidenav, we will implement it soon, so this code is going to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
@@ -154,7 +154,11 @@ export const metaReducers: MetaReducer<State>[] = ENV !== "production" ? [logger | |||
StarkRoutingModule.forRoot(), | |||
SharedModule, | |||
DemoModule, | |||
StarkAppLogoModule | |||
StarkAppLogoModule, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All these modules (except the StarkAppLogoModule) should not be imported here, they are now imported in the Demo module ;)
public constructor(@Inject(STARK_LOGGING_SERVICE) public logger: StarkLoggingService) {} | ||
|
||
public ngOnInit(): void { | ||
console.log("On Init"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace the console.log by the StarkLoggingService since you already injected it ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oups my mistake :-)
showcase/src/app/demo/index.ts
Outdated
@@ -2,3 +2,6 @@ export * from "./action-bar"; | |||
export * from "./example-viewer"; | |||
export * from "./table"; | |||
export * from "./demo.module"; | |||
export * from "./action-bar/action-bar.component"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This re-export is not needed, This is already done in this barrel: demo/action-bar/index.ts
showcase/src/app/demo/index.ts
Outdated
@@ -2,3 +2,6 @@ export * from "./action-bar"; | |||
export * from "./example-viewer"; | |||
export * from "./table"; | |||
export * from "./demo.module"; | |||
export * from "./action-bar/action-bar.component"; | |||
export * from "./button/button.component"; | |||
export * from "./example-viewer/example-viewer.component"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This re-export is not needed. This is already done in this barrel: demo/example-viewer/index.ts
showcase/src/app/demo/index.ts
Outdated
@@ -2,3 +2,6 @@ export * from "./action-bar"; | |||
export * from "./example-viewer"; | |||
export * from "./table"; | |||
export * from "./demo.module"; | |||
export * from "./action-bar/action-bar.component"; | |||
export * from "./button/button.component"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This barrel should just re-export everything from ./action-bar
. There, inside the "action-bar" folder there should be a barrel index.ts
which re-exports all the .ts
files except the spec.ts
.
See how it is done in the other folders ;)
&.stark-action-bar-full { | ||
} | ||
|
||
@media #{$mobile-only-query} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous code the media query was "tablet-query" and now is "mobile-only-query"... Is this an intended change? Why? What about tablet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is intended, now with the button theme, we can specify which color the button should have with the color attribute. It is only an small device that we need to use custom colors, so it make more sense to have SCSS exception on small device
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, Ok.
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core"; | ||
|
||
@Component({ | ||
selector: "showcase-demo-button", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure these lines are correctly formatted (indentation) ... could you please run the "prettier-check" command to auto format all files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I already did it, so I guess the indentation is correct. Seems ok in my editor...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
Allright, I repushed the changes. @christophercr @SuperITMan can you recheck? |
Changes pushed. @christophercr @SuperITMan can you recheck? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small remarks
</ng-container> | ||
</div> | ||
</div> | ||
|
||
<div *ngIf="mode === 'full' || alternativeActions" class="alt-actions"> | ||
<button class="extend-action-bar" mat-icon-button *ngIf="mode === 'full'" (click)="toggleExtendedActionBar()"> | ||
<mat-icon starkSvgViewBox svgIcon="dots-horizontal"></mat-icon> | ||
<button class="extend-action-bar" color="primary" mat-icon-button *ngIf="mode === 'full'" (click)="toggleExtendedActionBar()"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this "color" should also be set via the buttonColor right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well this button are not set via any Input property, it is the generic extend button. I don't think we should add an Input for this, it will make the api more complex.
</button> | ||
<button class="open-alt-actions" mat-icon-button *ngIf="alternativeActions" [matMenuTriggerFor]="menu"> | ||
<mat-icon starkSvgViewBox svgIcon="dots-vertical"></mat-icon> | ||
<button class="open-alt-actions" color="primary" mat-icon-button *ngIf="alternativeActions" [matMenuTriggerFor]="menu"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, I think this "color" should also be set via the buttonColor right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark than above
/** | ||
* Color of the button (optional) | ||
*/ | ||
buttonColor?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "(optional)" string in the comment is not needed since it is already implicit in the Typescript code. Then, I think the type of this property should be more specific as @SuperITMan suggested, so it would be something like this:
/**
* Color of the action button. Default: "primary".
*/
buttonColor?: "primary" | "alert" | "accent" | "anyOtherStarkColor" | string;
In this case, the "string" type is still needed so the developer can give any other color.
Changes pushed. @christophercr @SuperITMan can you recheck? |
ccf1384
to
240f6f0
Compare
@catlabs could you please rebase your PR? 😊 |
Rebase pushed |
ISSUES CLOSED: #476
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Implementation of the button's theme
Issue Number: #476
What is the new behavior?
The old style have been merged and some new ones have been added (white buttons)
The html will be a bit different but it follows the angular material way of declaring a button