Ver código fonte

Change Feed state to render archive

master
Immanuel Onyeka 3 anos atrás
pai
commit
797877732a
5 arquivos alterados com 36 adições e 7 exclusões
  1. +2
    -0
      README.md
  2. +9
    -5
      src/App.jsx
  3. +3
    -0
      src/Archive.jsx
  4. +4
    -2
      src/Feed.jsx
  5. +18
    -0
      src/Navigator.jsx

+ 2
- 0
README.md Ver arquivo

@@ -10,6 +10,8 @@
- Give call entries shine and box shadow. Maybe color them by type
- Add entry transition animation
- Add favicon
- Seperator could be added by putting li renderer in a seperate function from
Feed

## Summary



+ 9
- 5
src/App.jsx Ver arquivo

@@ -4,20 +4,24 @@ import ReactDOM from 'react-dom';
import Header from './Header.jsx';
import Feed from './Feed.jsx';
import Navigator from './Navigator.jsx';
import Archive from './Archive.jsx';
import Call from './Call.jsx';

const App = () => {
const [recent, setRecent] = useState(true)
const [call, setCall] = useState()

let focus = <Feed recent={recent} onSelect={ (c) => setCall(c) }/>
if (call) {
focus = <Call/>
}

return (
<div className='container'>
<Header/>
<Navigator onPageChange={ (r) => setRecent(r) }
recent={recent}/>
<div className="container-view">
{recent
? <Feed/>
: <Archive/>
}
{focus}
</div>
</div>
);


+ 3
- 0
src/Archive.jsx Ver arquivo

@@ -0,0 +1,3 @@
import React, {useState, useEffect} from 'react';



+ 4
- 2
src/Feed.jsx Ver arquivo

@@ -61,7 +61,7 @@ function Seperator(props) {
}

// The component used for retrieving, sorting, and rendering calls.
function Feed() {
function Feed(props) {
const [ stack, setStack ] = useState(null)

@@ -78,7 +78,9 @@ function Feed() {
if (stack) {
entries = stack.map((entry, index) => {

if (entry.is_archived) {
// Check if current page matches entry type
if (entry.is_archived == props.recent) {
return null
}



+ 18
- 0
src/Navigator.jsx Ver arquivo

@@ -0,0 +1,18 @@
import React, {useState, useEffect} from 'react';

function Navigator(props) {
let recent = "recent" + (props.recent ? " selected" : '')
let archived = "archived" + (props.recent ? "" : " selected")
return (
<nav>
<button onClick={() => props.onPageChange(true)}
className={recent}>Recent
</button>
<button onClick={() => props.onPageChange(false)}
className={archived}>Archived
</button>
</nav>
)
}

export default Navigator

Carregando…
Cancelar
Salvar