Unverified Commit 1898a88e authored by Marcos Iglesias's avatar Marcos Iglesias Committed by GitHub

Padding on table and limits on description showing (#688)

Signed-off-by: 's avatarMarcos Iglesias Valle <golodhros@gmail.com>
parent 69ce3643
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
$resource-header-height: 84px; $resource-header-height: 84px;
$aside-separation-space: 40px; $aside-separation-space: 40px;
$screen-lg-max: 1490px;
$screen-lg-container: 1440px; $screen-lg-container: 1440px;
.resource-detail-layout { .resource-detail-layout {
......
...@@ -100,6 +100,9 @@ $body-min-width: 1048px; ...@@ -100,6 +100,9 @@ $body-min-width: 1048px;
$footer-height: 60px; $footer-height: 60px;
$navbar-item-line-height: 36px; $navbar-item-line-height: 36px;
// Extra breakpoints
$screen-lg-max: 1490px;
// SearchPanel // SearchPanel
$search-panel-width: 270px; $search-panel-width: 270px;
$search-panel-border-width: 4px; $search-panel-border-width: 4px;
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
@import 'variables'; @import 'variables';
@import 'typography'; @import 'typography';
$description-max-width: 700px; $description-max-width: 650px;
$description-max-width-med: 450px;
$description-max-width-small: 300px;
.column-list { .column-list {
margin: 0; margin: 0;
...@@ -75,25 +77,29 @@ $description-max-width: 700px; ...@@ -75,25 +77,29 @@ $description-max-width: 700px;
.markdown-wrapper p { .markdown-wrapper p {
margin-top: 0; margin-top: 0;
white-space: normal;
} }
.column-desc { .column-desc {
@extend %text-body-w3; @extend %text-body-w3;
padding-right: $spacer-1; max-width: $description-max-width-small;
max-width: $description-max-width;
.ams-table-row.has-child-expanded & { @media (min-width: $screen-md-max) {
display: none; max-width: $description-max-width-med;
}
@media (min-width: $screen-lg-max) {
max-width: $description-max-width;
} }
} }
.column-type { .has-child-expanded .column-desc {
padding-right: $spacer-1; display: none;
} }
.actions,
.usage-value { .usage-value {
padding-left: $spacer-1; font-variant-numeric: tabular-nums;
font-family: $text-heading-font-family;
} }
} }
...@@ -212,10 +212,11 @@ describe('Table', () => { ...@@ -212,10 +212,11 @@ describe('Table', () => {
data, data,
columns, columns,
}); });
const expected = 'left'; const expected = true;
const actual = wrapper const actual = wrapper
.find('.ams-table-header .ams-table-heading-cell') .find('.ams-table-header .ams-table-heading-cell')
.get(0).props.style.textAlign; .at(0)
.hasClass('is-left-aligned');
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
}); });
...@@ -225,23 +226,25 @@ describe('Table', () => { ...@@ -225,23 +226,25 @@ describe('Table', () => {
data, data,
columns, columns,
}); });
const expected = 'center'; const expected = true;
const actual = wrapper const actual = wrapper
.find('.ams-table-header .ams-table-heading-cell') .find('.ams-table-header .ams-table-heading-cell')
.get(1).props.style.textAlign; .at(1)
.hasClass('is-center-aligned');
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
}); });
it('renders the first column as right aligned', () => { it('renders the third column as right aligned', () => {
const { wrapper } = setup({ const { wrapper } = setup({
data, data,
columns, columns,
}); });
const expected = 'right'; const expected = true;
const actual = wrapper const actual = wrapper
.find('.ams-table-header .ams-table-heading-cell') .find('.ams-table-header .ams-table-heading-cell')
.get(2).props.style.textAlign; .at(2)
.hasClass('is-right-aligned');
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
}); });
...@@ -253,10 +256,11 @@ describe('Table', () => { ...@@ -253,10 +256,11 @@ describe('Table', () => {
data, data,
columns, columns,
}); });
const expected = 'left'; const expected = true;
const actual = wrapper const actual = wrapper
.find('.ams-table-body .ams-table-cell') .find('.ams-table-body .ams-table-cell')
.get(0).props.style.textAlign; .at(0)
.hasClass('is-left-aligned');
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
}); });
...@@ -266,10 +270,11 @@ describe('Table', () => { ...@@ -266,10 +270,11 @@ describe('Table', () => {
data, data,
columns, columns,
}); });
const expected = 'center'; const expected = true;
const actual = wrapper const actual = wrapper
.find('.ams-table-body .ams-table-cell') .find('.ams-table-body .ams-table-cell')
.get(1).props.style.textAlign; .at(1)
.hasClass('is-center-aligned');
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
}); });
...@@ -279,10 +284,11 @@ describe('Table', () => { ...@@ -279,10 +284,11 @@ describe('Table', () => {
data, data,
columns, columns,
}); });
const expected = 'right'; const expected = true;
const actual = wrapper const actual = wrapper
.find('.ams-table-body .ams-table-cell') .find('.ams-table-body .ams-table-cell')
.get(2).props.style.textAlign; .at(2)
.hasClass('is-right-aligned');
expect(actual).toEqual(expected); expect(actual).toEqual(expected);
}); });
......
...@@ -43,6 +43,11 @@ const DEFAULT_ROW_HEIGHT = 30; ...@@ -43,6 +43,11 @@ const DEFAULT_ROW_HEIGHT = 30;
const EXPANDING_CELL_WIDTH = '70px'; const EXPANDING_CELL_WIDTH = '70px';
const DEFAULT_TEXT_ALIGNMENT = 'left'; const DEFAULT_TEXT_ALIGNMENT = 'left';
const DEFAULT_CELL_WIDTH = 'auto'; const DEFAULT_CELL_WIDTH = 'auto';
const ALIGNEMENT_TO_CLASS_MAP = {
left: 'is-left-aligned',
right: 'is-right-aligned',
center: 'is-center-aligned',
};
type RowStyles = { type RowStyles = {
height: string; height: string;
...@@ -54,6 +59,9 @@ type EmptyRowProps = { ...@@ -54,6 +59,9 @@ type EmptyRowProps = {
emptyMessage?: string; emptyMessage?: string;
}; };
const getCellAlignmentClass = (alignment: TextAlignmentValues) =>
ALIGNEMENT_TO_CLASS_MAP[alignment];
const EmptyRow: React.FC<EmptyRowProps> = ({ const EmptyRow: React.FC<EmptyRowProps> = ({
colspan, colspan,
rowStyles, rowStyles,
...@@ -204,7 +212,6 @@ const Table: React.FC<TableProps> = ({ ...@@ -204,7 +212,6 @@ const Table: React.FC<TableProps> = ({
: DEFAULT_CELL_WIDTH; : DEFAULT_CELL_WIDTH;
const cellStyle = { const cellStyle = {
width, width,
textAlign: `${horAlign}` as TextAlignmentValues,
}; };
// TODO: Improve the typing of this // TODO: Improve the typing of this
let cellContent: React.ReactNode | typeof value = value; let cellContent: React.ReactNode | typeof value = value;
...@@ -214,7 +221,9 @@ const Table: React.FC<TableProps> = ({ ...@@ -214,7 +221,9 @@ const Table: React.FC<TableProps> = ({
return ( return (
<td <td
className="ams-table-cell" className={`ams-table-cell ${getCellAlignmentClass(
horAlign
)}`}
key={`index:${index}`} key={`index:${index}`}
style={cellStyle} style={cellStyle}
> >
...@@ -253,12 +262,13 @@ const Table: React.FC<TableProps> = ({ ...@@ -253,12 +262,13 @@ const Table: React.FC<TableProps> = ({
({ title, horAlign = DEFAULT_TEXT_ALIGNMENT, width = null }, index) => { ({ title, horAlign = DEFAULT_TEXT_ALIGNMENT, width = null }, index) => {
const cellStyle = { const cellStyle = {
width: width ? `${width}px` : DEFAULT_CELL_WIDTH, width: width ? `${width}px` : DEFAULT_CELL_WIDTH,
textAlign: `${horAlign}` as TextAlignmentValues,
}; };
return ( return (
<th <th
className="ams-table-heading-cell" className={`ams-table-heading-cell ${getCellAlignmentClass(
horAlign
)}`}
key={`index:${index}`} key={`index:${index}`}
style={cellStyle} style={cellStyle}
> >
......
...@@ -42,6 +42,22 @@ $row-bottom-border-color: $gray10; ...@@ -42,6 +42,22 @@ $row-bottom-border-color: $gray10;
&:last-child { &:last-child {
padding-right: $spacer-3; padding-right: $spacer-3;
} }
&.is-left-aligned {
text-align: left;
padding-right: $spacer-1;
}
&.is-right-aligned {
text-align: right;
padding-left: $spacer-1;
}
&.is-center-aligned {
text-align: center;
padding-left: $spacer-1;
padding-right: $spacer-1;
}
} }
.ams-table-row { .ams-table-row {
...@@ -72,6 +88,22 @@ $row-bottom-border-color: $gray10; ...@@ -72,6 +88,22 @@ $row-bottom-border-color: $gray10;
&:last-child { &:last-child {
padding-right: $spacer-3; padding-right: $spacer-3;
} }
&.is-left-aligned {
text-align: left;
padding-right: $spacer-1;
}
&.is-right-aligned {
text-align: right;
padding-left: $spacer-1;
}
&.is-center-aligned {
text-align: center;
padding-left: $spacer-1;
padding-right: $spacer-1;
}
} }
.ams-table-expanding-button { .ams-table-expanding-button {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment