-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,77 @@ | ||
@mixin stark-button-color($color) { | ||
color: $color; | ||
.mat-button-focus-overlay { | ||
background-color: rgba($color: $color, $alpha: 0.12); | ||
@mixin stark-button-color($color, $contrast) { | ||
&.mat-button, | ||
&.mat-icon-button, | ||
&.mat-stroked-button { | ||
color: $color; | ||
.mat-button-focus-overlay { | ||
background-color: rgba($color: $color, $alpha: 0.12); | ||
} | ||
.mat-ripple-element { | ||
background-color: rgba($color: $color, $alpha: 0.1); | ||
} | ||
} | ||
.mat-ripple-element { | ||
background-color: rgba($color: $color, $alpha: 0.1); | ||
|
||
&.mat-flat-button, | ||
&.mat-raised-button, | ||
&.mat-fab, | ||
&.mat-mini-fab { | ||
color: $contrast; | ||
background-color: $color; | ||
.mat-ripple-element { | ||
background-color: rgba($color: $contrast, $alpha: 0.1); | ||
} | ||
} | ||
|
||
.mat-icon-button { | ||
.mat-ripple-element { | ||
background-color: rgba($color: $color, $alpha: 0.2); | ||
} | ||
} | ||
} | ||
|
||
@if variable-exists(stark-button-theme) { | ||
$button-theme: map-merge($button-theme, $stark-button-theme); | ||
} | ||
|
||
button[mat-raised-button], | ||
a[mat-raised-button] { | ||
border-radius: map-get($button-theme, border-radius); | ||
/*padding: map-get($button-theme, padding); | ||
line-height: map-get($button-theme, line-height);*/ | ||
.mat-success { | ||
@include stark-button-color(map-get(map-get($button-theme, success), color), map-get(map-get($button-theme, success), contrast)); | ||
} | ||
|
||
.mat-alert { | ||
@include stark-button-color(map-get(map-get($button-theme, alert), color), map-get(map-get($button-theme, alert), contrast)); | ||
} | ||
|
||
.mat-alt { | ||
@include stark-button-color(map-get(map-get($button-theme, alt), color), map-get(map-get($button-theme, alt), contrast)); | ||
} | ||
|
||
.mat-neutral { | ||
@include stark-button-color(map-get(map-get($button-theme, neutral), color), map-get(map-get($button-theme, neutral), contrast)); | ||
} | ||
|
||
button[mat-raised-button].stark-small-button, | ||
a[mat-raised-button].stark-small-button { | ||
font-size: map-get($button-theme, small-font-size); | ||
font-weight: map-get($button-theme, small-font-weight); | ||
line-height: map-get($button-theme, small-line-height); | ||
min-width: map-get($button-theme, small-min-width); | ||
padding: map-get($button-theme, small-padding); | ||
.mat-white { | ||
@include stark-button-color(#fff, $dark-primary-text); | ||
} | ||
|
||
.mat-icon-button .mat-icon, | ||
.mat-mini-fab .mat-icon { | ||
&.stark-small-icon { | ||
line-height: 18px; | ||
height: 18px; | ||
width: 18px; | ||
svg { | ||
height: 18px; | ||
width: 18px; | ||
} | ||
} | ||
} | ||
|
||
button[mat-raised-button].stark-large-button, | ||
a[mat-raised-button].stark-large-button { | ||
font-size: map-get($button-theme, large-font-size); | ||
font-weight: map-get($button-theme, large-font-weight); | ||
line-height: map-get($button-theme, large-line-height); | ||
min-width: map-get($button-theme, large-min-width); | ||
padding: map-get($button-theme, large-padding); | ||
.mat-button, | ||
.mat-icon-button, | ||
.mat-stroked-button, | ||
.mat-flat-button, | ||
.mat-raised-button, | ||
.mat-fab, | ||
.mat-mini-fab { | ||
text-transform: uppercase; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]="action.buttonColor ? action.buttonColor:'primary'" [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" class="stark-small-icon"></mat-icon> | ||
</button> | ||
<label class="action-label" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended" translate>{{ action.label }}</label> | ||
<label [class]="'action-label '+ (action.buttonColor?action.buttonColor:'primary')" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended"> <span translate>{{ action.label }}</span></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 commentThe 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 commentThe 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. |
||
<mat-icon starkSvgViewBox svgIcon="dots-horizontal" class="stark-small-icon"></mat-icon> | ||
</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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Same remark than above |
||
<mat-icon starkSvgViewBox svgIcon="dots-vertical" class="stark-small-icon"></mat-icon> | ||
</button> | ||
<mat-menu #menu="matMenu" xPosition="before"> | ||
<div *ngFor="let action of alternativeActions; trackBy: trackAction" mat-menu-item [id]="actionBarId + '-alt-' + action.id" [disabled]="!action.isEnabled" | ||
(click)="onClick(action, $event)"> | ||
<ng-container *ngIf="action.isVisible !== false"> | ||
<div [ngClass]="action.className"> | ||
<mat-icon starkSvgViewBox [svgIcon]="action.icon"></mat-icon> | ||
<mat-icon starkSvgViewBox [svgIcon]="action.icon" class="stark-small-icon"></mat-icon> | ||
<span translate>{{ action.label }}</span> | ||
</div> | ||
</ng-container> | ||
|
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.
https://material.angular.io/components/button/examples
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:
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:
But we could have something else like:
Then, in the component, we could have this:
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
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