1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

[CL-24] Add tables (#2950)

This commit is contained in:
Oscar Hinton 2022-07-28 12:43:00 +02:00 committed by GitHub
parent da341e1317
commit 4fc278b956
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import { HostBinding, Directive } from "@angular/core";
@Directive({
selector: "th[bitCell], td[bitCell]",
})
export class CellDirective {
@HostBinding("class") get classList() {
return ["tw-p-3"];
}
}

View File

@ -0,0 +1 @@
export * from "./table.module";

View File

@ -0,0 +1,17 @@
import { HostBinding, Directive } from "@angular/core";
@Directive({
selector: "tr[bitRow]",
})
export class RowDirective {
@HostBinding("class") get classList() {
return [
"tw-border-0",
"tw-border-b",
"tw-border-secondary-300",
"tw-border-solid",
"hover:tw-bg-background-alt",
"last:tw-border-0",
];
}
}

View File

@ -0,0 +1,10 @@
<table class="tw-table-auto tw-w-full tw-text-main tw-leading-normal">
<thead
class="tw-border-solid tw-border-0 tw-border-b-2 tw-border-secondary-300 tw-text-muted tw-text-bold"
>
<ng-content select="[header]"></ng-content>
</thead>
<tbody>
<ng-content select="[body]"></ng-content>
</tbody>
</table>

View File

@ -0,0 +1,7 @@
import { Component } from "@angular/core";
@Component({
selector: "bit-table",
templateUrl: "./table.component.html",
})
export class TableComponent {}

View File

@ -0,0 +1,13 @@
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { CellDirective } from "./cell.directive";
import { RowDirective } from "./row.directive";
import { TableComponent } from "./table.component";
@NgModule({
imports: [CommonModule],
declarations: [TableComponent, CellDirective, RowDirective],
exports: [TableComponent, CellDirective, RowDirective],
})
export class TableModule {}

View File

@ -0,0 +1,53 @@
import { Meta, moduleMetadata, Story } from "@storybook/angular";
import { TableModule } from "./table.module";
export default {
title: "Component Library/Table",
decorators: [
moduleMetadata({
imports: [TableModule],
}),
],
parameters: {
design: {
type: "figma",
url: "https://www.figma.com/file/Zt3YSeb6E6lebAffrNLa0h/Tailwind-Component-Library?node-id=1881%3A18371",
},
},
} as Meta;
const Template: Story = (args) => ({
props: args,
template: `
<bit-table>
<ng-container header>
<tr>
<th bitCell>Header 1</th>
<th bitCell>Header 2</th>
<th bitCell>Header 3</th>
</tr>
</ng-container>
<ng-container body>
<tr bitRow>
<td bitCell>Cell 1</td>
<td bitCell>Cell 2</td>
<td bitCell>Cell 3</td>
</tr>
<tr bitRow>
<td bitCell>Cell 4</td>
<td bitCell>Cell 5</td>
<td bitCell>Cell 6</td>
</tr>
<tr bitRow>
<td bitCell>Cell 7</td>
<td bitCell>Cell 8</td>
<td bitCell>Cell 9</td>
</tr>
</ng-container>
</bit-table>
`,
});
export const Default = Template.bind({});