-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 1526-doc-internet-header-import
- Loading branch information
Showing
46 changed files
with
1,212 additions
and
339 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,7 @@ | ||
--- | ||
'@swisspost/design-system-documentation': minor | ||
'@swisspost/design-system-components': minor | ||
'@swisspost/design-system-styles': patch | ||
--- | ||
|
||
Added a new post-tabs component. |
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: 'Mark stale issues' | ||
permissions: | ||
issues: write | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '9 22 * * *' # the job will run every day at 22:09 | ||
|
||
jobs: | ||
stale: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/stale@v8 | ||
with: | ||
days-before-stale: 60 | ||
days-before-close: -1 | ||
stale-issue-label: 'stale' | ||
exempt-milestones: 'next' | ||
operations-per-run: 100 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
describe('tabs', () => { | ||
describe('default', () => { | ||
beforeEach(() => { | ||
cy.getComponent('tabs'); | ||
cy.get('post-tab-header').as('headers'); | ||
}); | ||
|
||
it('should render', () => { | ||
cy.get('@tabs').should('exist'); | ||
}); | ||
|
||
it('should show three tab headers', () => { | ||
cy.get('@headers').should('have.length', 3); | ||
}); | ||
|
||
it('should only show the first tab header as active', () => { | ||
cy.get('@headers').each(($header, index) => { | ||
cy.wrap($header).find('.active').should(index === 0 ? 'exist' : 'not.exist'); | ||
}); | ||
}); | ||
|
||
it('should only show the tab panel associated with the first tab header', () => { | ||
cy.get('post-tab-panel:visible').as('panel'); | ||
cy.get('@panel').should('have.length', 1); | ||
cy.get('@headers').first().invoke('attr', 'panel').then(panel => { | ||
cy.get('@panel').invoke('attr', 'name').should('equal', panel); | ||
}); | ||
}); | ||
|
||
it('should activate a clicked tab header and deactivate the tab header that was previously activated', () => { | ||
cy.get('@headers').last().click(); | ||
|
||
cy.get('@headers').first().find('.active').should('not.exist'); | ||
cy.get('@headers').last().find('.active').should('exist'); | ||
}); | ||
|
||
it('should show the panel associated with a clicked tab header and hide the panel that was previously shown', () => { | ||
cy.get('@headers').last().click(); | ||
|
||
// wait for the fade out animation to complete | ||
cy.wait(200); | ||
|
||
cy.get('post-tab-panel:visible').as('panel'); | ||
cy.get('@panel').should('have.length', 1); | ||
cy.get('@headers').last().invoke('attr', 'panel').then(panel => { | ||
cy.get('@panel').invoke('attr', 'name').should('equal', panel); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('active panel', () => { | ||
beforeEach(() => { | ||
cy.getComponent('tabs', 'active-panel'); | ||
cy.get('post-tab-header').as('headers'); | ||
cy.get('post-tab-panel:visible').as('panel'); | ||
}); | ||
|
||
it('should only show the requested active tab panel', () => { | ||
cy.get('@panel').should('have.length', 1); | ||
cy.get('@tabs').invoke('attr', 'active-panel').then(activePanel => { | ||
cy.get('@panel').invoke('attr', 'name').should('equal', activePanel); | ||
}); | ||
}); | ||
|
||
it('should show as active only the tab header associated with the requested active tab panel', () => { | ||
cy.get('@tabs').invoke('attr', 'active-panel').then(activePanel => { | ||
cy.get('@headers').each($header => { | ||
cy.wrap($header).invoke('attr', 'panel').then(panel => { | ||
cy.wrap($header).find('.active').should(panel === activePanel ? 'exist' : 'not.exist'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('async', () => { | ||
beforeEach(() => { | ||
cy.getComponent('tabs', 'async'); | ||
cy.get('post-tab-header').as('headers'); | ||
}); | ||
|
||
it('should add a tab header', () => { | ||
cy.get('#add-tab').click(); | ||
cy.get('@headers').should('have.length', 4); | ||
}); | ||
|
||
it('should still show the tab panel associated with the first tab header after adding new tab', () => { | ||
cy.get('#add-tab').click(); | ||
|
||
cy.get('post-tab-panel:visible').as('panel'); | ||
cy.get('@panel').should('have.length', 1); | ||
cy.get('@headers').first().invoke('attr', 'panel').then(panel => { | ||
cy.get('@panel').invoke('attr', 'name').should('equal', panel); | ||
}); | ||
}); | ||
|
||
it('should activate the newly added tab header after clicking on it', () => { | ||
cy.get('#add-tab').click(); | ||
|
||
cy.get('post-tab-header').as('headers'); | ||
cy.get('@headers').last().click(); | ||
|
||
cy.get('@headers').first().find('.active').should('not.exist'); | ||
cy.get('@headers').last().find('.active').should('exist'); | ||
}); | ||
|
||
it('should display the tab panel associated with the newly added tab after clicking on it', () => { | ||
cy.get('#add-tab').click(); | ||
|
||
cy.get('post-tab-header').last().as('new-panel'); | ||
cy.get('@new-panel').click(); | ||
|
||
// wait for the fade out animation to complete | ||
cy.wait(200); | ||
|
||
cy.get('post-tab-panel:visible').as('panel'); | ||
cy.get('@panel').should('have.length', 1); | ||
cy.get('@new-panel').invoke('attr', 'panel').then(panel => { | ||
cy.get('@panel').invoke('attr', 'name').should('equal', panel); | ||
}); | ||
}); | ||
|
||
it('should remove a tab header', () => { | ||
cy.get('.tab-title.active').then(() => { | ||
cy.get('#remove-active-tab').click(); | ||
cy.get('@headers').should('have.length', 2); | ||
}); | ||
}); | ||
|
||
it('should still show an active tab header after removing the active tab', () => { | ||
cy.get('.tab-title.active').then(() => { | ||
cy.get('#remove-active-tab').click(); | ||
cy.get('.tab-title.active').should('exist'); | ||
}); | ||
}); | ||
|
||
it('should still show a tab panel after removing the active tab', () => { | ||
cy.get('.tab-title.active').then(() => { | ||
cy.get('#remove-active-tab').click(); | ||
cy.get('post-tab-panel:visible').should('exist'); | ||
}); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const fadeDuration = 200; | ||
const fadedOutKeyFrame = {opacity: '0'}; | ||
const fadedInKeyFrame = {opacity: '1'}; | ||
|
||
export const fadeIn = (el: Element): Animation => el.animate( | ||
[ fadedOutKeyFrame, fadedInKeyFrame ], | ||
{ duration: fadeDuration } | ||
); | ||
|
||
export const fadeOut = (el: Element): Animation => el.animate( | ||
[ fadedInKeyFrame, fadedOutKeyFrame ], | ||
{ duration: fadeDuration } | ||
); |
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 @@ | ||
export * from './fade'; |
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
5 changes: 5 additions & 0 deletions
5
packages/components/src/components/post-tab-header/post-tab-header.scss
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 @@ | ||
@use '@swisspost/design-system-styles/components/tabs/tab-title'; | ||
|
||
:host { | ||
display: block; | ||
} |
Oops, something went wrong.