From 704bc263c8aa39753bef31ba530511933369e16d Mon Sep 17 00:00:00 2001 From: Susmitha Girumala Date: Tue, 11 Aug 2020 18:27:31 -0400 Subject: [PATCH] chore: Add table section component Remove table header, footer, and body components as section component is used to build them. --- .../rose/addon/components/rose/table/body.js | 10 ------- .../addon/components/rose/table/footer.js | 10 ------- .../addon/components/rose/table/header.js | 10 ------- .../rose/addon/components/rose/table/row.js | 3 ++- .../addon/components/rose/table/section.js | 11 ++++++++ .../addon/templates/components/rose/table.hbs | 15 ++++++++--- .../templates/components/rose/table/body.hbs | 5 ---- .../components/rose/table/footer.hbs | 5 ---- .../components/rose/table/header.hbs | 5 ---- .../templates/components/rose/table/row.hbs | 23 +++++----------- .../components/rose/table/section.hbs | 6 +++++ addons/rose/app/components/rose/table/body.js | 1 - .../rose/app/components/rose/table/footer.js | 1 - .../rose/app/components/rose/table/header.js | 1 - .../rose/app/components/rose/table/section.js | 1 + .../rose/tests/dummy/app/templates/index.hbs | 2 +- .../components/rose/table/body-test.js | 26 ------------------ .../components/rose/table/footer-test.js | 26 ------------------ .../components/rose/table/header-test.js | 26 ------------------ .../components/rose/table/row-test.js | 19 +++---------- .../components/rose/table/section-test.js | 27 +++++++++++++++++++ 21 files changed, 70 insertions(+), 163 deletions(-) delete mode 100644 addons/rose/addon/components/rose/table/body.js delete mode 100644 addons/rose/addon/components/rose/table/footer.js delete mode 100644 addons/rose/addon/components/rose/table/header.js create mode 100644 addons/rose/addon/components/rose/table/section.js delete mode 100644 addons/rose/addon/templates/components/rose/table/body.hbs delete mode 100644 addons/rose/addon/templates/components/rose/table/footer.hbs delete mode 100644 addons/rose/addon/templates/components/rose/table/header.hbs create mode 100644 addons/rose/addon/templates/components/rose/table/section.hbs delete mode 100644 addons/rose/app/components/rose/table/body.js delete mode 100644 addons/rose/app/components/rose/table/footer.js delete mode 100644 addons/rose/app/components/rose/table/header.js create mode 100644 addons/rose/app/components/rose/table/section.js delete mode 100644 addons/rose/tests/integration/components/rose/table/body-test.js delete mode 100644 addons/rose/tests/integration/components/rose/table/footer-test.js delete mode 100644 addons/rose/tests/integration/components/rose/table/header-test.js create mode 100644 addons/rose/tests/integration/components/rose/table/section-test.js diff --git a/addons/rose/addon/components/rose/table/body.js b/addons/rose/addon/components/rose/table/body.js deleted file mode 100644 index eebd02b73..000000000 --- a/addons/rose/addon/components/rose/table/body.js +++ /dev/null @@ -1,10 +0,0 @@ -import Component from '@ember/component'; -import layout from '../../../templates/components/rose/table/body'; - -/** - * A table body component that uses tbody table element. - */ -export default Component.extend({ - layout, - tagName: '', -}); diff --git a/addons/rose/addon/components/rose/table/footer.js b/addons/rose/addon/components/rose/table/footer.js deleted file mode 100644 index 3e1ab08bb..000000000 --- a/addons/rose/addon/components/rose/table/footer.js +++ /dev/null @@ -1,10 +0,0 @@ -import Component from '@ember/component'; -import layout from '../../../templates/components/rose/table/footer'; - -/** - * A table footer component that uses tfoot table element. - */ -export default Component.extend({ - layout, - tagName: '', -}); diff --git a/addons/rose/addon/components/rose/table/header.js b/addons/rose/addon/components/rose/table/header.js deleted file mode 100644 index c762042d4..000000000 --- a/addons/rose/addon/components/rose/table/header.js +++ /dev/null @@ -1,10 +0,0 @@ -import Component from '@ember/component'; -import layout from '../../../templates/components/rose/table/header'; - -/** - * A table header component that uses thead table element. - */ -export default Component.extend({ - layout, - tagName: '', -}); diff --git a/addons/rose/addon/components/rose/table/row.js b/addons/rose/addon/components/rose/table/row.js index 58be69420..bf4bc17bf 100644 --- a/addons/rose/addon/components/rose/table/row.js +++ b/addons/rose/addon/components/rose/table/row.js @@ -2,7 +2,8 @@ import Component from '@ember/component'; import layout from '../../../templates/components/rose/table/row'; /** - * A table row component that uses tr table element. + * A table row component that uses tr table element and + * configures a table cell element. */ export default Component.extend({ layout, diff --git a/addons/rose/addon/components/rose/table/section.js b/addons/rose/addon/components/rose/table/section.js new file mode 100644 index 000000000..503ed969b --- /dev/null +++ b/addons/rose/addon/components/rose/table/section.js @@ -0,0 +1,11 @@ +import Component from '@ember/component'; +import layout from '../../../templates/components/rose/table/section'; + +/** + * A table section component that configures a row component. + * Section can be: thead, tbody, or tfoot table elements. + */ +export default Component.extend({ + layout, + tagName: '', +}); diff --git a/addons/rose/addon/templates/components/rose/table.hbs b/addons/rose/addon/templates/components/rose/table.hbs index 580885405..ae0208227 100644 --- a/addons/rose/addon/templates/components/rose/table.hbs +++ b/addons/rose/addon/templates/components/rose/table.hbs @@ -4,8 +4,17 @@ {{/if}} {{yield (hash - header=(component 'rose/table/header') - body=(component 'rose/table/body') - footer=(component 'rose/table/footer') + header=(component 'rose/table/section' + tagName='thead' + cellTagName='th' + classNames='rose-table-header') + body=(component 'rose/table/section' + tagName='tbody' + cellTagName='td' + classNames='rose-table-body') + footer=(component 'rose/table/section' + tagName='tfoot' + cellTagName='td' + classNames='rose-table-foot') )}} diff --git a/addons/rose/addon/templates/components/rose/table/body.hbs b/addons/rose/addon/templates/components/rose/table/body.hbs deleted file mode 100644 index f82c64d04..000000000 --- a/addons/rose/addon/templates/components/rose/table/body.hbs +++ /dev/null @@ -1,5 +0,0 @@ - - {{yield (hash - row=(component 'rose/table/row') - )}} - diff --git a/addons/rose/addon/templates/components/rose/table/footer.hbs b/addons/rose/addon/templates/components/rose/table/footer.hbs deleted file mode 100644 index 560a1ff72..000000000 --- a/addons/rose/addon/templates/components/rose/table/footer.hbs +++ /dev/null @@ -1,5 +0,0 @@ - - {{yield (hash - row=(component 'rose/table/row') - )}} - diff --git a/addons/rose/addon/templates/components/rose/table/header.hbs b/addons/rose/addon/templates/components/rose/table/header.hbs deleted file mode 100644 index 13344bc99..000000000 --- a/addons/rose/addon/templates/components/rose/table/header.hbs +++ /dev/null @@ -1,5 +0,0 @@ - - {{yield (hash - row=(component 'rose/table/row' header=true) - )}} - diff --git a/addons/rose/addon/templates/components/rose/table/row.hbs b/addons/rose/addon/templates/components/rose/table/row.hbs index 5bfb9f587..4ed16dac0 100644 --- a/addons/rose/addon/templates/components/rose/table/row.hbs +++ b/addons/rose/addon/templates/components/rose/table/row.hbs @@ -1,17 +1,6 @@ - - {{#if @header}} - {{yield (hash - cell=(component 'rose/anonymous' - tagName='th' - classNames='rose-table-cell rose-table-header-cell' - ) - )}} - {{else}} - {{yield (hash - cell=(component 'rose/anonymous' - tagName='td' - classNames='rose-table-cell' - ) - )}} - {{/if}} - +{{yield (hash + cell=(component 'rose/anonymous' + tagName=@cellTagName + class='rose-table-cell' + ) +)}} diff --git a/addons/rose/addon/templates/components/rose/table/section.hbs b/addons/rose/addon/templates/components/rose/table/section.hbs new file mode 100644 index 000000000..b1b8b1d65 --- /dev/null +++ b/addons/rose/addon/templates/components/rose/table/section.hbs @@ -0,0 +1,6 @@ +{{yield (hash + row=(component 'rose/table/row' + tagName='tr' + cellTagName=@cellTagName + class='rose-table-row') +)}} \ No newline at end of file diff --git a/addons/rose/app/components/rose/table/body.js b/addons/rose/app/components/rose/table/body.js deleted file mode 100644 index bf58d0690..000000000 --- a/addons/rose/app/components/rose/table/body.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'rose/components/rose/table/body'; diff --git a/addons/rose/app/components/rose/table/footer.js b/addons/rose/app/components/rose/table/footer.js deleted file mode 100644 index 8fedb5800..000000000 --- a/addons/rose/app/components/rose/table/footer.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'rose/components/rose/table/footer'; diff --git a/addons/rose/app/components/rose/table/header.js b/addons/rose/app/components/rose/table/header.js deleted file mode 100644 index c0a585fe7..000000000 --- a/addons/rose/app/components/rose/table/header.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from 'rose/components/rose/table/header'; diff --git a/addons/rose/app/components/rose/table/section.js b/addons/rose/app/components/rose/table/section.js new file mode 100644 index 000000000..a1f01158a --- /dev/null +++ b/addons/rose/app/components/rose/table/section.js @@ -0,0 +1 @@ +export { default } from 'rose/components/rose/table/section'; \ No newline at end of file diff --git a/addons/rose/tests/dummy/app/templates/index.hbs b/addons/rose/tests/dummy/app/templates/index.hbs index 3554ea5f2..2960a10fc 100644 --- a/addons/rose/tests/dummy/app/templates/index.hbs +++ b/addons/rose/tests/dummy/app/templates/index.hbs @@ -20,4 +20,4 @@ Footer - + \ No newline at end of file diff --git a/addons/rose/tests/integration/components/rose/table/body-test.js b/addons/rose/tests/integration/components/rose/table/body-test.js deleted file mode 100644 index c427d17b3..000000000 --- a/addons/rose/tests/integration/components/rose/table/body-test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render, find } from '@ember/test-helpers'; -import hbs from 'htmlbars-inline-precompile'; - -module('Integration | Component | rose/table/body', function (hooks) { - setupRenderingTest(hooks); - - test('it renders', async function (assert) { - await render(hbs``); - assert.ok(find('tbody')); - assert.ok(find('.rose-table-body')); - }); - - test('it renders with attributes', async function (assert) { - await render(hbs``); - assert.ok(find('#body')); - }); - - test('it renders a row', async function (assert) { - await render(hbs` - - `); - assert.ok(find('tr')); - }); -}); diff --git a/addons/rose/tests/integration/components/rose/table/footer-test.js b/addons/rose/tests/integration/components/rose/table/footer-test.js deleted file mode 100644 index 235e4e573..000000000 --- a/addons/rose/tests/integration/components/rose/table/footer-test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render, find } from '@ember/test-helpers'; -import hbs from 'htmlbars-inline-precompile'; - -module('Integration | Component | rose/table/footer', function (hooks) { - setupRenderingTest(hooks); - - test('it renders', async function (assert) { - await render(hbs``); - assert.ok(find('tfoot')); - assert.ok(find('.rose-table-footer')); - }); - - test('it renders with attributes', async function (assert) { - await render(hbs``); - assert.ok(find('#footer')); - }); - - test('it renders with row', async function (assert) { - await render(hbs` - - `); - assert.ok(find('tr')); - }); -}); diff --git a/addons/rose/tests/integration/components/rose/table/header-test.js b/addons/rose/tests/integration/components/rose/table/header-test.js deleted file mode 100644 index 43862929f..000000000 --- a/addons/rose/tests/integration/components/rose/table/header-test.js +++ /dev/null @@ -1,26 +0,0 @@ -import { module, test } from 'qunit'; -import { setupRenderingTest } from 'ember-qunit'; -import { render, find } from '@ember/test-helpers'; -import hbs from 'htmlbars-inline-precompile'; - -module('Integration | Component | rose/table/header', function (hooks) { - setupRenderingTest(hooks); - - test('it renders', async function (assert) { - await render(hbs``); - assert.ok(find('thead')); - assert.ok(find('.rose-table-header')); - }); - - test('it renders with attributes', async function (assert) { - await render(hbs``); - assert.ok(find('#header')); - }); - - test('it renders with row', async function (assert) { - await render(hbs` - - `); - assert.ok(find('tr')); - }); -}); diff --git a/addons/rose/tests/integration/components/rose/table/row-test.js b/addons/rose/tests/integration/components/rose/table/row-test.js index bd9268c70..96cf77369 100644 --- a/addons/rose/tests/integration/components/rose/table/row-test.js +++ b/addons/rose/tests/integration/components/rose/table/row-test.js @@ -7,31 +7,20 @@ module('Integration | Component | rose/table/row', function (hooks) { setupRenderingTest(hooks); test('it renders', async function (assert) { - await render(hbs``); - assert.ok(find('tr')); - assert.ok(find('.rose-table-row')); + await render(hbs``); + assert.ok(find('tag')); }); test('it renders with attributes', async function (assert) { - await render(hbs``); + await render(hbs``); assert.ok(find('#row')); }); test('it renders a cell', async function (assert) { - await render(hbs` + await render(hbs` `); assert.ok(find('td')); assert.ok(find('.rose-table-cell')); }); - - test('it renders a header cell', async function (assert) { - await render(hbs` - - `); - assert.ok(find('th')); - assert.notOk(find('td')); - assert.ok(find('.rose-table-cell')); - assert.ok(find('.rose-table-header-cell')); - }); }); diff --git a/addons/rose/tests/integration/components/rose/table/section-test.js b/addons/rose/tests/integration/components/rose/table/section-test.js new file mode 100644 index 000000000..5d91cf920 --- /dev/null +++ b/addons/rose/tests/integration/components/rose/table/section-test.js @@ -0,0 +1,27 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render, find } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +module('Integration | Component | rose/table/section', function(hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + await render(hbs``); + assert.ok(find('tag')); + assert.ok(find('.tag-class')); + }); + + test('it renders with attributes', async function (assert) { + await render(hbs``); + assert.ok(find('#section')); + }); + + test('it renders a row', async function (assert) { + await render(hbs` + + `); + assert.ok(find('tr')); + assert.ok(find('.rose-table-row')); + }); +});