diff --git a/src/components/todoStuff/todoBoard.js b/src/components/todoStuff/todoBoard.js new file mode 100644 index 0000000..36d0abd --- /dev/null +++ b/src/components/todoStuff/todoBoard.js @@ -0,0 +1,49 @@ +import React from 'react' + +import TodoCard from './todoCard.js' + +import styles from './todoBoard.module.css' + +export default function TodoBoard(props) { + const { columns, cards, userId, categories, onCardClick } = props + + const clickableTypes = Object.keys(columns).reduce((acc, key) => { + const col = columns[key] + if (col.clickable) { + acc.push(key) + } + return acc + }, []) + + return ( +
+
+ {Object.keys(columns).map((key) => { + const category = columns[key] + return ( +
+
{category.name}
+ {cards.map((card, i) => { + if (card.state === key) { + // TODO: determine if clickable here + return ( + + ) + } else { + return null + } + })} +
+ ) + })} +
+
+ ) +} diff --git a/src/components/todoStuff/todoBoard.module.css b/src/components/todoStuff/todoBoard.module.css new file mode 100644 index 0000000..7e603fa --- /dev/null +++ b/src/components/todoStuff/todoBoard.module.css @@ -0,0 +1,23 @@ +.tableContainer { + overflow-y: hidden; + overflow-x: auto; + margin: 5px 0px; +} + +.table { + display: flex; + min-width: 800px; +} + +.categoryName { + text-align: center; + margin: 5px 0px; + font-size: 16px; + font-weight: bold; + color: white; + white-space: nowrap; +} + +.tableCol { + flex: 1; +} diff --git a/src/components/todoStuff/todoCard.js b/src/components/todoStuff/todoCard.js index 432addf..eaf0ea2 100644 --- a/src/components/todoStuff/todoCard.js +++ b/src/components/todoStuff/todoCard.js @@ -2,12 +2,9 @@ import React from 'react' import styles from './todoCard.module.css' -const clickableTypes = ['todo', 'blocked', 'inprogress', 'testing'] - export default function TodoCard(props) { - const { categories, type, onClick, userId } = props + const { categories, onClick, userId, clickable } = props const { name, description, category, points, votes, id } = props.cardData - const clickable = clickableTypes.includes(type) const voted = votes.includes(userId) return ( diff --git a/src/components/todoStuff/todoRow.js b/src/components/todoStuff/todoRow.js new file mode 100644 index 0000000..6714428 --- /dev/null +++ b/src/components/todoStuff/todoRow.js @@ -0,0 +1,34 @@ +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 voted = votes.includes(userId) + + return ( +
+
{`#${id}`}
+
{name}
+
+
+ {categories[category].name} +
+
+
{`Votes: ${votes.length}`}
+
+ ) +} diff --git a/src/components/todoStuff/todoRow.module.css b/src/components/todoStuff/todoRow.module.css new file mode 100644 index 0000000..18af760 --- /dev/null +++ b/src/components/todoStuff/todoRow.module.css @@ -0,0 +1,40 @@ +.row { + display: flex; + border: 2px solid #99f; + border-radius: 2px; + padding: 5px; + margin: 6px 3px; +} + +.row > div { + margin: 0px 5px; +} + +.id { + flex: 0 20px; + margin: 0px 3px; + color: #999; +} + +.description { + flex: 1; + word-break: normal; + font-size: 14px; + color: white; +} + +.votes { +} + +.voted { + border: 2px solid #cf9; +} + +.catName { + display: flex; +} + +.category { + word-break: break-all; + font-size: 10px; +} diff --git a/src/components/todoStuff/todoTable.js b/src/components/todoStuff/todoTable.js index ff18cb1..be909fa 100644 --- a/src/components/todoStuff/todoTable.js +++ b/src/components/todoStuff/todoTable.js @@ -1,80 +1,35 @@ -import React, { useState, useEffect } from 'react' +import React from 'react' -import LoadingIndicator from '../LoadingIndicator.js' -import TodoCard from './todoCard.js' +import TodoRow from './todoRow.js' -import constants from '../../constants.json' import styles from './todoTable.module.css' -export default function TodoTable() { - const [cards, setCards] = useState(null) - const [columns, setColumns] = useState(null) - const [categories, setCategories] = useState(null) - const [userId, setUserId] = useState(null) - - useEffect(() => { - console.info('Fetching todos') - fetch(`${constants.apiUrl}todos`, { - credentials: 'include', - }) - .then((resp) => { - return resp.json() - }) - .then((data) => { - setTodos(data) - }) - }, []) - - const setTodos = (data) => { - setCards( - data.todos.cards.sort((a, b) => { - return b.votes.length - a.votes.length - }) - ) - setColumns(data.todos.columns) - setCategories(data.todos.categories) - setUserId(data.userId) - } - - const onCardClick = (id) => { - fetch(`${constants.apiUrl}voteTodo?id=${id}`, { - credentials: 'include', - }) - .then((resp) => { - return resp.json() - }) - .then((data) => { - setTodos(data) - }) - } - - if (!cards || !columns || !categories) { - return - } +export default function TodoBoard(props) { + const { tables, cards, userId, categories } = props return ( -
+
- {Object.keys(columns).map((key) => { - const category = columns[key] + {Object.keys(tables).map((key) => { + const table = tables[key] + + const tableCards = cards.filter((card) => { + return card.state === key + }) + return ( -
-
{category.name}
- {cards.map((card, i) => { - if (card.state === key) { - return ( - - ) - } else { - return null - } +
+
{table.name}
+ {tableCards.map((card, i) => { + return ( + + ) })}
) diff --git a/src/components/todoStuff/todoTable.module.css b/src/components/todoStuff/todoTable.module.css index 91625be..eecc804 100644 --- a/src/components/todoStuff/todoTable.module.css +++ b/src/components/todoStuff/todoTable.module.css @@ -1,16 +1,17 @@ -.table { - display: flex; -} - -.categoryName { - text-align: center; +.tableContainer { margin: 5px 0px; - font-size: 16px; - font-weight: bold; - color: white; - white-space: nowrap; } -.tableCol { - flex: 1; +.table { + justify-content: center; +} + +.container { + flex-direction: column; +} + +.title { + text-align: center; + font-size: 20px; + font-weight: bold; } diff --git a/src/components/todoStuff/todos.js b/src/components/todoStuff/todos.js new file mode 100644 index 0000000..27956bf --- /dev/null +++ b/src/components/todoStuff/todos.js @@ -0,0 +1,107 @@ +import React, { useState, useEffect } from 'react' + +import LoadingIndicator from '../LoadingIndicator.js' +import TodoBoard from './todoBoard.js' +import TodoTable from './todoTable.js' + +import constants from '../../constants.json' + +const byVotes = (a, b) => { + return b.votes.length - a.votes.length +} + +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 [categories, setCategories] = useState(null) + const [userId, setUserId] = useState(null) + + useEffect(() => { + console.info('Fetching todos') + fetch(`${constants.apiUrl}todos`, { + credentials: 'include', + }) + .then((resp) => { + return resp.json() + }) + .then((data) => { + setTodos(data) + }) + }, []) + + const setTodos = (data) => { + 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) + + setLoaded(true) + } + + const onCardClick = (id) => { + fetch(`${constants.apiUrl}todos?id=${id}`, { + credentials: 'include', + }) + .then((resp) => { + return resp.json() + }) + .then((data) => { + setTodos(data) + }) + } + + if (!loaded) { + return + } + + return ( +
+ + +
+ ) +} diff --git a/src/data/links.json b/src/data/links.json index 2f5c064..d5e8e08 100644 --- a/src/data/links.json +++ b/src/data/links.json @@ -10,5 +10,13 @@ "data": { "href": "/data.json", "text": "Összes kérdés JSON" + }, + "irc": { + "href": "/irc", + "text": "IRC chat" + }, + "dataeditor": { + "href": "/dataeditor", + "text": "Dataeditor" } } diff --git a/src/data/tabs.json b/src/data/tabs.json index 1b08897..5179dbe 100644 --- a/src/data/tabs.json +++ b/src/data/tabs.json @@ -25,7 +25,7 @@ }, "contribute": { "href": "/contribute", - "text": "Contribute / Todos" + "text": "Todos, contribute" }, "ranklist": { "href": "/ranklist", diff --git a/src/pages/contribute.js b/src/pages/contribute.js index db67079..8c195f2 100644 --- a/src/pages/contribute.js +++ b/src/pages/contribute.js @@ -1,9 +1,8 @@ import React, { useState } from 'react' import Head from 'next/head' -import Button from '../components/Button.js' import Sleep from '../components/sleep' -import TodoTable from '../components/todoStuff/todoTable' +import Todos from '../components/todoStuff/todos' import constants from '../constants.json' import styles from './contribute.module.css' @@ -72,39 +71,26 @@ export default function contribute() { annál nehezebb a feladat. Tartsd egeret kártyán részletesebb leírásért (ha van hozzá)
- +
Itt írhatsz todo-ra ötleteket
{renderNewTaskArea()}
-
- Csak álnévvel commitolj git repókhoz! -
+
Git repos
+
+
-
Git repo links
- {Object.keys(repos.repos).map((key) => { - let repo = repos.repos[key] - return ( - - ) - })} +
    + {Object.keys(repos.repos).map((key) => { + let repo = repos.repos[key] + return ( +
  • + {repo.description} +
  • + ) + })} +
-
-
- IRC chat: egy IRC chatszoba van létrehozva egy random szerveren, ahol - tudsz azonnal üzenni, és ha épp fent vagyok akkor azonnal válaszolok -
-
) } diff --git a/src/pages/contribute.module.css b/src/pages/contribute.module.css index 1c90498..081839f 100644 --- a/src/pages/contribute.module.css +++ b/src/pages/contribute.module.css @@ -1,9 +1,3 @@ -.repos { - display: flex; - flex-direction: column; - align-items: center; -} - .description { font-size: 15px; color: white; @@ -39,3 +33,9 @@ .inputArea { display: flex; } + +.title { + color: #9999ff; + font-size: 30px; + text-align: center; +} diff --git a/src/pages/index.js b/src/pages/index.js index 6dcc390..f3f772e 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -167,6 +167,7 @@ export default function Index({ router }) { {renderMotd()} {userSpecificMotd && renderUserSpecificMotd()}
+
{renderNews()}
diff --git a/src/pages/index.module.css b/src/pages/index.module.css index c8902cb..fdfd0e0 100644 --- a/src/pages/index.module.css +++ b/src/pages/index.module.css @@ -7,10 +7,11 @@ color: white; background-color: #303030; margin: 2px; - padding: 15px 32px; + padding: 10px 5px; text-align: center; font-size: 16px; cursor: pointer; + word-wrap: break-word; display: flex; flex-direction: column; @@ -69,3 +70,8 @@ margin: 0px 5px; font-size: 24px; } + +.repos { + display: flex; + flex-direction: column; +}