mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
[CL-236] Card component (#8900)
* add card component; adjust section margin on small screens
This commit is contained in:
parent
5dc83cd34c
commit
e89c82defe
15
libs/components/src/card/card.component.ts
Normal file
15
libs/components/src/card/card.component.ts
Normal 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 {}
|
62
libs/components/src/card/card.stories.ts
Normal file
62
libs/components/src/card/card.stories.ts
Normal 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>
|
||||
`,
|
||||
}),
|
||||
};
|
1
libs/components/src/card/index.ts
Normal file
1
libs/components/src/card/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./card.component";
|
@ -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";
|
||||
|
@ -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>
|
||||
`,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user