Skip to content

Commit 5e96ecd

Browse files
committed
feat: export modal and css improvements
1 parent 9d5b311 commit 5e96ecd

20 files changed

+521
-224
lines changed

app/components/CommitDetails.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as React from 'react'
2+
import numeral from 'numeral'
3+
4+
import { Structure, Commit } from '../models/dataset'
5+
6+
import Icon from './chrome/Icon'
7+
import RelativeTimestamp from './RelativeTimestamp'
8+
9+
interface CommitDetailsProps {
10+
structure: Structure
11+
commit: Commit
12+
path: string
13+
}
14+
15+
const CommitDetails: React.FunctionComponent<CommitDetailsProps> = (props) => {
16+
const { structure, commit, path } = props
17+
return (
18+
<>
19+
<span className='dataset-details' style={{ marginBottom: '6px' }}><Icon icon='stickyNote' size='sm' color='default' />{commit.title}</span>
20+
<div className='dataset-details-container'>
21+
<span className='dataset-details'><Icon icon='commit' size='sm' color='default' /><span title={path}>{path.substring(path.length - 7)}</span></span>
22+
<span className='dataset-details'><Icon icon='clock' size='sm' color='default' /><RelativeTimestamp timestamp={commit.timestamp}/></span>
23+
<span className='dataset-details'><Icon icon='hdd' size='sm' color='default' />{numeral(structure.length).format('0.0b')}</span>
24+
<span className='dataset-details'><Icon icon='bars' size='sm' color='default' />{numeral(structure.entries).format('0,0')} rows</span>
25+
</div>
26+
</>
27+
)
28+
}
29+
30+
export default CommitDetails

app/components/RelativeTimestamp.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react'
2+
import moment from 'moment'
3+
4+
interface RelativeTimestampProps {
5+
timestamp: string
6+
}
7+
8+
const RelativeTimestamp: React.FunctionComponent<RelativeTimestampProps> = ({ timestamp }) => (
9+
<span
10+
className='relative-timestamp'
11+
title={moment(timestamp).format('MMM D YYYY, h:mm A zz')}
12+
>
13+
{moment(timestamp).fromNow()}
14+
</span>
15+
)
16+
17+
export default RelativeTimestamp

app/components/chrome/Icon.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,24 @@ import {
3434
faEllipsisH,
3535
faSort,
3636
faMinus,
37-
faSave,
38-
faSync
37+
faSync,
38+
faBars
3939
} from '@fortawesome/free-solid-svg-icons'
4040

41+
import {
42+
faClock,
43+
faStickyNote,
44+
faHdd
45+
} from '@fortawesome/free-regular-svg-icons'
46+
4147
interface IconProps {
4248
// name of the icon
4349
icon: string
4450
// size sm: .875em
4551
// md: 1.33em
4652
// lg: 2em
4753
size?: 'xs' | 'sm' | 'md' | 'lg'
48-
color?: 'light' | 'medium' | 'dark' | 'red' | 'green'
54+
color?: 'light' | 'medium' | 'dark' | 'red' | 'green' | 'default'
4955
}
5056

