-
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): add stark-action-bar into stark-table #525
feat(stark-ui): add stark-action-bar into stark-table #525
Conversation
c38198a
to
196a412
Compare
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.
Apart from integrating the action bar component in the row action bar, we should also integrate it in the table action bar.
eeb1f68
to
44b2e2b
Compare
Now we also have the main action bar on the table. |
|
||
.actions { | ||
align-items: center; | ||
display: flex; | ||
justify-content: flex-end; | ||
&.actions-alt{ |
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.
Could you please add a space before the bracket ?
(Prettier should do it automatically normally 😕)
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.
Strange cause I ran prettier-check before pushing... Maybe we should have a ticket about it?
.stark-table { | ||
.header { | ||
align-items: center; | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 20px; | ||
|
||
.transcluded{ |
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.
Could you please add a space before the bracket ?
(Prettier should do it automatically normally 😕)
@@ -4,10 +4,10 @@ | |||
<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 [color]="action.buttonColor ? action.buttonColor:'primary'" [ngClass]="action.className" [matTooltip]="action.labelSwitchFunction ? action.labelActivated : action.label" [disabled]="!action.isEnabled" mat-icon-button> | |||
<button [color]="action.buttonColor ? action.buttonColor:buttonColor" [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.
Could you please add a space before and after the :
for having (action.buttonColor ? action.buttonColor : buttonColor)
?
(Prettier should do it automatically normally 😕)
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, in fact Prettier doesn't support HTML yet 😩
https://prettier.io/docs/en/language-support.html
prettier/prettier#1882
<mat-icon starkSvgViewBox [svgIcon]="action.iconSwitchFunction ? action.iconActivated : action.icon" class="stark-small-icon"></mat-icon> | ||
</button> | ||
<label [class]="'action-label '+ (action.buttonColor?action.buttonColor:'primary')" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended"> <span translate>{{ action.label }}</span></label> | ||
<label [class]="'action-label '+ (action.buttonColor ? action.buttonColor:buttonColor)" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended"> <span translate>{{ action.label }}</span></label> |
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.
Could you please add a space before and after the :
for having (action.buttonColor ? action.buttonColor : buttonColor)
?
(Prettier should do it automatically normally 😕)
<div class="actions"> | ||
<button *ngIf="isMultiSortEnabled" (click)="openMultiSortDialog()" mat-icon-button> | ||
<mat-icon svgIcon="sort" matTooltip="Multi-Column Sorting"></mat-icon> | ||
<div class="header mat-el"> |
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 is mat-el
class ?
/** | ||
* Type of StarkAction objects | ||
*/ | ||
@Input() public customTableActionsType: 'regular' | 'alt' | string = 'regular'; |
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.
Could you please replace '
by "
?
(Prettier should do it automatically normally 😕)
44b2e2b
to
91a895b
Compare
<ng-content select="header"></ng-content> | ||
</div> | ||
<div class="actions" [ngClass]="{'actions-alt': customTableActionsType === 'alt'}"> | ||
<stark-action-bar [actionBarConfig]="customTableActionsType === 'regular' ?{actions: customTableActions}:{}" [alternativeActions]="customTableActionsType === 'alt' ?customTableActions:null" buttonColor="alt" mode="compact"></stark-action-bar> |
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.
We should avoid adding to much logic in the templates and do all manipulations in the component class instead.
Moreover, in this particular case we are creating new objects which should implement a certain interface, but this is easy to overlook and we might forget to change this whenever we change the interface. This will be much easier to detect in the component class.
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 as below:
Well yeah we could have a more flexible approach but this one is the one that cost the less effort regarding the old API.
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 understand the reason of this code, but the point here is that this code should be in the component class instead of the template. It is safer there and more difficult to overlook potential issues related to the interface that should be implemented.
<span>{{ context.displayedValue }}</span> | ||
</ng-template> | ||
</stark-table-column> | ||
<mat-card-content> |
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 do we use a <mat-card-content>
here? I would suggest to use all the minimal MatCard elements or none of them but not just one of them which might cause some weird behavior if used alone.
Maybe a simple <div>
with some styling will be better.
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.
Doesn't matter as we will implement the example-viewer #514
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, so I think we should just remove the <mat-card-content>
and keep the code clean (so we don't need to import the MatCardModule).
@@ -24,6 +27,7 @@ import { StarkTableMultisortDialogComponent } from "./components/dialogs/multiso | |||
BrowserAnimationsModule, | |||
FormsModule, | |||
MatButtonModule, | |||
MatCardModule, |
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 replace the <mat-card-content>
in the template, then this will not be needed anymore
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.
Doesn't matter as we will implement the example-viewer #514
/** | ||
* Type of StarkAction objects | ||
*/ | ||
@Input() public customTableActionsType: "regular" | "alt" | string = "regular"; |
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 there is the "string" type? Normally, there are only 2 possible values: "regular" and "alt" right?
And for the type "alt", it stands for "alternative" right? Then I think we should use the full name so it is clear the intention. The more descriptive our API is the better.
templateUrl: "./table.component.html" | ||
styleUrls: ["./table.component.scss"], | ||
templateUrl: "./table.component.html", | ||
encapsulation: ViewEncapsulation.None |
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.
Can you please add a comment indicating why you use ViewEncapsulation.None
?
showcase/src/styles/_theme.scss
Outdated
@@ -5,7 +5,8 @@ | |||
@import "~@nationalbankbelgium/stark-ui/assets/themes/button-theme"; | |||
@import "~@nationalbankbelgium/stark-ui/assets/themes/card-theme"; | |||
@import "~@nationalbankbelgium/stark-ui/assets/themes/menu-theme"; | |||
@import "~@nationalbankbelgium/stark-ui/assets/themes/table-theme"; | |||
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/table.component"; | |||
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/dialogs/multisort.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.
Why these 2 files are imported here? Normally only the "theme" files should be imported here and not the "component" 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.
Well I don't agree, all the other theme files are imported here (see action bar and slider) and I think it is the right place to put them. Here the enduser can decide either he wants to import them 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.
Ah indeed, I overlooked that ;)
@@ -3,6 +3,3 @@ | |||
@import "~basscss/css/basscss.css"; | |||
@import "~normalize.css/normalize.css"; | |||
@import "~prismjs/themes/prism-okaidia.css"; | |||
|
|||
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/table.component"; | |||
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/dialogs/multisort.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.
I think these should not be removed from here, see my previous comment
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 as above
<div class="transcluded"> | ||
<ng-content select="header"></ng-content> | ||
</div> | ||
<div class="actions" [ngClass]="{'actions-alt': customTableActionsType === 'alt'}"> |
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 wondering if this approach (defining the "customTableActionsType" in the table) is flexible enough.
Wouldn't it be more flexible to define it in the Action instead of in the table? Then the developer can decide for every action if they should be "alternative" 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.
Well yeah we could have a more flexible approach but this one is the one that cost the less effort regarding the old API. The idea behind is to either have a full bar or an alt action bar. It won't make sense for now to use both of them in the main table action bar.
For now it is a matter of showing to the end user what we could do and how the interface could be improved, I think we should first propose this option and then see what we do according to their feedbacks.
f972578
to
6612d19
Compare
Re-pushed |
6612d19
to
0adbc00
Compare
@catlabs could you rebase your PR ? 😊 |
0adbc00
to
d3a2c6d
Compare
Yep it is rebased :-) |
ISSUES CLOSED: #512
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?
Add the stark-action-bar to the stark-table
Issue Number: #512