Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accessibility-with-fixed-header: mocked fixed header with CSS and moved all the three components into single table #490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions addon/components/columns/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ const Column = Component.extend(DraggableColumnMixin, {
*/
sortIcons: null,

fix: false,

/**
* @property sortIconProperty
* @type {String|null}
Expand Down
4 changes: 2 additions & 2 deletions addon/components/lt-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@ export default Component.extend({
},

_setupVirtualScrollbar() {
let { fixedHeader, fixedFooter } = this.get('sharedOptions');
this.set('useVirtualScrollbar', fixedHeader || fixedFooter);
let { fixedFooter } = this.get('sharedOptions');
this.set('useVirtualScrollbar', fixedFooter);
},

onRowsChange: observer('rows.[]', function() {
Expand Down
56 changes: 56 additions & 0 deletions addon/styles/addon.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,59 @@
.ember-light-table .lt-row.is-selectable {
cursor: pointer;
}


/*Following is the custom CSS to mock fixed header layout*/

.light-table-wrapper {
padding-top: 2.5rem;
/*Leave room for the header area*/
}

.light-table-wrapper.scrollable {
position: relative;
height: 100%;
}

.light-table-wrapper .scroll-area {
overflow: auto;
/*Make this box scroll*/
height: 100%;
border-bottom: 0.0625rem solid #ECEFF1;
border-top: 0.0625rem solid #ECEFF1;
}

.light-table-wrapper .fixable .fix {
position: absolute;
/*Escape the scrolling context*/
}

.light-table-wrapper thead {
border: 0;
}

.light-table-wrapper table {
table-layout: fixed;
}

.light-table-wrapper .fixable .fix {
/*Move above the scroll area into the fake header*/
top: 0;
/*Must absolutely position the top to avoid bugs in Firefox and IE6*/
height: 2.5rem;
line-height: 2.5rem;
}

.light-table-wrapper .fixable .lt-column {
position: initial;
padding-top: 0;
padding-bottom: 0;
}

.light-table-wrapper tr.fixable:first-child {
height: auto !important;
}

.light-table-wrapper .ember-light-table {
overflow: initial !important;
}
18 changes: 10 additions & 8 deletions addon/templates/components/columns/base.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{{#if column.component}}
{{component column.component column=column table=table tableActions=tableActions extra=extra sortIcons=sortIcons}}
{{else}}
{{label}}
{{#if sortIconProperty}}
<i class="lt-sort-icon {{get sortIcons sortIconProperty}}"></i>
{{/if}}
{{/if}}
<div class="{{if fix "fix"}}">
{{#if column.component}}
{{component column.component column=column table=table tableActions=tableActions extra=extra sortIcons=sortIcons}}
{{else}}
{{label}}
{{#if sortIconProperty}}
<i class="lt-sort-icon {{get sortIcons sortIconProperty}}"></i>
{{/if}}
{{/if}}
</div>

{{#if isResizable}}
{{lt-column-resizer
Expand Down
58 changes: 32 additions & 26 deletions addon/templates/components/light-table.hbs
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
{{yield (hash
head=(component 'lt-head'
tableId=elementId
table=table
tableActions=tableActions
extra=extra
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
body=(component 'lt-body'
tableId=elementId
table=table
tableActions=tableActions
extra=extra
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
foot=(component 'lt-foot'
tableId=elementId
table=table
tableActions=tableActions
extra=extra
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
)}}
<div class="light-table-wrapper scrollable">
<div class="scroll-area">
<table class={{tableClassNames}}>
{{yield (hash
head=(component 'lt-head'
tableId=elementId
table=table
tableActions=tableActions
extra=extra
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
body=(component 'lt-body'
tableId=elementId
table=table
tableActions=tableActions
extra=extra
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
foot=(component 'lt-foot'
tableId=elementId
table=table
tableActions=tableActions
extra=extra
tableClassNames=tableClassNames
sharedOptions=sharedOptions
)
)}}
</table>
</div>
</div>
6 changes: 2 additions & 4 deletions addon/templates/components/lt-body.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
scrollTo=targetScrollOffset
onScrollY=(action 'onScroll')
}}
<div id={{concat tableId '_inline_head'}} class="lt-inline lt-head"></div>
<thead id={{concat tableId '_inline_head'}} class="lt-inline lt-head"></thead>

<table class={{tableClassNames}}>
<tbody class="lt-body">
{{#if enableScaffolding}}
<tr class="lt-scaffolding-row">
Expand Down Expand Up @@ -52,12 +51,11 @@
) rows}}
{{/if}}
</tbody>
</table>

{{#if onScrolledToBottom}}
{{lt.infinity rows=rows onScrolledToBottom=onScrolledToBottom scrollBuffer=scrollBuffer}}
{{/if}}

<div id={{concat tableId '_inline_foot'}} class="lt-inline lt-foot"></div>
<tfoot id={{concat tableId '_inline_foot'}} class="lt-inline lt-foot"></tfoot>
{{/lt-scrollable}}
{{/with}}
6 changes: 1 addition & 5 deletions addon/templates/components/lt-foot.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{#ember-wormhole to=(concat tableId '_inline_foot') renderInPlace=renderInPlace}}
<table class={{tableClassNames}}>
<tfoot class="lt-foot">
{{#ember-wormhole to=(concat tableId '_inline_foot')}}
{{!-- Scaffolding is needed here to allow use of colspan in the footer --}}
<tr class="lt-scaffolding-row">
{{#each columns as |column|}}
Expand All @@ -26,6 +24,4 @@
{{/each}}
</tr>
{{/if}}
</tfoot>
</table>
{{/ember-wormhole}}
9 changes: 3 additions & 6 deletions addon/templates/components/lt-head.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{#ember-wormhole to=(concat tableId '_inline_head') renderInPlace=renderInPlace}}
<table class={{tableClassNames}}>
<thead class="lt-head">
{{#ember-wormhole to=(concat tableId '_inline_head')}}
{{#if hasBlock}}
{{yield columnGroups subColumns}}
{{else}}
Expand All @@ -16,14 +14,15 @@
</tr>
{{/if}}

<tr>
<tr class="{{if fixed "fixable" "" }}">
{{#each columnGroups as |column|}}
{{component (concat 'light-table/columns/' column.type) column
table=table
tableActions=tableActions
extra=extra
sortIcons=sortIcons
resizeOnDrag=resizeOnDrag
fix = fixed
click=(action 'onColumnClick' column)
doubleClick=(action 'onColumnDoubleClick' column)
onColumnResized=(action 'onColumnResized')
Expand All @@ -50,6 +49,4 @@
{{/each}}
</tr>
{{/if}}
</thead>
</table>
{{/ember-wormhole}}