This repository has been archived by the owner on Dec 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Customizable Headers and Footers, fixes #11 #38
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
85f2abe
Rename Header/HeaderCell to ColumnHeaders/ColumnHeaderCell
pottedmeat 6f24cba
Add Header
pottedmeat abbfbdf
Make headers and footers customizable
pottedmeat 0affd91
Add test for custom header/footer that aren’t ColumnHeaders
pottedmeat 72d47b0
Alphebetize imports
pottedmeat 431b827
Group duplicated code and update array type
pottedmeat 0d012db
Merge branch 'master' into feature-headers-footers
pottedmeat 5334c34
Customize cell content, fixes #12 (#37)
pottedmeat 2afd0af
Remove HeaderCell references
pottedmeat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { v, w } from '@dojo/widget-core/d'; | ||
import { DNode } from '@dojo/widget-core/interfaces'; | ||
import { RegistryMixin, RegistryMixinProperties } from '@dojo/widget-core/mixins/Registry'; | ||
import { ThemeableMixin, theme, ThemeableProperties } from '@dojo/widget-core/mixins/Themeable'; | ||
import WidgetBase from '@dojo/widget-core/WidgetBase'; | ||
import ColumnHeaderCell from './ColumnHeaderCell'; | ||
import { HasColumns, HasSortDetails, HasSortEvent } from './interfaces'; | ||
|
||
import * as css from './styles/columnHeaders.m.css'; | ||
import * as tableCss from './styles/shared/table.m.css'; | ||
|
||
export const ColumnHeadersBase = ThemeableMixin(RegistryMixin(WidgetBase)); | ||
|
||
export interface ColumnHeadersProperties extends ThemeableProperties, HasColumns, HasSortDetails, HasSortEvent, RegistryMixinProperties {} | ||
|
||
@theme(tableCss) | ||
@theme(css) | ||
class ColumnHeaders extends ColumnHeadersBase<ColumnHeadersProperties> { | ||
render(): DNode { | ||
const { | ||
columns, | ||
onSortRequest, | ||
registry, | ||
sortDetails, | ||
theme | ||
} = this.properties; | ||
|
||
return v('div', { | ||
classes: this.classes(css.columnHeaders, css.columnHeadersRow), | ||
role: 'row' | ||
}, [ | ||
v('table', { | ||
role: 'presentation', | ||
classes: this.classes(tableCss.table, css.columnHeadersTable) | ||
}, [ | ||
v('tr', columns.map((column) => { | ||
let sortDetail; | ||
for (const detail of sortDetails) { | ||
if (detail.columnId === column.id) { | ||
sortDetail = detail; | ||
break; | ||
} | ||
} | ||
|
||
return w<ColumnHeaderCell>('column-header-cell', { | ||
column, | ||
key: column.id, | ||
onSortRequest, | ||
registry, | ||
sortDetail, | ||
theme | ||
}); | ||
})) | ||
]) | ||
]); | ||
} | ||
} | ||
|
||
export default ColumnHeaders; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,10 @@ import { theme, ThemeableMixin, ThemeableProperties } from '@dojo/widget-core/mi | |
import WidgetBase, { diffProperty } from '@dojo/widget-core/WidgetBase'; | ||
import DataProviderBase from './bases/DataProviderBase'; | ||
import Body from './Body'; | ||
import ColumnHeaders from './ColumnHeaders'; | ||
import Footer from './Footer'; | ||
import GridRegistry, { gridRegistry } from './GridRegistry'; | ||
import Header from './Header'; | ||
import Header, { HeaderType } from './Header'; | ||
import { DataProperties, HasColumns, SortRequestListener } from './interfaces'; | ||
|
||
import * as css from './styles/grid.m.css'; | ||
|
@@ -25,6 +27,8 @@ export const GridBase = ThemeableMixin(RegistryMixin(WidgetBase)); | |
export interface GridProperties extends ThemeableProperties, HasColumns { | ||
registry?: GridRegistry; | ||
dataProvider: DataProviderBase; | ||
footers?: Array<HeaderType | DNode>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. generally we use |
||
headers?: Array<HeaderType | DNode>; | ||
} | ||
|
||
@theme(css) | ||
|
@@ -69,6 +73,8 @@ class Grid extends GridBase<GridProperties> { | |
_sortRequestListener: onSortRequest, | ||
properties: { | ||
columns, | ||
footers = [], | ||
headers = [ HeaderType.COLUMN_HEADERS ], | ||
theme, | ||
registry = gridRegistry | ||
} | ||
|
@@ -79,18 +85,35 @@ class Grid extends GridBase<GridProperties> { | |
role: 'grid' | ||
}, [ | ||
w<Header>('header', { | ||
columns, | ||
registry, | ||
sortDetails, | ||
theme, | ||
onSortRequest | ||
}), | ||
theme | ||
}, <DNode[]> headers.map((child) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems odd we need a cast here. Also this logic is quite hard to follow in line and is duplicated below. This should probably be broken into a function that is easier to grok and maintain. |
||
return (child === HeaderType.COLUMN_HEADERS) ? w<ColumnHeaders>('column-headers', { | ||
columns, | ||
registry, | ||
sortDetails, | ||
theme, | ||
onSortRequest | ||
}) : child; | ||
})), | ||
w<Body>('body', { | ||
columns, | ||
items, | ||
registry, | ||
theme | ||
}) | ||
}), | ||
w<Footer>('footer', { | ||
registry, | ||
theme | ||
}, <DNode[]> footers.map((child) => { | ||
return (child === HeaderType.COLUMN_HEADERS) ? w<ColumnHeaders>('column-headers', { | ||
columns, | ||
registry, | ||
sortDetails, | ||
theme, | ||
onSortRequest | ||
}) : child; | ||
})) | ||
]); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/styles/headerCell.m.css → src/styles/columnHeaderCell.m.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.headerCell { | ||
.columnHeaderCell { | ||
position: relative; | ||
} | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
src/styles/headerCell.m.css.d.ts → src/styles/columnHeaderCell.m.css.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.columnHeaders { | ||
} | ||
|
||
.columnHeadersRow { | ||
} | ||
|
||
.columnHeadersTable { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const columnHeaders: string; | ||
export const columnHeadersRow: string; | ||
export const columnHeadersTable: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,3 @@ | |
.header { | ||
background-color: var(--header-background-color); | ||
} | ||
|
||
.headerRow { | ||
} | ||
|
||
.headerTable { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export const header: string; | ||
export const headerRow: string; | ||
export const headerTable: string; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theme
should be first