-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from camptocamp/dataset-abstract
[Dataset page] Main block
- Loading branch information
Showing
34 changed files
with
1,122 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
describe('datasets', () => { | ||
describe('when not logged in', () => { | ||
beforeEach(() => cy.visit('/dataset/8698bf0b-fceb-4f0f-989b-111e7c4af0a4')) | ||
|
||
it('should display the favorite button disabled', () => { | ||
cy.get('mel-datahub-button-primary') | ||
.eq(0) | ||
.find('button') | ||
.as('favoriteButton') | ||
cy.get('@favoriteButton').should('be.disabled') | ||
cy.get('@favoriteButton').should('have.class', 'bg-primary-light') | ||
}) | ||
|
||
it('should scroll down when clicking on download button', () => { | ||
cy.get('mel-datahub-button-primary').eq(1).as('downloadButton') | ||
cy.get('@downloadButton').click() | ||
cy.get('@downloadButton').should(() => { | ||
const scrollPosition = Cypress.dom.getWindowByElement( | ||
cy.state('window') | ||
).scrollY | ||
expect(scrollPosition).to.be.greaterThan(0) | ||
}) | ||
}) | ||
|
||
it('should scroll down when clicking on api button', () => { | ||
cy.get('mel-datahub-button-primary').eq(2).as('apiButton') | ||
cy.get('@apiButton').click() | ||
cy.get('@apiButton').should(() => { | ||
const scrollPosition = Cypress.dom.getWindowByElement( | ||
cy.state('window') | ||
).scrollY | ||
expect(scrollPosition).to.be.greaterThan(0) | ||
}) | ||
}) | ||
|
||
it('should display the title', () => { | ||
cy.get('.mel-page-title').should('be.visible') | ||
cy.get('.mel-page-title').should('have.text', ' Alpenkonvention ') | ||
}) | ||
|
||
it('should display the abstract in collapsed mode applying gradient', () => { | ||
cy.get('mel-datahub-text-expand').should('be.visible') | ||
cy.get('mel-datahub-text-expand') | ||
.find('mel-datahub-button-primary') | ||
.should('have.text', ' En savoir plus ') | ||
cy.get('mel-datahub-text-expand') | ||
.find('mel-datahub-button-primary') | ||
.find('img') | ||
.should('have.attr', 'src', '/assets/icons/arrow.svg') | ||
cy.get('mel-datahub-text-expand') | ||
.find('.bg-gradient-to-b') | ||
.should('have.css', 'max-height', '72px') | ||
}) | ||
|
||
it('should display the abstract in expanded mode without gradient', () => { | ||
cy.get('mel-datahub-text-expand').should('be.visible') | ||
cy.get('mel-datahub-text-expand') | ||
.find('mel-datahub-button-primary') | ||
.click() | ||
cy.get('mel-datahub-text-expand') | ||
.find('mel-datahub-button-primary') | ||
.should('have.text', ' Reduire ') | ||
cy.get('mel-datahub-text-expand') | ||
.find('mel-datahub-button-primary') | ||
.find('img') | ||
.should('have.attr', 'src', '/assets/icons/arrow-up.svg') | ||
cy.get('mel-datahub-text-expand') | ||
.find('.bg-gradient-to-b') | ||
.should('not.exist') | ||
cy.get('mel-datahub-text-expand') | ||
.find('.ease-in') | ||
.should('have.css', 'max-height') | ||
.and('satisfy', (maxHeight) => parseInt(maxHeight, 10) > 110) | ||
}) | ||
}) | ||
describe('when logged in', () => { | ||
beforeEach(() => { | ||
cy.login() | ||
cy.clearFavorites() | ||
cy.visit('/dataset/8698bf0b-fceb-4f0f-989b-111e7c4af0a4') | ||
}) | ||
it('should toggle the favorite button', () => { | ||
cy.get('mel-datahub-button-primary').eq(0).as('favoriteButton') | ||
cy.get('@favoriteButton') | ||
.find('img') | ||
.should('have.attr', 'src', '/assets/icons/heart.svg') | ||
cy.get('@favoriteButton').click() | ||
cy.get('@favoriteButton') | ||
.find('img') | ||
.should('have.attr', 'src', '/assets/icons/heart-filled.svg') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
apps/datahub/src/app/common/button-primary/button-primary.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<button | ||
class="h-11 flex justify-center items-center gap-2 text-white text-[15px] font-extrabold leading-[18px] py-2 px-[18px] rounded border hover:bg-primary-dark" | ||
[class]="disabled ? 'bg-primary-light' : 'bg-primary'" | ||
[disabled]="disabled" | ||
> | ||
{{ label }} | ||
@if(src){ | ||
<img [src]="src" [alt]="placeholder" /> | ||
} | ||
</button> |
20 changes: 20 additions & 0 deletions
20
apps/datahub/src/app/common/button-primary/button-primary.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core' | ||
|
||
@Component({ | ||
selector: 'mel-datahub-button-primary', | ||
templateUrl: './button-primary.component.html', | ||
styles: ``, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ButtonPrimaryComponent { | ||
@Input() label: string | ||
@Input() set icon(fileName: string) { | ||
if (fileName) { | ||
this.src = `/assets/icons/${fileName}.svg` | ||
this.placeholder = fileName | ||
} | ||
} | ||
@Input() disabled = false | ||
src?: string | ||
placeholder?: string | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/datahub/src/app/common/favorites/favorite-heart/favorite-heart.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<mel-datahub-heart-toggle | ||
[toggled]="isFavorite$ | async" | ||
(newValue)="toggleFavorite($event)" | ||
[disabled]="loading || (isAnonymous$ | async)" | ||
></mel-datahub-heart-toggle> |
19 changes: 19 additions & 0 deletions
19
apps/datahub/src/app/common/favorites/favorite-heart/favorite-heart.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
ElementRef, | ||
ViewChild, | ||
} from '@angular/core' | ||
import { FavoriteStarComponent } from 'geonetwork-ui' | ||
import { HeartToggleComponent } from '../heart-toggle/heart-toggle.component' | ||
|
||
@Component({ | ||
selector: 'mel-datahub-favorite-heart', | ||
templateUrl: './favorite-heart.component.html', | ||
styles: ``, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class FavoriteHeartComponent extends FavoriteStarComponent { | ||
@ViewChild(HeartToggleComponent, { read: ElementRef }) | ||
override starToggleRef: ElementRef | ||
} |
6 changes: 6 additions & 0 deletions
6
apps/datahub/src/app/common/favorites/heart-toggle/heart-toggle.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<mel-datahub-button-primary | ||
[label]="'mel.dataset.favorite' | translate" | ||
[icon]="toggled ? 'heart-filled' : 'heart'" | ||
[disabled]="disabled" | ||
(click)="toggle($event)" | ||
></mel-datahub-button-primary> |
29 changes: 29 additions & 0 deletions
29
apps/datahub/src/app/common/favorites/heart-toggle/heart-toggle.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
EventEmitter, | ||
Input, | ||
Output, | ||
} from '@angular/core' | ||
import { propagateToDocumentOnly } from 'geonetwork-ui' | ||
|
||
@Component({ | ||
selector: 'mel-datahub-heart-toggle', | ||
templateUrl: './heart-toggle.component.html', | ||
styles: ``, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class HeartToggleComponent { | ||
@Input() toggled!: boolean | ||
@Input() disabled = false | ||
@Output() newValue = new EventEmitter<boolean>() | ||
|
||
toggle(event: Event) { | ||
if (!this.disabled) { | ||
this.toggled = !this.toggled | ||
this.newValue.emit(this.toggled) | ||
} | ||
propagateToDocumentOnly(event) | ||
event.preventDefault() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
apps/datahub/src/app/common/text-expand/text-expand.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div | ||
#container | ||
class="overflow-hidden transition-[max-height] duration-300 mb-8" | ||
[ngClass]=" | ||
isExpanded || !showToggleButton | ||
? 'ease-in' | ||
: 'ease-out bg-gradient-to-b from-black to-beige text-transparent bg-clip-text' | ||
" | ||
[style.maxHeight]="maxHeight" | ||
> | ||
<ng-content></ng-content> | ||
</div> | ||
@if(showToggleButton){ | ||
<mel-datahub-button-primary | ||
[label]="(isExpanded ? 'mel.dataset.less' : 'mel.dataset.more') | translate" | ||
[icon]="isExpanded ? 'arrow-up' : 'arrow'" | ||
(click)="toggleDisplay()" | ||
></mel-datahub-button-primary> | ||
} |
Oops, something went wrong.