diff --git a/addons/rose/addon/components/rose/table/index.hbs b/addons/rose/addon/components/rose/table/index.hbs
index 655e7dbd4..643a14cfa 100644
--- a/addons/rose/addon/components/rose/table/index.hbs
+++ b/addons/rose/addon/components/rose/table/index.hbs
@@ -1,4 +1,4 @@
-
+
{{#if @caption}}
{{@caption}}
{{/if}}
diff --git a/addons/rose/addon/components/rose/table/index.stories.mdx b/addons/rose/addon/components/rose/table/index.stories.mdx
index a720bd877..444419be4 100644
--- a/addons/rose/addon/components/rose/table/index.stories.mdx
+++ b/addons/rose/addon/components/rose/table/index.stories.mdx
@@ -1,27 +1,42 @@
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
import { hbs } from 'ember-cli-htmlbars';
+import { boolean, select } from '@storybook/addon-knobs';
# Table
-A table component to display data in structure of rows and columns. It supports `header`, `body` and `footer` optional definitions. Each definition allows for a table `row` to be defined with either a `cell` or `headerCell` table element.
+A table component to display data in structure of rows and columns. It supports `header`, `body` and `footer` optional definitions. Each definition allows for a table `row` to be defined with either a `cell` or `headerCell` table element. Rows can be visually hidden, and cells can be shrinked to its content with, and center/right cell alignment is supported.
-```htmlbars
-
+Cell shrink should be applied to all the cells in a row. Otherwise the bigger cell with shrink applied will determinate the width of the row.
+
+```html
+
-
+
Address
Host Set
Name
- Description
+ Description
1.1.1.1
host-set-1, host-set-2
- optional name
+ optional name
+ description
+
+
+ 1.1.1.1
+ host-set-2
+ optional name
+ description
+
+
+ 1.1.1.1
+ host-set-1
+ optional name
description
@@ -36,22 +51,34 @@ A table component to display data in structure of rows and columns. It supports
{{
template: hbs`
-
+
-
- Address
- Host Set
- Name
- Description
+
+ Address
+ Host Set
+ Name
+ Description
- 1.1.1.1
+ 1.1.1.1
host-set-1, host-set-2
- optional name
+ optional name
description
+
+ 1.1.1.1
+ host-set-2
+ optional name
+ description
+
+
+ 1.1.1.1
+ host-set-1
+ optional name
+ description
+
@@ -60,6 +87,102 @@ A table component to display data in structure of rows and columns. It supports
`,
- context: {}
+ context: {
+ hideHeaderRow: boolean('hideHeaderRow', false),
+ cellShrink: boolean('cellShrink', false),
+ style: select(
+ 'style',
+ {
+ 'default': '',
+ 'condensed': 'condensed'
+ }
+ ),
+ cellAlignmentCenter: boolean('cellAlignmentCenter', false),
+ cellAlignmentRight: boolean('cellAlignmentRight', false),
+ },
+ }}
+
+
+
+ {{
+ template: hbs`
+
+
+
+ Key
+ Value
+
+
+
+
+ Key
+
+
+
+
+
+
+ Remove
+
+
+
+ Key
+
+
+
+ Choose an option
+ Value 1
+ Value 2
+ Value 3
+
+
+
+
+ Add
+
+
+
+ Key
+
+
+
+
+
+
+ Add
+
+
+
+ Key
+
+
+
+
+ Add
+
+
+
+
+
+ Footer
+
+
+
+ `,
+ context: {
+ style: select(
+ 'style',
+ {
+ 'condensed': 'condensed',
+ 'default': ''
+ }
+ )
+ }
}}
diff --git a/addons/rose/addon/components/rose/table/row/cell/index.hbs b/addons/rose/addon/components/rose/table/row/cell/index.hbs
new file mode 100644
index 000000000..fb5c4b157
--- /dev/null
+++ b/addons/rose/addon/components/rose/table/row/cell/index.hbs
@@ -0,0 +1 @@
+{{yield}}
\ No newline at end of file
diff --git a/addons/rose/addon/components/rose/table/row/cell/index.js b/addons/rose/addon/components/rose/table/row/cell/index.js
new file mode 100644
index 000000000..588c072cf
--- /dev/null
+++ b/addons/rose/addon/components/rose/table/row/cell/index.js
@@ -0,0 +1,28 @@
+import Component from '@ember/component';
+import layout from './index';
+import { computed } from '@ember/object';
+
+export default Component.extend({
+ layout,
+ tagName: 'td',
+ classNameBindings: ['cellTypeStyle', 'cellShrink', 'cellAlignmentStyle'],
+ cellTypeStyle: computed(function () {
+ return this.tagName.match('th')
+ ? `rose-table-header-cell`
+ : 'rose-table-cell';
+ }),
+ cellShrink: computed(function () {
+ if (this.shrink) {
+ return 'rose-table-cell-shrink'
+ }
+ }),
+ cellAlignmentStyle: computed(function () {
+ if (this.alignRight) {
+ return 'align-right';
+ }
+
+ if (this.alignCenter) {
+ return 'align-center';
+ }
+ })
+});
diff --git a/addons/rose/addon/components/rose/table/row/index.hbs b/addons/rose/addon/components/rose/table/row/index.hbs
index e5bad550e..65fb90e81 100644
--- a/addons/rose/addon/components/rose/table/row/index.hbs
+++ b/addons/rose/addon/components/rose/table/row/index.hbs
@@ -1,12 +1,6 @@
-
+
{{yield (hash
- cell=(component 'rose/anonymous'
- tagName='td'
- class='rose-table-cell'
- )
- headerCell=(component 'rose/anonymous'
- tagName='th'
- class='rose-table-header-cell'
- )
+ cell=(component 'rose/table/row/cell')
+ headerCell=(component 'rose/table/row/cell' tagName='th')
)}}
diff --git a/addons/rose/addon/styles/rose/components/table/_table.scss b/addons/rose/addon/styles/rose/components/table/_table.scss
index 0c581393e..f9b7b9daf 100644
--- a/addons/rose/addon/styles/rose/components/table/_table.scss
+++ b/addons/rose/addon/styles/rose/components/table/_table.scss
@@ -10,9 +10,20 @@
text-align: left;
}
+ // This styles are add to stop the input to apply extra margin (default on forms)
+ .rose-form-input-field,
+ .rose-form-select,
+ .rose-form-input {
+ margin: 0;
+ width: 100%;
+ }
+
.rose-table-cell,
.rose-table-header-cell {
vertical-align: middle;
+
+ &.align-right { text-align: right; }
+ &.align-center { text-align: center; }
}
.rose-table-header-cell {
@@ -35,7 +46,28 @@
}
}
+ .rose-table-cell-shrink {
+ width: 1%;
+ white-space: nowrap;
+ }
+
[class*='rose-button'] {
margin-bottom: 0;
}
+
+ &.rose-table-condensed {
+ .rose-table-cell {
+ @include type.type(s);
+ $lineHeight: 36 / 14;
+ line-height: $lineHeight;
+ padding: (sizing.rems(s) / 2) sizing.rems(s);
+ }
+
+ }
+
+ .rose-table-row-visually-hidden {
+ position: absolute;
+ top: -9999rem;
+ left: -9999rem;
+ }
}
diff --git a/addons/rose/app/components/rose/table/row/cell.js b/addons/rose/app/components/rose/table/row/cell.js
new file mode 100644
index 000000000..50e7502b4
--- /dev/null
+++ b/addons/rose/app/components/rose/table/row/cell.js
@@ -0,0 +1 @@
+export { default } from 'rose/components/rose/table/row/cell';
diff --git a/addons/rose/tests/dummy/app/templates/index.hbs b/addons/rose/tests/dummy/app/templates/index.hbs
index 8bb8b116d..e82d02286 100644
--- a/addons/rose/tests/dummy/app/templates/index.hbs
+++ b/addons/rose/tests/dummy/app/templates/index.hbs
@@ -1,93 +1,196 @@
-
-
+Condensed Table
+
+
+
+ Address
+ Host Set
+ Name
+ Description
+
+
+
+
+ 1.1.1.1
+ host-set-1, host-set-2
+ optional name
+ description
+
+
+
+
+ Footer
+
+
+
-
-
- Menu item
- Menu item - danger
-
- Button menu item
-
+Condensed Table with Shrink Cells
+
+
+
+ Address
+ Host Set
+ Name
+ Description
+
+
+
+
+ 1.1.1.1
+ host-set-1, host-set-2
+
+ Remove
+
+ description
+
+
+
+
+ Footer
+
+
+
- Section
- Section
-
+Condensed Table with Right and Center aligned cells
+
+
+
+ Address
+ Host Set
+ Name
+ Description
+
+
+
+
+ 1.1.1.1
+ host-set-1, host-set-2
+ optional name
+ description
+
+
+
+
+ Footer
+
+
+
-
-
- Menu item
- Menu item - danger
- Button - default
-
- Button - danger
-
-
-
+Condensed Table Key/Value Lookalike (edit mode)
+
+
+
+ Key
+ Value
+
+
+
+
+ Key
+
+
+
+
+
+
+ Remove
+
+
+
+ Key
+
+
+
+ Choose an option
+ Value 1
+ Value 2
+ Value 3
+
+
+
+
+ Add
+
+
+
+ Key
+
+
+
+
+
+
+ Add
+
+
+
+ Key
+
+
+
+
+ Add
+
+
+
+
+
+ Footer
+
+
+
-
- Menu item
- Menu item - danger
-
+Condensed Table With Visually Hidden Header & Footer
+
+
+
+ Address
+ Host Set
+ Name
+ Description
+
+
+
+
+ 1.1.1.1
+ host-set-1, host-set-2
+ optional name
+ description
+
+
+
+
+ Footer
+
+
+
- Button menu item
- Button - danger
-
-
-
- Menu item
-
-
-
-
- Menu item
- Button menu item
-
-
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
-
- <:header>
- Authentication Pending
-
- <:body>
- Complete authentication in the newly-opened window.
- Don't see the new window? Try again.
- Cancel
-
-
+Table
+
+
+
+ Address
+ Host Set
+ Name
+ Description
+
+
+
+
+ 1.1.1.1
+ host-set-1, host-set-2
+ optional name
+ description
+
+
+
+
+ Footer
+
+
+
\ No newline at end of file
diff --git a/addons/rose/tests/integration/components/rose/table-test.js b/addons/rose/tests/integration/components/rose/table-test.js
index 06f2a5b8c..aa78b58eb 100644
--- a/addons/rose/tests/integration/components/rose/table-test.js
+++ b/addons/rose/tests/integration/components/rose/table-test.js
@@ -43,4 +43,9 @@ module('Integration | Component | rose/table', function (hooks) {
`);
assert.ok(find('tfoot'));
});
+
+ test('it supports a style class', async function (assert) {
+ await render(hbs``);
+ assert.ok(find('.rose-table-condensed'));
+ });
});
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 94c57cd08..2a0c1f758 100644
--- a/addons/rose/tests/integration/components/rose/table/row-test.js
+++ b/addons/rose/tests/integration/components/rose/table/row-test.js
@@ -7,17 +7,20 @@ module('Integration | Component | rose/table/row', function (hooks) {
setupRenderingTest(hooks);
test('it renders', async function (assert) {
+ assert.expect(2);
await render(hbs``);
assert.ok(find('tr'));
assert.ok(find('.rose-table-row'));
});
test('it renders with attributes', async function (assert) {
+ assert.expect(1);
await render(hbs``);
assert.ok(find('#row'));
});
test('it renders a cell', async function (assert) {
+ assert.expect(2);
await render(hbs`
`);
@@ -26,10 +29,17 @@ module('Integration | Component | rose/table/row', function (hooks) {
});
test('it renders a header cell', async function (assert) {
+ assert.expect(2);
await render(hbs`
`);
assert.ok(find('th'));
assert.ok(find('.rose-table-header-cell'));
});
+
+ test('it can be hidden', async function (assert) {
+ assert.expect(1);
+ await render(hbs``);
+ assert.ok(find('.rose-table-row-visually-hidden'));
+ });
});
diff --git a/addons/rose/tests/integration/components/rose/table/row/cell-test.js b/addons/rose/tests/integration/components/rose/table/row/cell-test.js
new file mode 100644
index 000000000..4b8c3332d
--- /dev/null
+++ b/addons/rose/tests/integration/components/rose/table/row/cell-test.js
@@ -0,0 +1,76 @@
+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/row/cell', function (hooks) {
+ setupRenderingTest(hooks);
+
+ test('it renders', async function (assert) {
+ assert.expect(2);
+ await render(hbs`
+ content
+ `);
+ assert.ok(find('td'));
+ assert.equal(find('.rose-table-cell').textContent.trim(), 'content');
+ });
+
+ test('it renders with attributes', async function (assert) {
+ assert.expect(1);
+ await render(hbs``);
+ assert.ok(find('#cell'));
+ });
+
+ test('it renders as header cell', async function (assert) {
+ assert.expect(4);
+ await render(hbs``);
+ assert.ok(find('th'));
+ assert.ok(find('.rose-table-header-cell'));
+ assert.notOk(find('td'));
+ assert.notOk(find('.rose-table-cell'));
+ });
+
+ test('it adds shrink style class', async function (assert) {
+ assert.expect(1);
+ await render(hbs``);
+ assert.ok(find('.rose-table-cell-shrink'));
+ });
+
+ test('it does not add expand style class in default cells', async function (assert) {
+ assert.expect(1);
+ await render(hbs``);
+ assert.notOk(find('.rose-table-cell-shrink'));
+ });
+
+ test('it renders with align center in a header cell', async function (assert) {
+ assert.expect(2);
+ await render(
+ hbs``
+ );
+ assert.ok(find('.rose-table-header-cell'));
+ assert.ok(find('.align-center'));
+ });
+
+ test('it renders with align center in a body', async function (assert) {
+ assert.expect(2);
+ await render(hbs``);
+ assert.ok(find('.rose-table-cell'));
+ assert.ok(find('.align-center'));
+ });
+
+ test('it renders with align right in a header cell', async function (assert) {
+ assert.expect(2);
+ await render(
+ hbs``
+ );
+ assert.ok(find('.rose-table-header-cell'));
+ assert.ok(find('.align-right'));
+ });
+
+ test('it renders with align right', async function (assert) {
+ assert.expect(2);
+ await render(hbs``);
+ assert.ok(find('.rose-table-cell'));
+ assert.ok(find('.align-right'));
+ });
+});