diff --git a/.storybook/initComponents.js b/.storybook/initComponents.js index c4da9ab23..8c3949171 100644 --- a/.storybook/initComponents.js +++ b/.storybook/initComponents.js @@ -38,6 +38,11 @@ import { PharosTabs, PharosTab, PharosTable, + PharosTableBody, + PharosTableHeader, + PharosTableRow, + PharosTableCell, + PharosTableHeaderCell, PharosTabPanel, PharosTextInput, PharosTextarea, @@ -90,6 +95,11 @@ registerComponents('storybook', [ PharosTabs, PharosTab, PharosTable, + PharosTableBody, + PharosTableHeader, + PharosTableRow, + PharosTableCell, + PharosTableHeaderCell, PharosTabPanel, PharosTextInput, PharosTextarea, diff --git a/packages/pharos-site/src/components/statics/component-status/initComponents.js b/packages/pharos-site/src/components/statics/component-status/initComponents.js new file mode 100644 index 000000000..e1de67d82 --- /dev/null +++ b/packages/pharos-site/src/components/statics/component-status/initComponents.js @@ -0,0 +1,114 @@ +import { + PharosAlert, + PharosBreadcrumb, + PharosBreadcrumbItem, + PharosButton, + PharosCheckbox, + PharosCheckboxGroup, + PharosCoachMark, + PharosCombobox, + PharosDropdownMenu, + PharosDropdownMenuItem, + PharosDropdownMenuNav, + PharosDropdownMenuNavLink, + PharosDropdownMenuNavCategory, + PharosFooter, + PharosHeader, + PharosHeading, + PharosIcon, + PharosImageCard, + PharosInputGroup, + PharosInputGroupSelect, + PharosLayout, + PharosLink, + PharosLoadingSpinner, + PharosModal, + PharosPagination, + PharosPopover, + PharosProgressBar, + PharosRadioButton, + PharosRadioGroup, + PharosSelect, + PharosSheet, + PharosSidenav, + PharosSidenavLink, + PharosSidenavMenu, + PharosSidenavSection, + PharosSwitch, + PharosTabs, + PharosTab, + PharosTable, + PharosTableBody, + PharosTableHeader, + PharosTableRow, + Pharos, + PharosTableCell, + PharosTableHeaderCell, + PharosTabPanel, + PharosTextInput, + PharosTextarea, + PharosToast, + PharosToaster, + PharosToastButton, + PharosToggleButton, + PharosToggleButtonGroup, + PharosTooltip, +} from '../packages/pharos/lib/index'; +import registerComponents from '../packages/pharos/lib/utils/registerComponents'; + +registerComponents('storybook', [ + PharosAlert, + PharosBreadcrumb, + PharosBreadcrumbItem, + PharosButton, + PharosCheckbox, + PharosCheckboxGroup, + PharosCoachMark, + PharosCombobox, + PharosDropdownMenu, + PharosDropdownMenuItem, + PharosDropdownMenuNav, + PharosDropdownMenuNavLink, + PharosDropdownMenuNavCategory, + PharosFooter, + PharosHeader, + PharosHeading, + PharosIcon, + PharosImageCard, + PharosInputGroup, + PharosInputGroupSelect, + PharosLayout, + PharosLink, + PharosLoadingSpinner, + PharosModal, + PharosPagination, + PharosPopover, + PharosProgressBar, + PharosRadioButton, + PharosRadioGroup, + PharosSelect, + PharosSheet, + PharosSidenav, + PharosSidenavLink, + PharosSidenavMenu, + PharosSidenavSection, + PharosSwitch, + PharosTabs, + PharosTab, + PharosTable, + PharosTableBody, + PharosTableHeader, + PharosTableHeaderCell, + PharosTableCell, + PharosTableRow, + Pharos, + PharosTabPanel, + PharosTextInput, + PharosTextarea, + PharosToast, + PharosToaster, + PharosToastButton, + PharosToggleButton, + PharosToggleButtonGroup, + PharosTooltip, +]); diff --git a/packages/pharos/src/components/table/pharos-table-body.scss b/packages/pharos/src/components/table/pharos-table-body.scss new file mode 100644 index 000000000..d9cebbbde --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-body.scss @@ -0,0 +1,3 @@ +:host { + display: table-row-group; +} diff --git a/packages/pharos/src/components/table/pharos-table-body.ts b/packages/pharos/src/components/table/pharos-table-body.ts new file mode 100644 index 000000000..ad7fd343e --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-body.ts @@ -0,0 +1,26 @@ +import { html, type CSSResultArray, type TemplateResult } from 'lit'; +import ScopedRegistryMixin from '../../utils/mixins/scoped-registry'; +import { PharosElement } from '../base/pharos-element'; +import { tableBodyStyles } from './pharos-table-body.css'; + +/** + * Pharos table Body component. + * + * @tag pharos-table + * + * + */ +export class PharosTableBody extends ScopedRegistryMixin(PharosElement) { + constructor() { + super(); + this.role = 'rowgroup'; + } + + public static override get styles(): CSSResultArray { + return [tableBodyStyles]; + } + + protected override render(): TemplateResult { + return html``; + } +} diff --git a/packages/pharos/src/components/table/pharos-table-cell.scss b/packages/pharos/src/components/table/pharos-table-cell.scss new file mode 100644 index 000000000..60f2310ee --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-cell.scss @@ -0,0 +1,5 @@ +:host { + display: table-cell; + border: 1px solid var(--pharos-table-body-color-border, var(--pharos-color-ui-30)); + padding: var(--pharos-spacing-1-x); +} diff --git a/packages/pharos/src/components/table/pharos-table-cell.ts b/packages/pharos/src/components/table/pharos-table-cell.ts new file mode 100644 index 000000000..d7110a5cd --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-cell.ts @@ -0,0 +1,26 @@ +import { html, type CSSResultArray, type TemplateResult } from 'lit'; +import ScopedRegistryMixin from '../../utils/mixins/scoped-registry'; +import { PharosElement } from '../base/pharos-element'; +import { tableCellStyles } from './pharos-table-cell.css'; + +/** + * Pharos table Cell Row component. + * + * @tag pharos-table + * + * + */ +export class PharosTableCell extends ScopedRegistryMixin(PharosElement) { + constructor() { + super(); + this.role = 'cell'; + } + + public static override get styles(): CSSResultArray { + return [tableCellStyles]; + } + + protected override render(): TemplateResult { + return html``; + } +} diff --git a/packages/pharos/src/components/table/pharos-table-header-cell.scss b/packages/pharos/src/components/table/pharos-table-header-cell.scss new file mode 100644 index 000000000..8416b59d5 --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-header-cell.scss @@ -0,0 +1,6 @@ +:host { + display: table-cell; + font-weight: bold; + border: 1px solid var(--pharos-table-header-color-border, var(--pharos-color-ui-30)); + padding: var(--pharos-spacing-1-x); +} diff --git a/packages/pharos/src/components/table/pharos-table-header-cell.ts b/packages/pharos/src/components/table/pharos-table-header-cell.ts new file mode 100644 index 000000000..b590bf169 --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-header-cell.ts @@ -0,0 +1,25 @@ +import { html, type CSSResultArray, type TemplateResult } from 'lit'; +import ScopedRegistryMixin from '../../utils/mixins/scoped-registry'; +import { PharosElement } from '../base/pharos-element'; +import { tableHeaderCellStyles } from './pharos-table-header-cell.css'; + +/** + * Pharos table Cell Row component. + * + * @tag pharos-table + * + * + */ +export class PharosTableHeaderCell extends ScopedRegistryMixin(PharosElement) { + constructor() { + super(); + this.role = 'columnheader'; + } + public static override get styles(): CSSResultArray { + return [tableHeaderCellStyles]; + } + + protected override render(): TemplateResult { + return html``; + } +} diff --git a/packages/pharos/src/components/table/pharos-table-header.scss b/packages/pharos/src/components/table/pharos-table-header.scss new file mode 100644 index 000000000..9d79ff603 --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-header.scss @@ -0,0 +1,4 @@ +:host { + display: table-header-group; + background-color: var(--pharos-table-header-color-background, var(--pharos-color-ui-20)); +} diff --git a/packages/pharos/src/components/table/pharos-table-header.ts b/packages/pharos/src/components/table/pharos-table-header.ts new file mode 100644 index 000000000..d8c500159 --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-header.ts @@ -0,0 +1,26 @@ +import { html, type CSSResultArray, type TemplateResult } from 'lit'; +import ScopedRegistryMixin from '../../utils/mixins/scoped-registry'; +import { PharosElement } from '../base/pharos-element'; +import { tableHeaderStyles } from './pharos-table-header.css'; + +/** + * Pharos table Head component. + * + * @tag pharos-table + * + * + */ +export class PharosTableHeader extends ScopedRegistryMixin(PharosElement) { + constructor() { + super(); + this.role = 'rowgroup'; + } + + public static override get styles(): CSSResultArray { + return [tableHeaderStyles]; + } + + protected override render(): TemplateResult { + return html``; + } +} diff --git a/packages/pharos/src/components/table/pharos-table-row.scss b/packages/pharos/src/components/table/pharos-table-row.scss new file mode 100644 index 000000000..ec81a4405 --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-row.scss @@ -0,0 +1,3 @@ +:host { + display: table-row; +} diff --git a/packages/pharos/src/components/table/pharos-table-row.ts b/packages/pharos/src/components/table/pharos-table-row.ts new file mode 100644 index 000000000..5c847e9a9 --- /dev/null +++ b/packages/pharos/src/components/table/pharos-table-row.ts @@ -0,0 +1,25 @@ +import { html, type CSSResultArray, type TemplateResult } from 'lit'; +import ScopedRegistryMixin from '../../utils/mixins/scoped-registry'; +import { PharosElement } from '../base/pharos-element'; +import { tableRowStyles } from './pharos-table-row.css'; + +/** + * Pharos table Row component. + * + * @tag pharos-table + * + * + */ +export class PharosTableRow extends ScopedRegistryMixin(PharosElement) { + constructor() { + super(); + this.role = 'row'; + } + + public static override get styles(): CSSResultArray { + return [tableRowStyles]; + } + protected override render(): TemplateResult { + return html``; + } +} diff --git a/packages/pharos/src/components/table/pharos-table.scss b/packages/pharos/src/components/table/pharos-table.scss index 05cfd90ef..4828774af 100644 --- a/packages/pharos/src/components/table/pharos-table.scss +++ b/packages/pharos/src/components/table/pharos-table.scss @@ -1,27 +1,34 @@ @use '../../utils/scss/mixins'; -:host { - display: inline-flex; - flex-direction: column; -} +// :host { +// display: inline-flex; +// flex-direction: column; +// } + +// :host { +// display: table; +// border: solid 2px magenta; +// } .table { border-collapse: collapse; + display: table; } -.table-header { - background-color: var(--pharos-table-header-color-background, var(--pharos-color-ui-20)); -} +// .table-header { +// display: table-header-group; +// background-color: var(--pharos-table-header-color-background, var(--pharos-color-ui-20)); +// } -.table-header__cell { - border: 1px solid var(--pharos-table-header-color-border, var(--pharos-color-ui-30)); - padding: var(--pharos-spacing-1-x); -} +// .table-header__cell { +// border: 1px solid var(--pharos-table-header-color-border, var(--pharos-color-ui-30)); +// padding: var(--pharos-spacing-1-x); +// } -.table-body__cell { - border: 1px solid var(--pharos-table-body-color-border, var(--pharos-color-ui-30)); - padding: var(--pharos-spacing-1-x); -} +// .table-body__cell { +// border: 1px solid var(--pharos-table-body-color-border, var(--pharos-color-ui-30)); +// padding: var(--pharos-spacing-1-x); +// } .table-sticky-header { position: sticky; diff --git a/packages/pharos/src/components/table/pharos-table.test.ts b/packages/pharos/src/components/table/pharos-table.test_old.ts similarity index 100% rename from packages/pharos/src/components/table/pharos-table.test.ts rename to packages/pharos/src/components/table/pharos-table.test_old.ts diff --git a/packages/pharos/src/components/table/pharos-table.ts b/packages/pharos/src/components/table/pharos-table.ts index 546b75612..d244f2f8f 100644 --- a/packages/pharos/src/components/table/pharos-table.ts +++ b/packages/pharos/src/components/table/pharos-table.ts @@ -1,9 +1,11 @@ import { PharosElement } from '../base/pharos-element'; import ScopedRegistryMixin from '../../utils/mixins/scoped-registry'; -import { html, nothing } from 'lit'; -import { classMap } from 'lit/directives/class-map.js'; +// import { html, nothing } from 'lit'; +import { html } from 'lit'; +// import { classMap } from 'lit/directives/class-map.js'; import { state } from 'lit/decorators.js'; -import type { TemplateResult, CSSResultArray } from 'lit'; +// import type { TemplateResult, CSSResultArray } from 'lit'; +import type { CSSResultArray, TemplateResult } from 'lit'; import { property } from 'lit/decorators.js'; import { tableStyles } from './pharos-table.css'; import { PharosSelect } from '../select/pharos-select'; @@ -90,8 +92,8 @@ export class PharosTable extends ScopedRegistryMixin(PharosElement) { @state() private _pageSize = 50; - @state() - private _currentPage = 1; + // @state() + // private _currentPage = 1; @state() private header: HTMLTableSectionElement | null = null; @@ -168,116 +170,108 @@ export class PharosTable extends ScopedRegistryMixin(PharosElement) { return [tableStyles]; } - private _onPageSizeChange(event: Event): void { - this._pageSize = Number((event.composedPath()[0] as HTMLInputElement).value); - } - - private _pageStartNumber(): number { - return (this._currentPage - 1) * this._pageSize + 1; - } - - private _pageEndNumber(): number { - return Math.min(this.rowData.length, this._currentPage * this._pageSize); - } - - private _onPrevPage(): void { - this._currentPage = Math.max(this._currentPage - 1, 0); - this.dispatchEvent(new CustomEvent('pharos-table-prev-page')); - } - - private _onNextPage(): void { - this._currentPage = Math.min(this._currentPage + 1, this.rowData.length); - this.dispatchEvent(new CustomEvent('pharos-table-next-page')); - } - - private _renderTableHeader(): (TemplateResult | undefined)[] { - return this.columns.map((column: ColumnSpecification) => { - if (column.name) { - return html`${column.name}`; - } else { - return html``; - } - }); - } - - private _renderTableRows(): TemplateResult[] { - const currentDisplayingData = this.rowData.slice( - this._pageStartNumber() - 1, - this._pageEndNumber() - ); - return currentDisplayingData.map((row: RowData) => { - const arr: TemplateResult[] = []; - this.columns.forEach((column: ColumnSpecification) => { - arr.push(html`${row[column.field]}`); - }); - return html` - ${arr} - `; - }); - } - - private _renderPageSizeOptions(): TemplateResult[] { - return this.pageSizeOptions.map( - (option: number) => html`` - ); - } - - private _renderPagination(): TemplateResult | typeof nothing { - return this.showPagination - ? html`
-
- Items per page - - page size - ${this._renderPageSizeOptions()} - - (Displaying ${this._pageStartNumber()}-${this._pageEndNumber()} of - ${this.rowData.length}) -
- -
` - : nothing; - } - + // private _onPageSizeChange(event: Event): void { + // this._pageSize = Number((event.composedPath()[0] as HTMLInputElement).value); + // } + + // private _pageStartNumber(): number { + // return (this._currentPage - 1) * this._pageSize + 1; + // } + + // private _pageEndNumber(): number { + // return Math.min(this.rowData.length, this._currentPage * this._pageSize); + // } + + // private _onPrevPage(): void { + // this._currentPage = Math.max(this._currentPage - 1, 0); + // this.dispatchEvent(new CustomEvent('pharos-table-prev-page')); + // } + + // private _onNextPage(): void { + // this._currentPage = Math.min(this._currentPage + 1, this.rowData.length); + // this.dispatchEvent(new CustomEvent('pharos-table-next-page')); + // } + + // private _renderTableHeader(): (TemplateResult | undefined)[] { + // return this.columns.map((column: ColumnSpecification) => { + // if (column.name) { + // return html`${column.name}`; + // } else { + // return html``; + // } + // }); + // } + + // private _renderTableRows(): TemplateResult[] { + // const currentDisplayingData = this.rowData.slice( + // this._pageStartNumber() - 1, + // this._pageEndNumber() + // ); + // return currentDisplayingData.map((row: RowData) => { + // const arr: TemplateResult[] = []; + // this.columns.forEach((column: ColumnSpecification) => { + // arr.push(html`${row[column.field]}`); + // }); + // return html` + // ${arr} + // `; + // }); + // } + + // private _renderPageSizeOptions(): TemplateResult[] { + // return this.pageSizeOptions.map( + // (option: number) => html`` + // ); + // } + + // private _renderPagination(): TemplateResult | typeof nothing { + // return this.showPagination + // ? html`
+ //
+ // Items per page + // + // page size + // ${this._renderPageSizeOptions()} + // + // (Displaying ${this._pageStartNumber()}-${this._pageEndNumber()} of + // ${this.rowData.length}) + //
+ // + //
` + // : nothing; + // } protected override render(): TemplateResult { - return html` - - - - - ${this._renderTableHeader()} - - - - ${this._renderTableRows()} - -
- ${this.caption} -
- ${this._renderPagination()} - `; + // return html` + // + // + // ${this.caption} + // + // + // test + // + // ${this._renderPagination()} + // `; + + return html`
+ +
`; } } diff --git a/packages/pharos/src/components/table/pharos-table.wc.stories.jsx b/packages/pharos/src/components/table/pharos-table.wc.stories.jsx index 8bed7d36b..8af78e3b8 100644 --- a/packages/pharos/src/components/table/pharos-table.wc.stories.jsx +++ b/packages/pharos/src/components/table/pharos-table.wc.stories.jsx @@ -19,7 +19,74 @@ export const Base = { .rowData="${rowData}" .showPagination="${showPagination}" caption="An example table" - /> + > + + + Item + Filename + Expired Date + Created On + University + + + + + 1 + 12345.jpg + 2020-1-1 + 2010-1-1 + University of Michigan + + + 2 + 123456.jpg + 2020-1-1 + 2010-1-1 + University of Michigan + + + 3 + 123456.jpg + 2020-1-1 + 2010-1-1 + University of Michigan + + + 4 + 123456.jpg + 2020-1-1 + 2010-1-1 + University of Michigan + + + 5 + 123456.jpg + 2020-1-1 + 2010-1-1 + University of Michigan + + + + Testing this thing! + + + Round robin + + + + I am a label + + + + + + +
Test
+
+
+
+
+ `, args: { ...defaultArgs, @@ -27,50 +94,50 @@ export const Base = { }, }; -export const WithPagination = { - render: ({ columns, rowData, showPagination }) => html` - - `, - args: { - ...defaultArgs, - showPagination: true, - }, -}; +// export const WithPagination = { +// render: ({ columns, rowData, showPagination }) => html` +// +// `, +// args: { +// ...defaultArgs, +// showPagination: true, +// }, +// }; -export const WithHiddenCaption = { - render: ({ columns, rowData, showPagination }) => html` - - `, - args: { - ...defaultArgs, - showPagination: false, - }, -}; +// export const WithHiddenCaption = { +// render: ({ columns, rowData, showPagination }) => html` +// +// `, +// args: { +// ...defaultArgs, +// showPagination: false, +// }, +// }; -export const WithStickyHeader = { - render: ({ columns, rowData }) => html` - - `, - args: { - ...defaultArgs, - showPagination: true, - }, -}; +// export const WithStickyHeader = { +// render: ({ columns, rowData }) => html` +// +// `, +// args: { +// ...defaultArgs, +// showPagination: true, +// }, +// }; diff --git a/packages/pharos/src/index.ts b/packages/pharos/src/index.ts index 80ff33408..bfaaa3fff 100644 --- a/packages/pharos/src/index.ts +++ b/packages/pharos/src/index.ts @@ -16,6 +16,11 @@ export { PharosDropdownMenuItem } from './components/dropdown-menu/pharos-dropdo export { PharosDropdownMenu } from './components/dropdown-menu/pharos-dropdown-menu'; export { PharosTab } from './components/tabs/pharos-tab'; export { PharosTable } from './components/table/pharos-table'; +export { PharosTableHeader } from './components/table/pharos-table-header'; +export { PharosTableHeaderCell } from './components/table/pharos-table-header-cell'; +export { PharosTableRow } from './components/table/pharos-table-row'; +export { PharosTableCell } from './components/table/pharos-table-cell'; +export { PharosTableBody } from './components/table/pharos-table-body'; export { PharosTabs } from './components/tabs/pharos-tabs'; export { PharosTabPanel } from './components/tabs/pharos-tab-panel'; export { PharosPagination } from './components/pagination/pharos-pagination';