-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(small-stage): introduce component (#71)
- Loading branch information
1 parent
8bb5eeb
commit b0035b6
Showing
23 changed files
with
451 additions
and
1 deletion.
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
Empty file.
17 changes: 17 additions & 0 deletions
17
...ntation/examples/small-stage-content-variation/small-stage-content-variation-example.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,17 @@ | ||
<div class="nx-margin-bottom-m"> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
> | ||
<p nxHeadline="subsection-xsmall" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="section" class="nx-margin-0">Headline text</h2> | ||
</nx-small-stage> | ||
</div> | ||
|
||
<div> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
> | ||
<p nxHeadline="subsection-xsmall" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="section" class="nx-margin-0">Headline text with some extra words that will eventually break into multiple lines</h2> | ||
</nx-small-stage> | ||
</div> |
10 changes: 10 additions & 0 deletions
10
...mentation/examples/small-stage-content-variation/small-stage-content-variation-example.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,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* @title Small stage content variation example | ||
*/ | ||
@Component({ | ||
templateUrl: './small-stage-content-variation-example.html' | ||
}) | ||
export class SmallStageContentVariationExampleComponent { | ||
} |
Empty file.
17 changes: 17 additions & 0 deletions
17
...cts/ng-aquila/documentation/examples/small-stage-default/small-stage-default-example.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,17 @@ | ||
<div class="nx-margin-bottom-m"> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
> | ||
<p nxCopytext="large" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="subsection-large" class="nx-margin-0">Headline text</h2> | ||
</nx-small-stage> | ||
</div> | ||
|
||
<div> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
> | ||
<p nxCopytext="large" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="subsection-large" class="nx-margin-0">Headline text with some extra words that will eventually break into multiple lines</h2> | ||
</nx-small-stage> | ||
</div> |
10 changes: 10 additions & 0 deletions
10
projects/ng-aquila/documentation/examples/small-stage-default/small-stage-default-example.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,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* @title Small stage default example | ||
*/ | ||
@Component({ | ||
templateUrl: './small-stage-default-example.html' | ||
}) | ||
export class SmallStageDefaultExampleComponent { | ||
} |
Empty file.
19 changes: 19 additions & 0 deletions
19
...ila/documentation/examples/small-stage-image-offset/small-stage-image-offset-example.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 class="nx-margin-bottom-m"> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
offsetEnd | ||
> | ||
<p nxCopytext="large" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="subsection-large" class="nx-margin-0">Headline text</h2> | ||
</nx-small-stage> | ||
</div> | ||
|
||
<div> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
offsetEnd | ||
> | ||
<p nxCopytext="large" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="subsection-large" class="nx-margin-0">Headline text with some extra words that will eventually break into multiple lines</h2> | ||
</nx-small-stage> | ||
</div> |
10 changes: 10 additions & 0 deletions
10
...quila/documentation/examples/small-stage-image-offset/small-stage-image-offset-example.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,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* @title Small stage image offset example | ||
*/ | ||
@Component({ | ||
templateUrl: './small-stage-image-offset-example.html' | ||
}) | ||
export class SmallStageImageOffsetExampleComponent { | ||
} |
Empty file.
19 changes: 19 additions & 0 deletions
19
...quila/documentation/examples/small-stage-text-narrow/small-stage-text-narrow-example.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 class="nx-margin-bottom-m"> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
contentNarrow | ||
> | ||
<p nxCopytext="large" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="subsection-large" class="nx-margin-0">Headline text</h2> | ||
</nx-small-stage> | ||
</div> | ||
|
||
<div> | ||
<nx-small-stage | ||
imageUrl="assets/images/small-stage-illustration.png" | ||
contentNarrow | ||
> | ||
<p nxCopytext="large" class="nx-margin-bottom-xs">Topline text</p> | ||
<h2 nxHeadline="subsection-large" class="nx-margin-0">Headline text with some extra words that will eventually break into multiple lines</h2> | ||
</nx-small-stage> | ||
</div> |
10 changes: 10 additions & 0 deletions
10
...-aquila/documentation/examples/small-stage-text-narrow/small-stage-text-narrow-example.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,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* @title Small stage narrow content example | ||
*/ | ||
@Component({ | ||
templateUrl: './small-stage-text-narrow-example.html' | ||
}) | ||
export class SmallStageTextNarrowExampleComponent { | ||
} |
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,7 @@ | ||
{ | ||
"ngPackage": { | ||
"lib": { | ||
"entryFile": "public-api.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,3 @@ | ||
|
||
export * from './small-stage.module'; | ||
export * from './small-stage.component'; |
6 changes: 6 additions & 0 deletions
6
projects/ng-aquila/src/small-stage/small-stage.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 @@ | ||
<div class="content-container"> | ||
<ng-content></ng-content> | ||
</div> | ||
<div class="image-container"> | ||
<div class="image-container__inner" [style]="_imageInlineStyle"></div> | ||
</div> |
107 changes: 107 additions & 0 deletions
107
projects/ng-aquila/src/small-stage/small-stage.component.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,107 @@ | ||
@import '../shared-styles/index'; | ||
|
||
$image-container-offset-end: var(--small-stage-image-container-offset-end); | ||
$image-container-padding-start: var(--small-stage-image-container-padding-start); | ||
$image-container-padding-top: var(--small-stage-image-container-padding-top); | ||
|
||
:host { | ||
display: -ms-grid; | ||
display: grid; | ||
-ms-grid-columns: 2fr 1fr; | ||
grid-template-columns: 2fr 1fr; | ||
padding: 0 nx-spacer(2m); | ||
background-color: var(--small-stage-background-color); | ||
|
||
&.nx-small-stage--content-narrow { | ||
-ms-grid-columns: 1fr 1fr; | ||
grid-template-columns: 1fr 1fr; | ||
} | ||
|
||
@include media-breakpoint-response(mobile) { | ||
-ms-grid-columns: 1fr; | ||
grid-template-columns: 1fr; | ||
|
||
&.nx-small-stage--content-narrow { | ||
-ms-grid-columns: 1fr; | ||
grid-template-columns: 1fr; | ||
} | ||
} | ||
} | ||
|
||
.content-container { | ||
padding: nx-spacer(3m) 0 nx-spacer(2m); | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-end; | ||
-ms-grid-row: 1; | ||
-ms-grid-column: 1; | ||
} | ||
|
||
.image-container { | ||
min-height: var(--small-stage-image-min-height); | ||
padding-left: $image-container-padding-start; | ||
padding-top: $image-container-padding-top; | ||
position: relative; | ||
-ms-grid-row: 1; | ||
-ms-grid-column: 2; | ||
|
||
:host(.nx-small-stage--w-end-offset) & { | ||
padding-right: $image-container-offset-end; | ||
} | ||
|
||
@include media-breakpoint-response(mobile) { | ||
-ms-grid-row: 2; | ||
-ms-grid-column: 1; | ||
padding-top: 0; | ||
|
||
:host(.nx-small-stage--w-end-offset) & { | ||
padding-right: 0; | ||
} | ||
} | ||
|
||
&__inner { | ||
position: absolute; | ||
min-width: var(--small-stage-image-min-width); | ||
width: calc(100% - #{$image-container-padding-start}); | ||
height: calc(100% - #{$image-container-padding-top}); | ||
background-size: contain; | ||
background-repeat: no-repeat; | ||
background-position: center bottom; | ||
|
||
:host(.nx-small-stage--w-end-offset) & { | ||
width: calc(100% - #{$image-container-offset-end} - #{$image-container-padding-start}); | ||
} | ||
|
||
@include media-breakpoint-response(mobile) { | ||
background-position: right bottom; | ||
width: calc(100% - #{$image-container-padding-start}); | ||
height: 100%; | ||
|
||
:host(.nx-small-stage--w-end-offset) & { | ||
width: calc(100% - #{$image-container-padding-start}); | ||
} | ||
} | ||
} | ||
|
||
:host-context([dir="rtl"]) { | ||
.image-container { | ||
padding-right: $image-container-padding-start; | ||
padding-left: 0; | ||
} | ||
|
||
&.nx-small-stage--w-end-offset .image-container { | ||
padding-left: $image-container-offset-end; | ||
|
||
@include media-breakpoint-response(mobile) { | ||
padding-left: 0; | ||
} | ||
} | ||
|
||
.image-container__inner { | ||
@include media-breakpoint-response(mobile) { | ||
background-position: left bottom; | ||
} | ||
} | ||
} | ||
} | ||
|
87 changes: 87 additions & 0 deletions
87
projects/ng-aquila/src/small-stage/small-stage.component.spec.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,87 @@ | ||
import { Component, DebugElement, Type, ViewChild, Directive } from '@angular/core'; | ||
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import * as axe from 'axe-core'; | ||
|
||
import { NxSmallStageComponent } from './small-stage.component'; | ||
import { NxSmallStageModule } from './small-stage.module'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
// For better readablity here, We can safely ignore some conventions in our specs | ||
// tslint:disable:component-class-suffix | ||
|
||
@Directive() | ||
abstract class SmallStageTest { | ||
@ViewChild(NxSmallStageComponent) smallStageInstance: NxSmallStageComponent; | ||
} | ||
|
||
describe('NxSmallStageComponent', () => { | ||
let fixture: ComponentFixture<SmallStageTest>; | ||
let testInstance: SmallStageTest; | ||
let smallStageInstance: NxSmallStageComponent; | ||
let smallStageDebugElement: DebugElement; | ||
|
||
const createTestComponent = (component: Type<SmallStageTest>) => { | ||
fixture = TestBed.createComponent(component); | ||
fixture.detectChanges(); | ||
testInstance = fixture.componentInstance; | ||
smallStageInstance = testInstance.smallStageInstance; | ||
smallStageDebugElement = fixture.debugElement.query(By.directive(NxSmallStageComponent)); | ||
}; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
BasicSmallStage, | ||
DynamicSmallStage, | ||
], | ||
imports: [ | ||
NxSmallStageModule, | ||
] | ||
}).compileComponents(); | ||
})); | ||
|
||
it('creates the small stage', waitForAsync(() => { | ||
createTestComponent(BasicSmallStage); | ||
expect(smallStageInstance).toBeTruthy(); | ||
})); | ||
|
||
it('should change class when input changes', () => { | ||
createTestComponent(DynamicSmallStage); | ||
(testInstance as DynamicSmallStage).contentNarrow = true; | ||
fixture.detectChanges(); | ||
expect(smallStageDebugElement.nativeElement.classList.contains('nx-small-stage--content-narrow')).toBe(true); | ||
}); | ||
|
||
describe('a11y', () => { | ||
it('has no accessbility violations', function (done) { | ||
createTestComponent(BasicSmallStage); | ||
|
||
axe.run(fixture.nativeElement, {}, (error: Error, results: axe.AxeResults) => { | ||
expect(results.violations.length).toBe(0); | ||
// const violationMessages = results.violations.map(item => item.description); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
@Component({ | ||
template: ` | ||
<nx-small-stage> | ||
<p>text</p> | ||
</nx-small-stage> | ||
` | ||
}) | ||
class BasicSmallStage extends SmallStageTest { | ||
} | ||
|
||
@Component({ | ||
template: ` | ||
<nx-small-stage [contentNarrow]="contentNarrow"> | ||
<p>text</p> | ||
</nx-small-stage> | ||
` | ||
}) | ||
class DynamicSmallStage extends SmallStageTest { | ||
contentNarrow = false; | ||
} |
Oops, something went wrong.