[CL-236] Card component (#8900)

* add card component; adjust section margin on small screens
This commit is contained in:
Will Martin 2024-04-24 14:52:29 -04:00 committed by GitHub
parent 5dc83cd34c
commit e89c82defe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 81 additions and 2 deletions

View File

@ -0,0 +1,15 @@
import { CommonModule } from "@angular/common";
import { ChangeDetectionStrategy, Component } from "@angular/core";
@Component({
selector: "bit-card",
standalone: true,
imports: [CommonModule],
template: `<ng-content></ng-content>`,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class:
"tw-box-border tw-block tw-bg-background tw-text-main tw-border-solid tw-border-b tw-border-0 tw-border-b-secondary-300 tw-rounded-lg tw-py-4 tw-px-3",
},
})
export class CardComponent {}

View File

@ -0,0 +1,62 @@
import { Meta, StoryObj, componentWrapperDecorator, moduleMetadata } from "@storybook/angular";
import { SectionComponent } from "../section";
import { TypographyModule } from "../typography";
import { CardComponent } from "./card.component";
export default {
title: "Component Library/Card",
component: CardComponent,
decorators: [
moduleMetadata({
imports: [TypographyModule, SectionComponent],
}),
componentWrapperDecorator(
(story) => `<div class="tw-bg-background-alt tw-p-10 tw-text-main">${story}</div>`,
),
],
} as Meta;
type Story = StoryObj<CardComponent>;
/** Cards are presentational containers. */
export const Default: Story = {
render: (args) => ({
props: args,
template: /*html*/ `
<bit-card>
<p bitTypography="body1" class="!tw-mb-0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae congue risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc elementum odio nibh, eget pellentesque sem ornare vitae. Etiam vel ante et velit fringilla egestas a sed sem. Fusce molestie nisl et nisi accumsan dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed eu risus ex. </p>
</bit-card>
`,
}),
};
/** Cards are often paired with [Sections](/docs/component-library-section--docs). */
export const WithinSections: Story = {
render: (args) => ({
props: args,
template: /*html*/ `
<bit-section>
<h2 bitTypography="h5">Bar</h2>
<bit-card>
<p bitTypography="body1" class="!tw-mb-0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae congue risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc elementum odio nibh, eget pellentesque sem ornare vitae. Etiam vel ante et velit fringilla egestas a sed sem. Fusce molestie nisl et nisi accumsan dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed eu risus ex. </p>
</bit-card>
</bit-section>
<bit-section>
<h2 bitTypography="h5">Bar</h2>
<bit-card>
<p bitTypography="body1" class="!tw-mb-0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae congue risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc elementum odio nibh, eget pellentesque sem ornare vitae. Etiam vel ante et velit fringilla egestas a sed sem. Fusce molestie nisl et nisi accumsan dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed eu risus ex. </p>
</bit-card>
</bit-section>
<bit-section>
<h2 bitTypography="h5">Bar</h2>
<bit-card>
<p bitTypography="body1" class="!tw-mb-0">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae congue risus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc elementum odio nibh, eget pellentesque sem ornare vitae. Etiam vel ante et velit fringilla egestas a sed sem. Fusce molestie nisl et nisi accumsan dapibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed eu risus ex. </p>
</bit-card>
</bit-section>
`,
}),
};

View File

@ -0,0 +1 @@
export * from "./card.component";

View File

@ -7,6 +7,7 @@ export * from "./breadcrumbs";
export * from "./button";
export { ButtonType } from "./shared/button-like.abstraction";
export * from "./callout";
export * from "./card";
export * from "./checkbox";
export * from "./color-password";
export * from "./container";

View File

@ -6,7 +6,7 @@ import { Component } from "@angular/core";
standalone: true,
imports: [CommonModule],
template: `
<section class="tw-mb-12">
<section class="tw-mb-6 md:tw-mb-12">
<ng-content></ng-content>
</section>
`,

View File

@ -17,7 +17,7 @@ export default {
type Story = StoryObj<SectionComponent>;
/** Sections are simple containers that apply a bottom margin. They often contain a heading. */
/** Sections are simple containers that apply a responsive bottom margin. They often contain a heading. */
export const Default: Story = {
render: (args) => ({
props: args,