diff --git a/src/components/todoStuff/todoCard.module.css b/src/components/todoStuff/todoCard.module.css
index baaf9c7..86cb918 100644
--- a/src/components/todoStuff/todoCard.module.css
+++ b/src/components/todoStuff/todoCard.module.css
@@ -3,17 +3,14 @@
border-radius: 2px;
padding: 5px;
margin: 6px 3px;
+ cursor: pointer;
}
.voted {
border: 2px solid #cf9;
}
-.clickable {
- cursor: pointer;
-}
-
-.clickable:hover {
+.card:hover {
background-color: #333;
border: 2px solid #f99;
}
diff --git a/src/components/todoStuff/todoRow.js b/src/components/todoStuff/todoRow.js
index 6714428..cba5bee 100644
--- a/src/components/todoStuff/todoRow.js
+++ b/src/components/todoStuff/todoRow.js
@@ -3,14 +3,16 @@ import React from 'react'
import styles from './todoRow.module.css'
export default function TodoRow(props) {
- const { categories, userId } = props
- const { name, description, category, votes, id } = props.rowData
+ const { categories, userId, onClick } = props
+ const { name, category, votes, id } = props.rowData
const voted = votes.includes(userId)
return (
{
+ onClick(props.rowData)
+ }}
className={`${styles.row} ${voted && styles.voted}`}
- title={description}
>
{`#${id}`}
{name}
diff --git a/src/components/todoStuff/todoRow.module.css b/src/components/todoStuff/todoRow.module.css
index 18af760..90085de 100644
--- a/src/components/todoStuff/todoRow.module.css
+++ b/src/components/todoStuff/todoRow.module.css
@@ -4,6 +4,12 @@
border-radius: 2px;
padding: 5px;
margin: 6px 3px;
+ cursor: pointer;
+}
+
+.row:hover {
+ background-color: #333;
+ border: 2px solid #f99;
}
.row > div {
diff --git a/src/components/todoStuff/todoSidebar.js b/src/components/todoStuff/todoSidebar.js
new file mode 100644
index 0000000..c57c6f2
--- /dev/null
+++ b/src/components/todoStuff/todoSidebar.js
@@ -0,0 +1,63 @@
+import React from 'react'
+
+import styles from './todoSidebar.module.css'
+
+export default function Todos({ card, userId, categories, columns, voteOn }) {
+ const { name, description, category, points, votes, id } = card
+ const voteable = columns[card.state].clickable
+
+ // TODO: hide vote button if not voteable
+ return (
+
+
+ #{id}
+ {name}
+
+ {categories[category].name}
+
+
+
+
+
+
Szavazatok:
+
{votes.length}
+
+
+ {description && (
+ <>
+
Leírás
+
+
+ >
+ )}
+
+ {voteable && (
+
{
+ voteOn(card)
+ }}
+ >
+ {votes.includes(userId) ? 'Szavazat visszavonása' : 'Szavazás'}
+
+ )}
+
+ )
+}
diff --git a/src/components/todoStuff/todoSidebar.module.css b/src/components/todoStuff/todoSidebar.module.css
new file mode 100644
index 0000000..8159b96
--- /dev/null
+++ b/src/components/todoStuff/todoSidebar.module.css
@@ -0,0 +1,54 @@
+.container {
+ display: flex;
+ flex-flow: column;
+ margin: 5px;
+}
+
+.container > hr {
+ width: 100%;
+}
+
+.title {
+ color: #99f;
+ font-size: 18px;
+}
+
+.name {
+ color: #99f;
+ font-size: 20px;
+ margin: 20px 0px;
+}
+
+.category {
+ word-break: break-all;
+ font-size: 10px;
+}
+
+.id {
+ font-size: 16px;
+ margin: 0px 3px;
+ color: #999;
+}
+
+.row {
+ display: flex;
+ justify-content: space-between;
+}
+
+.button {
+ border: 2px solid #99f;
+ border-radius: 3px;
+ text-align: center;
+ cursor: pointer;
+}
+
+.button:hover {
+ background-color: #333;
+}
+
+.votedtext {
+ color: #cf9;
+}
+.voted {
+ border: 2px solid #cf9;
+}
diff --git a/src/components/todoStuff/todoTable.js b/src/components/todoStuff/todoTable.js
index be909fa..01e7ae9 100644
--- a/src/components/todoStuff/todoTable.js
+++ b/src/components/todoStuff/todoTable.js
@@ -5,7 +5,7 @@ import TodoRow from './todoRow.js'
import styles from './todoTable.module.css'
export default function TodoBoard(props) {
- const { tables, cards, userId, categories } = props
+ const { tables, cards, userId, categories, onClick } = props
return (
@@ -23,6 +23,7 @@ export default function TodoBoard(props) {
{tableCards.map((card, i) => {
return (
{
@@ -13,11 +17,10 @@ const byVotes = (a, b) => {
export default function Todos() {
const [loaded, setLoaded] = useState(false)
const [columns, setColumns] = useState(null)
- const [boardCards, setBoardCards] = useState(null)
- const [tables, setTables] = useState(null)
- const [tableCards, setTableCards] = useState(null)
+ const [cards, setCards] = useState(null)
const [categories, setCategories] = useState(null)
const [userId, setUserId] = useState(null)
+ const [sidebarCard, setSidebarCard] = useState(null)
useEffect(() => {
console.info('Fetching todos')
@@ -36,72 +39,98 @@ export default function Todos() {
setCategories(data.todos.categories)
setUserId(data.userId)
- let bCards = []
- let tCards = []
- data.todos.cards.forEach((card) => {
- if (data.todos.columns[card.state].type === 'table') {
- tCards.push(card)
- } else {
- bCards.push(card)
- }
- })
-
- setTableCards(tCards.sort(byVotes))
- setBoardCards(bCards.sort(byVotes))
-
- let cols = {}
- let tables = {}
- Object.keys(data.todos.columns).forEach((key) => {
- const col = data.todos.columns[key]
- if (col.type !== 'table') {
- cols = {
- ...cols,
- [key]: col,
- }
- } else {
- tables = {
- ...tables,
- [key]: col,
- }
- }
- })
- setColumns(cols)
- setTables(tables)
-
+ setCards(data.todos.cards)
+ setColumns(data.todos.columns)
setLoaded(true)
}
- const onCardClick = (id) => {
- fetch(`${constants.apiUrl}todos?id=${id}`, {
- credentials: 'include',
- })
- .then((resp) => {
- return resp.json()
- })
- .then((data) => {
- setTodos(data)
- })
+ const onClick = (card) => {
+ setSidebarCard(card.id)
}
if (!loaded) {
return
}
+ let bCards = []
+ let tCards = []
+ cards.forEach((card) => {
+ if (columns[card.state].type === 'table') {
+ tCards.push(card)
+ } else {
+ bCards.push(card)
+ }
+ })
+ bCards = bCards.sort(byVotes)
+ tCards = tCards.sort(byVotes)
+
+ let cols = {}
+ let tables = {}
+ Object.keys(columns).forEach((key) => {
+ const col = columns[key]
+ if (col.type !== 'table') {
+ cols = {
+ ...cols,
+ [key]: col,
+ }
+ } else {
+ tables = {
+ ...tables,
+ [key]: col,
+ }
+ }
+ })
+
return (
-
-
+ {sidebarCard && (
+
{
+ setSidebarCard(null)
+ }}
+ >
+ {
+ return card.id === sidebarCard
+ })}
+ userId={userId}
+ categories={categories}
+ columns={columns}
+ voteOn={(card) => {
+ fetch(`${constants.apiUrl}todos?id=${card.id}`, {
+ credentials: 'include',
+ })
+ .then((resp) => {
+ return resp.json()
+ })
+ .then((data) => {
+ setTodos(data)
+ })
+ }}
+ />
+
+ )}
+
+
+
+
)
}
diff --git a/src/components/todoStuff/todos.module.css b/src/components/todoStuff/todos.module.css
new file mode 100644
index 0000000..e69de29
diff --git a/src/pages/contribute.js b/src/pages/contribute.js
index 4227c8f..5d32326 100644
--- a/src/pages/contribute.js
+++ b/src/pages/contribute.js
@@ -62,10 +62,9 @@ export default function contribute() {
return (
- Egy kártyára kattintva szavazhatsz. Minél több szavazat érkezik egy
- kártyára, annál magasabb lesz a pioritása. Jobb alsó szám minél több,
- annál nehezebb a feladat. Tartsd egeret kártyán részletesebb leírásért
- (ha van hozzá)
+ Egy kártyára kattintva nézheted meg a részleteket, vagy szavazhatsz.
+ Minél több szavazat érkezik egy kártyára, annál magasabb lesz a
+ pioritása. Jobb alsó szám minél több, annál nehezebb a feladat.
Itt írhatsz todo-ra ötleteket