5157
const icons: Record<string, any> = {
@@ -74,7 +80,6 @@ const icons: Record<string, any> = {
7480
'dataset': faFileAlt,
7581
'datasets': faCopy,
7682
'readme': faGlasses,
77-
'commit': faSave,
7883
'lock': faLock,
7984
'transform': faCode,
8085
'close': faTimes,
@@ -91,7 +96,11 @@ const icons: Record<string, any> = {
9196
'hamburger': faEllipsisH,
9297
'minus': faMinus,
9398
'plus': faPlus,
94-
'sync': faSync
99+
'sync': faSync,
100+
'clock': faClock,
101+
'bars': faBars,
102+
'hdd': faHdd,
103+
'stickyNote': faStickyNote
95104
}
96105

97106
export const iconsList = Object.keys(icons)
@@ -108,7 +117,17 @@ const Icon: React.FunctionComponent<IconProps> = ({
108117
'lg': '2x'
109118
}
110119

111-
return <FontAwesomeIcon size={sizes[size]} icon={icons[icon]} className={`icon-${color}`}/>
120+
if (icon === 'commit') {
121+
return (
122+
<svg aria-hidden='true' focusable='false' className={`svg-inline--fa fa-${sizes[size]}`} role='img' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 91'>
123+
<circle id='Oval' stroke='currentColor' strokeWidth='10' cx='26' cy='45' r='21' fill='none'></circle>
124+
<line x1='26.5' y1='4.5' x2='26.5' y2='22.5' id='Line' stroke='currentColor' strokeWidth='10' strokeLinecap='square'></line>
125+
<line x1='26.5' y1='66.5' x2='26.5' y2='86.5' id='Line' stroke='currentColor' strokeWidth='10' strokeLinecap='square'></line>
126+
</svg>
127+
)
128+
}
129+
130+
return <FontAwesomeIcon size={sizes[size]} icon={icons[icon]} className={color === 'default' ? '' : `icon-${color}`}/>
112131
}
113132

114133
export default Icon

app/components/collection/DatasetHeader.tsx

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import React from 'react'
2-
import moment from 'moment'
3-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
4-
import { faClock } from '@fortawesome/free-regular-svg-icons'
52

63
import { Structure, Commit } from '../../models/dataset'
7-
import fileSize from '../../utils/fileSize'
4+
5+
import CommitDetails from '../CommitDetails'
86

97
interface DatasetHeaderProps {
108
path: string
@@ -15,25 +13,11 @@ interface DatasetHeaderProps {
1513
const DatasetHeader: React.FunctionComponent<DatasetHeaderProps> = ({ path, structure, commit }) => {
1614
return (
1715
<div className='commit-details-header'>
18-
{structure && commit && <div className='details-flex'>
19-
<div className='text-column'>
20-
<div id='commit-title' className='text'>{commit.title}</div>
21-
<div className='subtext'>
22-
{/* <img className= 'user-image' src = {'https://avatars0.githubusercontent.com/u/1154390?s=60&v=4'} /> */}
23-
<div className='time-message'>
24-
<FontAwesomeIcon icon={faClock} size='sm'/>&nbsp;
25-
{moment(commit.timestamp).format('MMMM Do YYYY, h:mm:ss a')}
26-
</div>
27-
<small className='small hash'>{path && path.replace('/ipfs/', '') }</small>
28-
</div>
29-
</div>
30-
<div className='details-column'>
31-
{structure.length && <div className='detail' id='commit-details-header-file-size'>{fileSize(structure.length)}</div>}
32-
{structure.format && <div className='detail' id='commit-details-header-format'>{structure.format.toUpperCase()}</div>}
33-
{structure.entries && <div className='detail' id='commit-details-header-entries'>{structure.entries.toLocaleString()} {structure.entries !== 1 ? 'entries' : 'entry'}</div>}
34-
{structure.errCount && <div className='detail' id='commit-details-header-errors'>{structure.errCount.toLocaleString()} {structure.errCount !== 1 ? 'errors' : 'error'}</div>}
35-
</div>
36-
</div>}
16+
{
17+
structure && commit && (
18+
<CommitDetails structure={structure} commit={commit} path={path} />
19+
)
20+
}
3721
</div>
3822
)
3923
}

app/components/collection/layouts/DatasetMainContent.tsx

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react'
2-
import { Prompt } from 'react-router-dom'
32

43
import { connectComponentToPropsWithRouter } from '../../../utils/connectComponentToProps'
54
import { QriRef, qriRefFromRoute } from '../../../models/qriRef'
@@ -8,9 +7,6 @@ import { ApiActionThunk } from '../../../store/api'
87
import { fetchWorkingDatasetDetails } from '../../../actions/api'
98
import { selectFsiPath, selectMutationsIsDirty } from '../../../selections'
109

11-
import LinkButton from '../headerButtons/LinkButton'
12-
import PublishButton from '../headerButtons/PublishButton'
13-
1410
interface DatasetMainContentProps extends RouteProps {
1511
qriRef: QriRef
1612
modified: boolean
@@ -19,28 +15,12 @@ interface DatasetMainContentProps extends RouteProps {
1915
}
2016

2117
const DatasetMainContentComponent: React.FunctionComponent<DatasetMainContentProps> = (props) => {
22-
const {
23-
qriRef,
24-
modified,
25-
fsiPath,
26-
children,
27-
fetchWorkingDatasetDetails
28-
} = props
29-
return <>
30-
<div className='main-content-header'>
31-
<Prompt when={modified} message={(location) => {
32-
if (location.pathname.includes(qriRef.username) && location.pathname.includes(qriRef.name)) return true
33-
if (fsiPath !== '') {
34-
fetchWorkingDatasetDetails(qriRef.username, qriRef.name)
35-
return true
36-
}
37-
return `You have uncommited changes! Click 'cancel' and commit these changes before you navigate away or you will lose your work.`
38-
}}/>
39-
<LinkButton />
40-
<PublishButton />
41-
</div>
42-
{children}
43-
</>
18+
const { children } = props
19+
return (
20+
<>
21+
{children}
22+
</>
23+
)
4424
}
4525

4626
export default connectComponentToPropsWithRouter(

app/components/collection/layouts/DatasetSidebar.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { connectComponentToPropsWithRouter } from '../../../utils/connectCompone
77

88
import { selectVersionInfoFromWorkingDataset } from '../../../selections'
99

10-
import DatasetReference from '../../DatasetReference'
11-
import DatasetDetailsSubtext from '../../dataset/DatasetDetailsSubtext'
1210
import ReactTooltip from 'react-tooltip'
1311
import LogList from '../LogList'
1412

@@ -18,10 +16,7 @@ export interface DatasetSidebarProps extends RouteProps {
1816
}
1917

2018
export const DatasetSidebarComponent: React.FunctionComponent<DatasetSidebarProps> = (props) => {
21-
const {
22-
qriRef,
23-
data
24-
} = props
19+
const { qriRef } = props
2520

2621
// The `ReactTooltip` component relies on the `data-for` and `data-tip` attributes
2722
// we need to rebuild `ReactTooltip` so that it can recognize the `data-for`
@@ -30,10 +25,6 @@ export const DatasetSidebarComponent: React.FunctionComponent<DatasetSidebarProp
3025

3126
return (
3227
<div className='sidebar'>
33-
<div className='sidebar-header sidebar-padded-container'>
34-
<DatasetReference qriRef={qriRef} />
35-
<DatasetDetailsSubtext data={data} />
36-
</div>
3728
<LogList qriRef={qriRef} />
3829
</div>
3930
)

app/components/form/CheckboxInput.tsx

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
11
import * as React from 'react'
2+
import classNames from 'classnames'
23

34
export interface CheckboxInputProps {
45
label?: string
56
name: string
67
checked: boolean
8+
indeterminate?: boolean
79
onChange: (name: string, checked: any) => void
10+
strong?: boolean
11+
disabled?: boolean
812
}
913

10-
const CheckboxInput: React.FunctionComponent<CheckboxInputProps> = ({ label, name, checked, onChange }) => {
14+
const CheckboxInput: React.FunctionComponent<CheckboxInputProps> = (props) => {
15+
const { label, name, checked, onChange, indeterminate = false, strong = false, disabled = false } = props
1116
return (
12-
<>
13-
<div className='checkbox-input-container'>
14-
<input
15-
id={name}
16-
name={name}
17-
type='checkbox'
18-
className='checkbox-input'
19-
checked={checked}
20-
onChange={ () => { onChange(name, !checked) }}
21-
/>
22-
{label}
23-
</div>
24-
</>
17+
<div className={classNames('checkbox-input-container', { 'disabled': disabled === true })}>
18+
<input
19+
id={name}
20+
name={name}
21+
type='checkbox'
22+
className='checkbox-input'
23+
checked={checked}
24+
onChange={ () => { onChange(name, !checked) }}
25+
ref={el => el && (el.indeterminate = indeterminate)}
26+
disabled={disabled}
27+
/>
28+
{ strong ? (<strong>{label}</strong>) : label }
29+
</div>
2530
)
2631
}
2732

app/components/form/RadioInput.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as React from 'react'
2+
import classNames from 'classnames'
3+
4+
export interface RadioInputProps {
5+
label?: string
6+
name: string
7+
checked: boolean
8+
onChange: (name: string, checked: any) => void
9+
strong?: boolean
10+
disabled?: boolean
11+
}
12+
13+
const RadioInput: React.FunctionComponent<RadioInputProps> = (props) => {
14+
const { label, name, checked, onChange, strong = false, disabled = false } = props
15+
16+
return (
17+
<>
18+
<div className={classNames('radio-input-container', { 'disabled': disabled === true })}>
19+
<input
20+
id={name}
21+
name={name}
22+
type='radio'
23+
className='radio-input'
24+
checked={checked}
25+
onChange={ () => { onChange(name, !checked) }}
26+
disabled={disabled}
27+
/>
28+
{ strong && (
29+
<strong>{label}</strong>
30+
)}
31+
{!strong && label}
32+
</div>
33+
</>
34+
)
35+
}
36+
37+
export default RadioInput

app/components/item/LogListItem.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import React from 'react'
22
import { Action } from 'redux'
33
import classNames from 'classnames'
4+
45
import { VersionInfo } from '../../models/store'
5-
import moment from 'moment'
6+
7+
import RelativeTimestamp from '../RelativeTimestamp'
8+
import Icon from '../chrome/Icon'
69

710
export interface LogListItemProps {
811
id: string
@@ -52,9 +55,7 @@ const LogListItem: React.FunctionComponent<LogListItemProps> = (props) => {
5255
<div className='text'>{commitTitle}</div>
5356
<div className='subtext'>
5457
{/* Bring back avatar later <img className= 'user-image' src = {props.avatarUrl} /> */}
55-
<div className='time-message'>
56-
{moment(commitTime).fromNow()}
57-
</div>
58+
<span className='dataset-details'><Icon icon='clock' size='sm' color='default' /><RelativeTimestamp timestamp={commitTime}/></span>
5859
</div>
5960
</div>
6061
</div>

0 commit comments

Comments
 (0)