-
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): action-bar Component #495
feat(stark-ui): action-bar Component #495
Conversation
describe("ActionBarComponent", () => { | ||
let fixture: ComponentFixture<StarkActionBarComponent>; | ||
let component: StarkActionBarComponent; | ||
const buttonToogleSelector: string = ".extend-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.
Just a small typo buttonToogleSelector -> buttonToggleSelector 😏
public isExtended: boolean = false; | ||
|
||
/** | ||
* toogle the extended action in full mode |
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 typo toogle => toggle 😉
showcase/package.json
Outdated
@@ -121,8 +121,8 @@ | |||
"@angular/platform-browser-dynamic": "6.0.7", | |||
"@angular/platform-server": "6.0.7", | |||
"@angular/router": "6.0.7", | |||
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.3-6796ad0.tgz", | |||
"@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.0.0-alpha.3-6796ad0.tgz", | |||
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.3-00a78ab.tgz", |
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.
Don't include the package.json files in the commit if only the build number of a stark package has changed.
showcase/src/app/router.config.ts
Outdated
router.plugin(Visualizer); | ||
//Uncomment if needed | ||
/*router.trace.enable(Category.TRANSITION); | ||
router.plugin(Visualizer);*/ |
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.
It is better to put these kind of changes in a separate PR.
Now it is hidden inside this PR and harder to find in the future.
@@ -10,7 +10,7 @@ import { STARK_LOGGING_SERVICE, StarkErrorImpl, StarkLoggingService } from "@nat | |||
providers: [FileService] | |||
}) | |||
export class ExampleViewerComponent implements OnInit { | |||
@Input() public extensions: string[] = ["HTML", "TS", "CSS"]; |
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 is the CSS removed?
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.
For every component, we have now 2 SCSS files, one for the colors (them) and one for the rest of the styles. It is up to the end user if he wants to include those files or not, so they have more flexibility.
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 I think that this has nothing to do with the fact that there are 2 SCSS files for each component. This remark is about the CSS tab of the example viewer. Aren't we supposed to demo all what is needed to use a certain component? That means the TS code, HTML and CSS
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 for the action bar component for instance, I don't need any specific CSS
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.
True, but this is the example-viewer component so technically by default a demoed component should have HTML and CSS. In your case, the usage you do for the Action Bar demo you don't need it but that is just a specific use case so you just give a different value in the "extensions" input.
starter/package.json
Outdated
@@ -124,8 +124,8 @@ | |||
"@angular/platform-browser-dynamic": "6.0.7", | |||
"@angular/platform-server": "6.0.7", | |||
"@angular/router": "6.0.7", | |||
"@nationalbankbelgium/stark-core": "file:../dist/packages-dist/stark-core/nationalbankbelgium-stark-core-10.0.0-alpha.3-6796ad0.tgz", | |||
"@nationalbankbelgium/stark-ui": "file:../dist/packages-dist/stark-ui/nationalbankbelgium-stark-ui-10.0.0-alpha.3-6796ad0.tgz", |
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:
Don't include the package.json files in the commit if only the build number of a stark package has changed.
a61084c
to
ceff69e
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 the remarks below, I think the translation support is missing. Could you please add it?
You can have a look in the old Stark how this is implemented.
@@ -0,0 +1,8 @@ | |||
$tablet-query: "(min-width: 600px)"; |
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 is this file called "old-media-queries"? Are we going to create new media queries? If not, then I think we should simply call it "media-queries"
{ provide: STARK_LOGGING_SERVICE, useValue: new MockStarkLoggingService() }, | ||
{ provide: STARK_ROUTING_SERVICE, useClass: MockStarkRoutingService } | ||
], | ||
schemas: [NO_ERRORS_SCHEMA] // tells the Angular compiler to ignore unrecognized elements and attributes |
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 specify in the comment which elements we don't want to include?
label: "Validate", | ||
icon: "check", | ||
actionCall: ($event: Event, data: any): void => { | ||
console.log($event); |
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.
Let's avoid adding console.log
in the tests otherwise they are cluttered with lots of logs that makes it hard to read the test logs. You can use an spy or a noop.
Moreover, if you use Spies then in your tests you can remove the spyOn(...)
calls since they will already be spies ;)
label: "Save", | ||
icon: "content-save", | ||
actionCall: ($event: Event, data: any): void => { | ||
console.log($event); |
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... let's avoid console.log
@@ -0,0 +1,98 @@ | |||
"use strict"; |
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 use strict
directive is not needed anymore, this is added automatically by TSC when compiling the code.
component.mode = 'full'; | ||
fixture.detectChanges(); | ||
const buttonToggleExtend: HTMLElement = fixture.nativeElement.querySelector(buttonToggleSelector); | ||
expect(buttonToggleExtend).toBeTruthy(); |
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.
Perhaps the matcher .toBeDefined()
is more suitable and accurate in this case
component.mode = 'compact'; | ||
fixture.detectChanges(); | ||
const buttonToggleExtend: HTMLElement = fixture.nativeElement.querySelector(buttonToggleSelector); | ||
expect(buttonToggleExtend).toBeFalsy(); |
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.
Perhaps the matcher .toBeUndefined()
is more accurate in this case
describe("@Input() actionBarId", () => { | ||
it("should have set the id of the action bar", () => { | ||
const actionBar: HTMLElement = fixture.nativeElement.querySelector("#"+component.actionBarId); | ||
component.actionBarId = "action-bar-id"; |
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.
These 2 lines are a bit weird and confusing. The first line sets already the id (which is unknown by the way at this point) and then the second line sets the id. Finally in the last line of this test the id is checked.
You can improve this test by one of these 2 options:
- changing the order of these 2 lines and get the HTML element just after calling
fixture.detectChanges()
- add an expectation just after the first line to expect the HTMLElement to be undefined (because the querySelector will not find the element) and then add another expectation before the last line to expect the HTMLElement to be defined.
}); | ||
|
||
describe("@Input() actionBarConfig", () => { | ||
it("should call the defined action when disabled", () => { |
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.
"should NOT call the defined action when disabled" ;)
|
||
it("should display", () => { | ||
const actionBar: HTMLElement = fixture.nativeElement.querySelector(".open-alt-actions"); | ||
expect(actionBar).toBeTruthy(); |
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.
Perhaps the matcher .toBeDefined() is more suitable and accurate in this case
ceff69e
to
bb9d6ba
Compare
I added a ticket about translation: |
c84a611
to
ce3fb85
Compare
@@ -12,6 +12,21 @@ export const translationsEn: object = { | |||
SORTING: { | |||
ASC: "Ascending", | |||
DESC: "Descending" | |||
}, |
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'll have to think about the best place to put those translations.
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.
Indeed
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.
Issue created: #511
export class StarkActionBarComponent { | ||
@Input() public actionBarId: string = ""; | ||
@Input() public actionBarConfig: StarkActionBarConfig; | ||
@Input() public actionBarScope: any; |
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 JSDoc documentation for those bindings ?
5fc32cd
to
97375e3
Compare
ISSUES CLOSED: NationalBankBelgium#481
97375e3
to
d1dd733
Compare
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?
Issue Number: #481
What is the new behavior?
Action Bar - implement component/module
New stark-action-bar component integrated in stark-ui package.