Skip to content

Commit 00f3083

Browse files
authored
New: Key Value card and UI tweaks (#69)
1 parent f735d8c commit 00f3083

20 files changed

Lines changed: 139 additions & 55 deletions

src/components/ContentPreview/DetailsSidebar.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,23 @@ type Props = {
2121
/* eslint-disable jsx-a11y/label-has-for */
2222
const DetailsSidebar = ({ file, getPreviewer, getLocalizedMessage }: Props) =>
2323
<SidebarContent title={getLocalizedMessage('buik.preview.sidebar.details.title')}>
24-
<div className='bcpr-sidebar-details-description'>
25-
<label>
26-
<span>
27-
{getLocalizedMessage('buik.preview.sidebar.details.description')}
28-
</span>
29-
<textarea
30-
readOnly
31-
placeholder={getLocalizedMessage('buik.preview.sidebar.details.description.placeholder')}
32-
defaultValue={file.description}
33-
/>
34-
</label>
35-
</div>
36-
<SidebarSection title={getLocalizedMessage('buik.preview.sidebar.details.properties')}>
24+
<SidebarSkills metadata={file.metadata} getPreviewer={getPreviewer} getLocalizedMessage={getLocalizedMessage} />
25+
<SidebarSection isOpen={false} title={getLocalizedMessage('buik.preview.sidebar.details.properties')}>
3726
<FileProperties file={file} getLocalizedMessage={getLocalizedMessage} />
3827
</SidebarSection>
39-
<SidebarSkills metadata={file.metadata} getPreviewer={getPreviewer} getLocalizedMessage={getLocalizedMessage} />
4028
</SidebarContent>;
4129

4230
export default DetailsSidebar;
31+
32+
// <div className='bcpr-sidebar-details-description'>
33+
// <label>
34+
// <span>
35+
// {getLocalizedMessage('buik.preview.sidebar.details.description')}
36+
// </span>
37+
// <textarea
38+
// readOnly
39+
// placeholder={getLocalizedMessage('buik.preview.sidebar.details.description.placeholder')}
40+
// defaultValue={file.description}
41+
// />
42+
// </label>
43+
// </div>

src/components/ContentPreview/SidebarContent.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
position: relative; // So that the scroll wrapper is absolute
66

77
.bcpr-sidebar-title {
8-
border-bottom: 1px solid $off-white;
8+
// border-bottom: 1px solid $off-white;
99
line-height: 30px;
1010
margin: 15px 20px;
1111
}

src/components/ContentPreview/SidebarSection.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import React, { PureComponent } from 'react';
88
import classNames from 'classnames';
99
import { PlainButton } from '../Button';
10-
import IconCross from '../icons/IconCross';
10+
import IconAddCircle from '../icons/IconAddCircle';
11+
import IconSubtractCircle from '../icons/IconSubtractCircle';
1112
import './SidebarSection.scss';
1213

1314
type Props = {
@@ -32,7 +33,7 @@ class SidebarSection extends PureComponent<DefaultProps, Props, State> {
3233

3334
static defaultProps = {
3435
className: '',
35-
isOpen: false
36+
isOpen: true
3637
};
3738

3839
/**
@@ -72,14 +73,6 @@ class SidebarSection extends PureComponent<DefaultProps, Props, State> {
7273
const { isOpen }: State = this.state;
7374
const { children, className, title }: Props = this.props;
7475

75-
const titleClassName = classNames(
76-
'bcpr-sidebar-toggle',
77-
{
78-
'bcpr-sidebar-toggle-cross': isOpen
79-
},
80-
className
81-
);
82-
8376
const sectionClassName = classNames(
8477
'bcpr-sidebar-section',
8578
{
@@ -94,7 +87,7 @@ class SidebarSection extends PureComponent<DefaultProps, Props, State> {
9487
<span className='bcpr-sidebar-section-title-text'>
9588
{title}
9689
</span>
97-
<IconCross color='#b5b5b5' width={11} height={11} className={titleClassName} />
90+
{isOpen ? <IconSubtractCircle width={14} height={14} /> : <IconAddCircle width={14} height={14} />}
9891
</PlainButton>
9992
{isOpen &&
10093
<div className='bcpr-sidebar-section-content'>

src/components/ContentPreview/SidebarSection.scss

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,3 @@
3535
}
3636
}
3737
}
38-
39-
.bcpr-sidebar-toggle {
40-
transform: rotateZ(-45deg);
41-
transition: transform .3s;
42-
43-
.bcpr-sidebar-section-open & {
44-
transform: rotateZ(0deg);
45-
}
46-
}

src/components/ContentPreview/SidebarSkills.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import SidebarSection from './SidebarSection';
99
import Keywords from '../Keywords';
1010
import Transcript from '../Transcript';
1111
import Timelines from '../Timeline';
12+
import Keyvalues from '../Keyvalues';
1213
import type { SkillData, MetadataType } from '../../flowTypes';
1314

1415
type Props = {
@@ -22,6 +23,8 @@ function getCard(skill: SkillData, getPreviewer: Function) {
2223
switch (skills_data_type) {
2324
case 'keyword':
2425
return <Keywords skill={skill} getPreviewer={getPreviewer} />;
26+
case 'keyvalue':
27+
return <Keyvalues skill={skill} />;
2528
case 'timeline':
2629
return <Timelines skill={skill} getPreviewer={getPreviewer} />;
2730
case 'transcript':
@@ -74,6 +77,8 @@ const SidebarSkills = ({ metadata, getPreviewer, getLocalizedMessage }: Props) =
7477
{skills.map(
7578
(skill: SkillData, index) =>
7679
/* eslint-disable react/no-array-index-key */
80+
Array.isArray(skill.entries) &&
81+
skill.entries.length > 0 &&
7782
<SidebarSection
7883
key={index}
7984
title={
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @flow
3+
* @file File Key Values Skill Data component
4+
* @author Box
5+
*/
6+
7+
import React from 'react';
8+
import type { SkillData, SkillDataEntry } from '../../flowTypes';
9+
import './Keyvalues.scss';
10+
11+
type Props = {
12+
skill: SkillData
13+
};
14+
15+
const Keyvalues = ({ skill: { entries } }: Props) =>
16+
<div className='buik-keyvalues'>
17+
{Array.isArray(entries) &&
18+
entries.map(
19+
({ label, text }: SkillDataEntry, index) =>
20+
!!label &&
21+
!!text &&
22+
/* eslint-disable react/no-array-index-key */
23+
<dl className='buik-keyvalue' key={index}>
24+
<dt>
25+
{label}
26+
</dt>
27+
<dd>
28+
{text}
29+
</dd>
30+
</dl>
31+
/* eslint-enable react/no-array-index-key */
32+
)}
33+
</div>;
34+
35+
export default Keyvalues;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import '../variables';
2+
3+
.buik .buik-keyvalue {
4+
margin: 0 0 20px;
5+
}

src/components/Keyvalues/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default from './Keyvalues';

src/components/Keywords/Keyword.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ import './Keyword.scss';
1212

1313
type Props = {
1414
keyword: SkillDataEntry,
15+
isSelected: boolean,
1516
onClick: Function
1617
};
1718

18-
const Keyword = ({ keyword, onClick }: Props) =>
19+
const Keyword = ({ keyword, onClick, isSelected }: Props) =>
1920
<span className='buik-file-keyword'>
20-
<PlainButton className='buik-file-keyword-word' onClick={() => onClick(keyword)}>
21+
<PlainButton
22+
className={`buik-file-keyword-word ${isSelected ? 'buik-file-keyword-selected' : ''}`}
23+
onClick={() => onClick(keyword)}
24+
>
2125
{keyword.text}
2226
</PlainButton>
2327
</span>;

src/components/Keywords/Keyword.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
&:focus,
3535
&:active,
36-
&:hover {
36+
&:hover,
37+
&.buik-file-keyword-selected {
3738
background-color: $blue;
3839
border-color: $blue;
3940
color: $white;

0 commit comments

Comments
 (0)