Skip to content

Commit f32b8ca

Browse files
rickstefanikmergify[bot]
authored andcommitted
feat(content-explorer): grid view styling (#1464)
* feat(content-explorer): show cards with thumbnails (#1409) * feat: showing cards with thumbnails * feat: moved getThumbnail to api/File * fix: fixing en-US * feat: initial styling * fix: removed column width math in scss * fix: text goes to ellipsis when necessary * fix: made GridViewSlot component * fix: removed button right margin
1 parent c28f1fa commit f32b8ca

File tree

22 files changed

+177
-83
lines changed

22 files changed

+177
-83
lines changed

src/components/grid-view/GridView.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// @flow
22
import * as React from 'react';
3-
import classNames from 'classnames';
43
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/es/CellMeasurer';
54
import Table, { Column } from 'react-virtualized/dist/es/Table';
6-
import uniqueId from 'lodash/uniqueId';
75
import getProp from 'lodash/get';
6+
import GridViewSlot from './GridViewSlot';
87

98
import 'react-virtualized/styles.css';
109
import './GridView.scss';
@@ -37,13 +36,13 @@ class GridView extends React.Component<Props> {
3736
fixedWidth: true,
3837
});
3938

40-
componentDidUpdate(prevProps: Props) {
39+
componentDidUpdate({ columnCount: prevColumnCount, width: prevWidth }: Props) {
4140
const { columnCount, width } = this.props;
4241

43-
// The React Virtualized Table must be notified when either the cached
44-
// row sizes or the parent width change. If omitted, rows are sized
42+
// The React Virtualized Table must be notified whenever the heights of rows
43+
// could potentially change. If omitted, rows are sized
4544
// incorrectly resulting in gaps or content overlap.
46-
if (columnCount !== prevProps.columnCount || width !== prevProps.width) {
45+
if (columnCount !== prevColumnCount || width !== prevWidth) {
4746
this.cache.clearAll();
4847
this.forceUpdate();
4948
}
@@ -58,16 +57,19 @@ class GridView extends React.Component<Props> {
5857
const maxSlotIndex = Math.min(startingIndex + columnCount, count);
5958

6059
for (let slotIndex = startingIndex; slotIndex < maxSlotIndex; slotIndex += 1) {
60+
const { id, selected } = getProp(currentCollection, `items[${slotIndex}]`);
61+
6162
// using item's id as key is important for renrendering. React Virtualized Table rerenders
6263
// on every 1px scroll, so using improper key would lead to image flickering in each
6364
// card of the grid view when scrolling.
6465
contents.push(
65-
<div
66-
key={getProp(currentCollection, `items[${slotIndex}].id`) || uniqueId('bdl-GridView-slot')}
67-
className="bdl-GridView-slot"
68-
>
69-
{slotRenderer(slotIndex)}
70-
</div>,
66+
<GridViewSlot
67+
key={id}
68+
selected={selected}
69+
slotIndex={slotIndex}
70+
slotRenderer={slotRenderer}
71+
slotWidth={`${(100 / columnCount).toFixed(4)}%`}
72+
/>,
7173
);
7274
}
7375

@@ -89,7 +91,7 @@ class GridView extends React.Component<Props> {
8991

9092
return (
9193
<Table
92-
className={classNames('bdl-GridView', `bdl-GridView--columns-${columnCount}`)}
94+
className="bdl-GridView"
9395
disableHeader
9496
height={height}
9597
rowCount={rowCount}
Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,37 @@
1-
@import '../../elements/common/variables';
2-
@import '../../styles/variables';
3-
41
.bdl-GridView {
5-
padding: 0 5px;
6-
7-
&.bdl-GridView--columns-1 .bdl-GridView-slot {
8-
$columns1prct: 100%;
9-
10-
flex-basis: $columns1prct;
11-
max-width: $columns1prct;
2+
.ReactVirtualized__Table__rowColumn:first-child {
3+
margin: 0;
124
}
135

14-
&.bdl-GridView--columns-3 .bdl-GridView-slot {
15-
$columns3prct: calc(33.3333% - 10px); /* 100%/3 - 10px */
16-
17-
flex-basis: $columns3prct;
18-
max-width: $columns3prct;
6+
.bce-more-options {
7+
align-self: flex-start;
198
}
209

21-
&.bdl-GridView--columns-5 .bdl-GridView-slot {
22-
$columns5prct: calc(20% - 10px); /* 100%/5 - 10px */
10+
.bce-btn-more-options {
11+
margin-top: 0;
12+
margin-right: 0;
13+
padding: 5px 10px;
2314

24-
flex-basis: $columns5prct;
25-
max-width: $columns5prct;
15+
.btn-content {
16+
align-items: center;
17+
display: flex;
18+
justify-content: center;
19+
}
2620
}
21+
}
2722

28-
.ReactVirtualized__Table__rowColumn:first-of-type {
29-
margin: 0;
30-
}
23+
.bdl-GridView-body {
24+
outline: none;
25+
padding: 5px;
3126
}
3227

3328
.bdl-GridView-row {
3429
display: flex;
3530
justify-content: flex-start;
3631
}
3732

38-
.bdl-GridView-slot {
39-
border: 1px solid $bdl-gray-10;
40-
flex: 0 1 auto;
41-
margin-top: 10px;
42-
overflow: hidden;
43-
padding: 15px;
44-
white-space: normal;
45-
46-
& + & {
47-
margin-left: 10px;
48-
}
49-
}
50-
5133
.bdl-GridView-tableRow {
5234
border: none;
35+
padding-right: 0 !important;
36+
width: 100% !important;
5337
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @flow
2+
import * as React from 'react';
3+
import classNames from 'classnames';
4+
import './GridViewSlot.scss';
5+
6+
type Props = {
7+
selected: boolean,
8+
slotIndex: number,
9+
slotRenderer: (slotIndex: number) => ?React.Element<any>,
10+
slotWidth: string,
11+
};
12+
13+
const GridViewSlot = ({ selected, slotIndex, slotRenderer, slotWidth }: Props) => {
14+
return (
15+
<div className="bdl-GridViewSlot" style={{ maxWidth: slotWidth, flexBasis: slotWidth }}>
16+
<div
17+
className={classNames('bdl-GridViewSlot-content', {
18+
'bdl-GridViewSlot-content--selected': selected,
19+
})}
20+
>
21+
{slotRenderer(slotIndex)}
22+
</div>
23+
</div>
24+
);
25+
};
26+
27+
export default GridViewSlot;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@import '../../elements/common/variables';
2+
@import '../../styles/variables';
3+
4+
.bdl-GridViewSlot {
5+
flex: 0 1 auto;
6+
overflow: hidden;
7+
padding: 5px;
8+
white-space: normal;
9+
}
10+
11+
.bdl-GridViewSlot-content {
12+
border: 1px solid $bdl-gray-10;
13+
box-shadow: 0 1px 5px rgba(50, 50, 50, .1);
14+
height: 100%;
15+
16+
&:hover,
17+
&:active,
18+
&:focus {
19+
border-color: $bdl-box-blue-50;
20+
}
21+
22+
&.bdl-GridViewSlot-content--selected {
23+
border-color: $bdl-box-blue-50;
24+
}
25+
}

src/components/grid-view/__tests__/__snapshots__/GridView-test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`components/grid-view/GridView should render() 1`] = `
44
<Component
5-
className="bdl-GridView bdl-GridView--columns-5"
5+
className="bdl-GridView"
66
disableHeader={true}
77
gridClassName="bdl-GridView-body"
88
height={600}

src/elements/common/breadcrumbs/Breadcrumb.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ type Props = {
1818

1919
const Breadcrumb = ({ name = '', onClick, isLast, delimiter }: Props) => {
2020
const title = onClick ? (
21-
<PlainButton onClick={onClick} type="button">
21+
<PlainButton onClick={onClick} type="button" className="bdl-Breadcrumb-title">
2222
{name}
2323
</PlainButton>
2424
) : (
25-
<span>{name}</span>
25+
<div className="bdl-Breadcrumb-title">{name}</div>
2626
);
2727
return (
2828
<span className="be-breadcrumb">

src/elements/common/breadcrumbs/Breadcrumb.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,10 @@
2222
flex-shrink: 0;
2323
margin: 1px 8px 0 5px;
2424
}
25+
26+
.bdl-Breadcrumb-title {
27+
overflow: hidden;
28+
text-overflow: ellipsis;
29+
white-space: nowrap;
30+
width: 100%;
31+
}

src/elements/common/breadcrumbs/InlineBreadcrumbs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Props = {
1717
rootId: string,
1818
};
1919

20-
const InlineBreadcrumbs = ({ rootId, item, onItemClick }: Props) => {
20+
const InlineBreadcrumbs = ({ item, onItemClick, rootId }: Props) => {
2121
const { path_collection }: BoxItem = item;
2222
const { entries: breadcrumbs = [] } = path_collection || {};
2323
return (
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
@import '../variables';
22

33
.be-item-label {
4+
display: block;
45
outline: none;
6+
overflow: hidden;
57
text-align: left;
8+
text-overflow: ellipsis;
69
white-space: nowrap;
10+
width: 100%;
711
}

src/elements/common/item/ItemSubDetails.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import getSize from '../../../utils/size';
1010
import Datefield from '../date';
1111
import messages from '../messages';
1212
import { VIEW_RECENTS } from '../../../constants';
13+
import './ItemSubDetails.scss';
1314

1415
type Props = {
1516
item: BoxItem,
1617
view: View,
1718
};
1819

19-
const ItemSubDetails = ({ view, item }: Props) => {
20+
const ItemSubDetails = ({ item, view }: Props) => {
2021
const { modified_at = '', interacted_at = '', modified_by }: BoxItem = item;
2122
const modifiedBy: string = modified_by ? modified_by.name || '' : '';
2223
const isRecents: boolean = view === VIEW_RECENTS;
@@ -33,17 +34,16 @@ const ItemSubDetails = ({ view, item }: Props) => {
3334

3435
return (
3536
<span>
36-
<FormattedMessage
37-
{...message}
38-
values={{
39-
date: DateValue,
40-
name: modifiedBy,
41-
}}
42-
/>
43-
<span>
44-
&nbsp;-&nbsp;
45-
{getSize(size)}
37+
<span className="bdl-ItemSubDetails-modifiedBy">
38+
<FormattedMessage
39+
{...message}
40+
values={{
41+
date: DateValue,
42+
name: modifiedBy,
43+
}}
44+
/>
4645
</span>
46+
<span className="bdl-ItemSubDetails-size">{getSize(size)}</span>
4747
</span>
4848
);
4949
};

0 commit comments

Comments
 (0)