Skip to content

Commit

Permalink
feat(design)!: shard card component (#2674)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `DaffCardModule` has moved to its own package. Update imports to `@daffodil/design/card`
  • Loading branch information
xelaint committed Dec 20, 2023
1 parent 88e31ed commit 142e1c1
Show file tree
Hide file tree
Showing 39 changed files with 81 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { DaffCardModule } from '@daffodil/design';
import { DaffButtonModule } from '@daffodil/design/button';
import { DaffCalloutModule } from '@daffodil/design/callout';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffContainerModule } from '@daffodil/design/container';
import { DaffImageModule } from '@daffodil/design/image';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { DaffCardModule } from '@daffodil/design';
import { DaffCalloutModule } from '@daffodil/design/callout';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffContainerModule } from '@daffodil/design/container';

import { DaffioWhyPwaExamplesComponent } from './why-pwa-examples.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

import { DaffCardModule } from '@daffodil/design';
import { DaffCalloutModule } from '@daffodil/design/callout';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffContainerModule } from '@daffodil/design/container';

import { DaffioWhyPwaOverviewComponent } from './why-pwa-overview.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

import { DaffCardModule } from '@daffodil/design';
import { DaffCalloutModule } from '@daffodil/design/callout';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffContainerModule } from '@daffodil/design/container';

import { DaffioWhyPwaStatsComponent } from './why-pwa-stats.component';
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

import { DaffCardModule } from '@daffodil/design';
import { DaffButtonModule } from '@daffodil/design/button';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffImageModule } from '@daffodil/design/image';

import { BasicCardComponent } from './basic-card.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';

import { DaffCardModule } from '@daffodil/design';
import { DaffButtonModule } from '@daffodil/design/button';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffImageModule } from '@daffodil/design/image';

import { CardOrientationComponent } from './card-orientation.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';

import { DaffCardModule } from '@daffodil/design';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffImageModule } from '@daffodil/design/image';

import { CardThemingComponent } from './card-theming.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';

import { DaffCardModule } from '@daffodil/design';
import { DaffButtonModule } from '@daffodil/design/button';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffImageModule } from '@daffodil/design/image';

import { LinkableCardComponent } from './linkable-card.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';

import { DaffCardModule } from '@daffodil/design';
import { DaffButtonModule } from '@daffodil/design/button';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffImageModule } from '@daffodil/design/image';

import { RaisedCardComponent } from './raised-card.component';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';

import { DaffCardModule } from '@daffodil/design';
import { DaffButtonModule } from '@daffodil/design/button';
import { DaffCardModule } from '@daffodil/design/card';
import { DaffImageModule } from '@daffodil/design/image';

