Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design): add a media-gallery component (#1206)
Co-authored-by: xelaint <xelaint@gmail.com> Co-authored-by: lderrickable <lderrickable@gmail.com> Co-authored-by: damienwebdev <damien@graycore.io>
- Loading branch information
1 parent
f81c7ef
commit a131764
Showing
42 changed files
with
1,239 additions
and
4 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
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
21 changes: 21 additions & 0 deletions
21
apps/design-land/src/app/media-gallery/media-gallery-routing-module.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,21 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { | ||
Routes, | ||
RouterModule, | ||
} from '@angular/router'; | ||
|
||
import { DesignLandMediaGalleryComponent } from './media-gallery.component'; | ||
|
||
export const mediaGalleryRoutes: Routes = [ | ||
{ path: '', component: DesignLandMediaGalleryComponent }, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
RouterModule.forChild(mediaGalleryRoutes), | ||
], | ||
exports: [ | ||
RouterModule, | ||
], | ||
}) | ||
export class DesignLandMediaGalleryRoutingModule {} |
19 changes: 19 additions & 0 deletions
19
apps/design-land/src/app/media-gallery/media-gallery.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 @@ | ||
<daff-article> | ||
<h1 daffArticleTitle>Media Gallery</h1> | ||
<p daffArticleLead><code><daff-media-gallery></code> is used to display a group of <code>[daffThumbnail]</code>s in a gallery format. Media galleries are useful to showcase multiple images related to a single product or topic.</p> | ||
|
||
<h2>Thumbnail</h2> | ||
<p><code>[daffThumbnail]</code>should be used as a directive with <code><daff-image></code>. (View <a href="/image">Image Documentation</a>)</p> | ||
<p>It should never be used as a standalone component. The first thumbnail is selected by default and dynamically rendered as the primary image by utilizing the <code><daff-media-renderer></code> component. The selected thumbnail can be controlled by the enduser, and the position of the list of thumbnails is dependent on the screen size.</p> | ||
|
||
<design-land-example-viewer-container example="basic-media-gallery"></design-land-example-viewer-container> | ||
|
||
<h2>Image Aspect Ratio</h2> | ||
<p>It's recommended to utilize the same aspect ratio for all images in the same media gallery. Otherwise, the height and width of the media gallery may change with every different aspect ratio presented by the selected thumbnail as show in the example.</p> | ||
|
||
<p>The thumbnail dimension is set to <code>80x80</code> pixels, so the recommended aspect ratio is <code>1:1</code>. However, it is not required since the thumbnail will horizontally and vertically center align images within a thumbnail.</p> | ||
<design-land-example-viewer-container example="mismatched-sizes-media-gallery"></design-land-example-viewer-container> | ||
|
||
<h2>Accessibility</h2> | ||
<p>Accessibility considerations for media gallery is handled by the <code>DaffImageComponent</code>. The <code>alt</code> attribute must be defined in <code><daff-image></code>. It specifies an alternate text for an image. An error will appear if it's not defined. This is important because it allows screen readers to describe what's in the image for visually impaired people. (View <a href="/image">Image Documentation</a>)</p> | ||
</daff-article> |
Empty file.
29 changes: 29 additions & 0 deletions
29
apps/design-land/src/app/media-gallery/media-gallery.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,29 @@ | ||
import { | ||
async, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
|
||
import { DesignLandMediaGalleryComponent } from './media-gallery.component'; | ||
|
||
describe('DesignLandMediaGalleryComponent', () => { | ||
let component: DesignLandMediaGalleryComponent; | ||
let fixture: ComponentFixture<DesignLandMediaGalleryComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ DesignLandMediaGalleryComponent ], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DesignLandMediaGalleryComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
apps/design-land/src/app/media-gallery/media-gallery.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,11 @@ | ||
import { | ||
Component, | ||
OnInit, | ||
} from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'design-land-media-gallery', | ||
templateUrl: './media-gallery.component.html', | ||
styleUrls: ['./media-gallery.component.scss'], | ||
}) | ||
export class DesignLandMediaGalleryComponent {} |
53 changes: 53 additions & 0 deletions
53
apps/design-land/src/app/media-gallery/media-gallery.module.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,53 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { | ||
NgModule, | ||
Injector, | ||
ComponentFactoryResolver, | ||
} from '@angular/core'; | ||
import { createCustomElement } from '@angular/elements'; | ||
|
||
|
||
import { | ||
DaffArticleModule, | ||
DaffMediaGalleryModule, | ||
DaffImageModule, | ||
} from '@daffodil/design'; | ||
import { MEDIA_GALLERY_EXAMPLES } from '@daffodil/design/media-gallery/examples'; | ||
|
||
import { DesignLandExampleViewerModule } from '../core/code-preview/container/example-viewer.module'; | ||
import { DesignLandMediaGalleryRoutingModule } from './media-gallery-routing-module'; | ||
import { DesignLandMediaGalleryComponent } from './media-gallery.component'; | ||
|
||
|
||
@NgModule({ | ||
declarations: [ | ||
DesignLandMediaGalleryComponent, | ||
], | ||
imports: [ | ||
CommonModule, | ||
DesignLandMediaGalleryRoutingModule, | ||
DesignLandExampleViewerModule, | ||
|
||
DaffArticleModule, | ||
DaffMediaGalleryModule, | ||
DaffImageModule, | ||
], | ||
}) | ||
export class DesignLandMediaGalleryModule { | ||
constructor( | ||
injector: Injector, | ||
private componentFactoryResolver: ComponentFactoryResolver, | ||
) { | ||
MEDIA_GALLERY_EXAMPLES.map((classConstructor) => ({ | ||
element: createCustomElement(classConstructor, { injector }), | ||
class: classConstructor, | ||
})) | ||
.map((customElement) => { | ||
// Register the custom element with the browser. | ||
customElements.define( | ||
this.componentFactoryResolver.resolveComponentFactory(customElement.class).selector + '-example', | ||
customElement.element, | ||
); | ||
}); | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json", | ||
"dest": "../../../dist/design/examples", | ||
"deleteDestPath": false, | ||
"lib": { | ||
"entryFile": "src/index.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 @@ | ||
{ | ||
"name": "@daffodil/design/media-gallery/examples" | ||
} |
7 changes: 7 additions & 0 deletions
7
.../design/media-gallery/examples/src/basic-media-gallery/basic-media-gallery.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,7 @@ | ||
<daff-media-gallery> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1556804335-2fa563e93aae?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=3763&q=80" alt="Drink" width="946" height="946"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1607344635159-59930e3330b1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1600&q=80" alt="Drink" width="946" height="946"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1584559582213-787a2953dcbe?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1600&q=80" alt="Fruits" width="946" height="946"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1587324438673-56c78a866b15?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1600&q=80" alt="Lemons" width="946" height="946"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1543363136-7fbfcd3b240d?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1600&q=80" alt="Avocado" width="946" height="946"></daff-image> | ||
</daff-media-gallery> |
11 changes: 11 additions & 0 deletions
11
libs/design/media-gallery/examples/src/basic-media-gallery/basic-media-gallery.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,11 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'basic-media-gallery', | ||
templateUrl: './basic-media-gallery.component.html', | ||
}) | ||
export class BasicMediaGalleryComponent { | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
libs/design/media-gallery/examples/src/basic-media-gallery/basic-media-gallery.module.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,23 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { | ||
DaffMediaGalleryModule, | ||
DaffImageModule, | ||
} from '@daffodil/design'; | ||
|
||
import { BasicMediaGalleryComponent } from './basic-media-gallery.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
BasicMediaGalleryComponent, | ||
], | ||
exports: [ | ||
BasicMediaGalleryComponent, | ||
], | ||
imports: [ | ||
DaffImageModule, | ||
DaffMediaGalleryModule, | ||
], | ||
providers: [], | ||
}) | ||
export class BasicMediaGalleryModule { } |
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 @@ | ||
import { BasicMediaGalleryComponent } from './basic-media-gallery/basic-media-gallery.component'; | ||
import { MismatchedSizesMediaGalleryComponent } from './mismatched-sizes-media-gallery/mismatched-sizes-media-gallery.component'; | ||
|
||
export const MEDIA_GALLERY_EXAMPLES = [ | ||
BasicMediaGalleryComponent, | ||
MismatchedSizesMediaGalleryComponent, | ||
]; |
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 './public_api'; |
7 changes: 7 additions & 0 deletions
7
...examples/src/mismatched-sizes-media-gallery/mismatched-sizes-media-gallery.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,7 @@ | ||
<daff-media-gallery> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1556804335-2fa563e93aae?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=3763&q=80" alt="Drink" width="946" height="946"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1551410224-699683e15636?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1300&q=80" alt="Drink" width="640" height="799"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1586788224331-947f68671cf1?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=934&q=80" alt="Fruits" width="640" height="960"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1559181567-c3190ca9959b?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=1300&q=80" alt="Cherries" width="640" height="800"></daff-image> | ||
<daff-image daffThumbnail src="https://images.unsplash.com/photo-1606926167690-07a1edafd407?ixlib=rb-1.2.1&ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&auto=format&fit=crop&w=2250&q=80" alt="Lemons" width="640" height="426"></daff-image> | ||
</daff-media-gallery> |
8 changes: 8 additions & 0 deletions
8
...y/examples/src/mismatched-sizes-media-gallery/mismatched-sizes-media-gallery.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,8 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
// eslint-disable-next-line @angular-eslint/component-selector | ||
selector: 'mismatched-sizes-media-gallery', | ||
templateUrl: './mismatched-sizes-media-gallery.component.html', | ||
}) | ||
export class MismatchedSizesMediaGalleryComponent {} |
23 changes: 23 additions & 0 deletions
23
...lery/examples/src/mismatched-sizes-media-gallery/mismatched-sizes-media-gallery.module.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,23 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { | ||
DaffMediaGalleryModule, | ||
DaffImageModule, | ||
} from '@daffodil/design'; | ||
|
||
import { MismatchedSizesMediaGalleryComponent } from './mismatched-sizes-media-gallery.component'; | ||
|
||
@NgModule({ | ||
declarations: [ | ||
MismatchedSizesMediaGalleryComponent, | ||
], | ||
exports: [ | ||
MismatchedSizesMediaGalleryComponent, | ||
], | ||
imports: [ | ||
DaffImageModule, | ||
DaffMediaGalleryModule, | ||
], | ||
providers: [], | ||
}) | ||
export class MismatchedSizesMediaGalleryModule { } |
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,4 @@ | ||
export { MEDIA_GALLERY_EXAMPLES } from './examples'; | ||
|
||
export { BasicMediaGalleryModule } from './basic-media-gallery/basic-media-gallery.module'; | ||
export { MismatchedSizesMediaGalleryModule } from './mismatched-sizes-media-gallery/mismatched-sizes-media-gallery.module'; |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<div class="daff-image__wrapper" [style.paddingTop]="paddingTop"> | ||
<div class="daff-image__wrapper" [style.paddingTop]="_paddingTop"> | ||
<img [src]="src" [alt]="alt" (load)="load.emit" /> | ||
</div> |
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
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 @@ | ||
# Media Gallery | ||
`<daff-media-gallery>` is used to display a group of `[daffThumbnail]`s in a gallery format. Media galleries are useful to showcase multiple images related to a single product or topic. | ||
|
||
## Thumbnail | ||
`[daffThumbnail]` should be used as a directive with `<daff-image>`. [View Image Documentation](/libs/design/src/atoms/image/README.md) | ||
|
||
It should never be used as a standalone component. The first thumbnail is selected by default and dynamically rendered as the primary image by utilizing the `<daff-media-renderer>` component. The selected thumbnail can be controlled by the enduser, and the position of the list of thumbnails is dependent on the screen size. | ||
|
||
<design-land-example-viewer-container example="basic-media-gallery"></design-land-example-viewer-container> | ||
|
||
## Image Aspect Ratio | ||
It's recommended to utilize the same aspect ratio for all images in the same media gallery. Otherwise, the height and width of the media gallery may change with every different aspect ratio presented by the selected thumbnail as show in the example. | ||
|
||
The thumbnail dimension is set to `80x80` pixels, so the recommended aspect ratio is `1:1`. However, it is not required since the thumbnail will horizontally and vertically center align images within a thumbnail. | ||
|
||
<design-land-example-viewer-container example="mismatched-sizes-media-gallery"></design-land-example-viewer-container> | ||
|
||
## Accessibility | ||
Accessibility considerations for media gallery is handled by the `DaffImageComponent`. The `alt` attribute must be defined in `<daff-image>`. It specifies an alternate text for an image. An error will appear if it's not defined. This is important because it allows screen readers to describe what's in the image for visually impaired people. [View Image Documentation](/libs/design/src/atoms/image/README.md) |
22 changes: 22 additions & 0 deletions
22
libs/design/src/molecules/media-gallery/media-gallery-theme.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,22 @@ | ||
@mixin daff-media-gallery-theme($theme) { | ||
$primary: map-get($theme, primary); | ||
$secondary: map-get($theme, secondary); | ||
$tertiary: map-get($theme, tertiary); | ||
$base: daff-map-deep-get($theme, 'core.base'); | ||
$white: daff-map-deep-get($theme, 'core.white'); | ||
$black: daff-map-deep-get($theme, 'core.black'); | ||
$gray: daff-configure-palette($daff-gray, 60); | ||
|
||
.daff-media-gallery { | ||
$root: &; | ||
|
||
.daff-thumbnail { | ||
border: 1px solid transparent; | ||
transition: border 150ms; | ||
|
||
&--selected { | ||
border: 1px solid daff-color($gray); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.