Skip to content

Commit

Permalink
feat: add FileSearch UI
Browse files Browse the repository at this point in the history
  • Loading branch information
HOUSHENGREN committed May 3, 2023
1 parent 3244424 commit cc67a95
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 11 deletions.
13 changes: 10 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
// import logo from './logo.svg';
import FileSearch from './components/FileSearch';
import FileList from './components/FileList'
import defaultFiles from './utils/defaultFiles';
import './App.css';
import 'bootstrap/dist/css/bootstrap.min.css'

function App() {
return (
<div className="App container-fluid">
<div className='row'>
<div className='col-3 bg-danger left-pane'>
<FileSearch onFileSearch={() => console.log(666)} title='My document'>2</FileSearch>
<div className='col-6 left-pane'>
<FileSearch onFileSearch={(value) => console.log(666, value)} title='My document'></FileSearch>
<FileList
files={defaultFiles}
onFileClick={(id) => {console.log('777cli', id)}}
onFileDelete={(id) => {console.log('777delete', id)}}
></FileList>
</div>
<div className='col-9 left-pane'>55</div>
<div className='col-6 left-pane'>55</div>
</div>
</div>
);
Expand Down
53 changes: 45 additions & 8 deletions src/components/FileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,52 @@ import { useState, useEffect } from "react"
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faEdit, faTrash } from '@fortawesome/free-solid-svg-icons'
import { faMarkdown } from '@fortawesome/free-brands-svg-icons'
import propTypes from 'prop-types'

const FileList = ({files, onFileClick, onSaveEdit, onFileDelete}) => {

const FileList = () => {
return (
<ul class="list-group">
<li class="list-group-item active" aria-current="true">An active item</li>
<li class="list-group-item">A second item</li>
<li class="list-group-item">A third item</li>
<li class="list-group-item">A fourth item</li>
<li class="list-group-item">And a fifth one</li>
<ul className="list-group list-group-flush file-list">
{
files.map(file => (
<li
className="list-group-item bg-light row d-flex align-items-center file-item"
key={file.id}
>
<span className="col-2">
<FontAwesomeIcon icon={faMarkdown}></FontAwesomeIcon>
</span>
<span className="col-8" onClick={() => { onFileClick(file.id) }}>{file.title}</span>
<button
type="button"
className="icon-button col-1"
// onClick={() => { onSaveEdit(file.id) }}
>
<FontAwesomeIcon title="编辑" size="lg" icon={faEdit} />
</button>
<button
type="button"
className="icon-button col-1"
onClick={() => { onFileDelete(file.id) }}
>
<FontAwesomeIcon title="删除" size="lg" icon={faTrash} />
</button>
</li>
))
}
</ul>
)
}
}

FileList.propTypes = {
files: propTypes.array,
onFileClick: propTypes.func,
onFileDelete: propTypes.func,
// onSaveEdit: propTypes.func
}

FileList.defaultProps = {
files: []
}

export default FileList
28 changes: 28 additions & 0 deletions src/utils/defaultFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const defaultFiles = [
{
id: 111,
title: 'file222',
body: 'should be careful',
createAt: 3215465454
},
{
id: 121,
title: 'file25',
body: '# should be honesty',
createAt: 32154654465
},
{
id: 141,
title: 'file272',
body: 'should be funny',
createAt: 3215465454786
},
{
id: 1145,
title: 'file782',
body: '## should be happy',
createAt: 321546547896
}
]

export default defaultFiles

0 comments on commit cc67a95

Please sign in to comment.