import { StrokedCardComponent } from './stroked-card.component';
Expand Down
9 changes: 9 additions & 0 deletions libs/design/card/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/design/card",
"deleteDestPath": false,
"lib": {
"entryFile": "src/index.ts",
"styleIncludePaths": ["../src/scss"]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../../../../scss/theming';
@use '../../../scss/theming';

@mixin daff-basic-card-theme-variant($color) {
background: $color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@use '../../../../../scss/theming';
@use '../../../scss/theming';

@mixin daff-linkable-card-theme-variant(
$hover-color,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@use 'sass:map';
@use '../../../../scss/core';
@use '../../../../scss/theming';
@use '../../scss/core';
@use '../../scss/theming';
@use './card-theme-variants/basic-card' as basic;
@use './card-theme-variants/stroked-card' as stroked;
@use './card-theme-variants/linkable-card' as linkable;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@use '../../../../scss/typography' as t;
@use '../../../../scss/layout';
@use '../../../scss/typography' as t;
@use '../../../scss/layout';

$card-border-radius: 8px;
$card-inner-border-radius: calc(#{$card-border-radius} - 1px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import {
} from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { DaffPalette } from '@daffodil/design';

import {
DaffCardComponent,
DaffCardOrientation,
} from './card.component';
import { DaffPalette } from '../../../core/colorable/public_api';

@Component ({
template: `<daff-card [color]="color" [orientation]="orientation"></daff-card>`,
Expand All @@ -24,7 +25,7 @@ class WrapperComponent {
orientation: DaffCardOrientation;
}

describe('DaffCardComponent', () => {
describe('DaffCardComponent | Usage', () => {
let fixture: ComponentFixture<WrapperComponent>;
let de: DebugElement;
let wrapper: WrapperComponent;
Expand Down Expand Up @@ -95,3 +96,52 @@ describe('DaffCardComponent', () => {
});
});
});

describe('DaffCardComponent | Defaults', () => {
let fixture: ComponentFixture<WrapperComponent>;
let de: DebugElement;
let wrapper: WrapperComponent;
let component: DaffCardComponent;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffCardComponent,
WrapperComponent,
],
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(WrapperComponent);
wrapper = fixture.componentInstance;
de = fixture.debugElement.query(By.css('daff-card'));
component = de.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(wrapper).toBeTruthy();
});

describe('<daff-card>', () => {
it('should add a class of "daff-card" to the host element', () => {
expect(de.classes).toEqual(jasmine.objectContaining({
'daff-card': true,
}));
});
});

describe('using the orientation property of a card', () => {
it('should set the default orientation to vertical', () => {
expect(component.orientation).toEqual('vertical');
});
});

describe('using the color property of a card', () => {
it('should not set a default color', () => {
expect(component.color).toBeFalsy();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
OnInit,
} from '@angular/core';

import { daffArticleEncapsulatedMixin } from '../../../core/article-encapsulated/public_api';
import {
daffArticleEncapsulatedMixin,
DaffColorable,
daffColorMixin,
} from '../../../core/colorable/public_api';
} from '@daffodil/design';

export type DaffCardType = null | 'daff-raised-card' | 'daff-stroked-card';

Expand Down
1 change: 1 addition & 0 deletions libs/design/card/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './public_api';
File renamed without changes.
2 changes: 1 addition & 1 deletion libs/design/scss/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@use '../src/atoms/progress-indicator/progress-indicator-theme' as progress-indicator;
@use '../accordion/src/accordion-theme' as accordion;
@use '../callout/src/callout-theme' as callout;
@use '../src/molecules/card/card/card-theme' as card;
@use '../card/src/card-theme' as card;
@use '../src/molecules/hero/hero-theme' as hero;
@use '../src/molecules/list/list/list-theme' as list;
@use '../src/molecules/media-gallery/media-gallery-theme' as media-gallery;
Expand Down
67 changes: 0 additions & 67 deletions libs/design/src/molecules/card/card/specs/card-default.spec.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { BehaviorSubject } from 'rxjs';
import { DaffArticleComponent } from '@daffodil/design/article';

import { DaffMediaRendererComponent } from './media-renderer.component';
import { DaffCardComponent } from '../../card/public_api';
import { DaffMediaGalleryRegistration } from '../media-gallery-registration.interface';
import { DAFF_MEDIA_GALLERY_TOKEN } from '../media-gallery-token';
import { DaffMediaGalleryRegistry } from '../registry/media-gallery.registry';
Expand Down Expand Up @@ -60,7 +59,6 @@ describe('DaffMediaRendererComponent', () => {
declarations: [
DaffMediaRendererComponent,
DaffArticleComponent,
DaffCardComponent,
DaffMockThumbnail1Component,
DaffMockThumbnail2Component,
],
Expand Down
1 change: 0 additions & 1 deletion libs/design/src/public_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export * from './molecules/paginator/public_api';
export * from './molecules/qty-dropdown/public_api';
export * from './molecules/hero/public_api';
export * from './molecules/feature/public_api';
export * from './molecules/card/public_api';

// Core
export * from './core/public_api';
Expand Down

0 comments on commit 142e1c1

Please sign in to comment.