Skip to content

Commit

Permalink
Merge pull request #14 from knowankit/feat/add-horizontal-scroll
Browse files Browse the repository at this point in the history
Add dummy columns on button click
  • Loading branch information
knowankit authored Apr 30, 2021
2 parents f5834f2 + ffe8e74 commit 4ee588b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 19 deletions.
62 changes: 46 additions & 16 deletions src/components/board/columns/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,54 @@
import React, { useState } from 'react';
import { Box, Button, Heading } from '@chakra-ui/react';

const tempData = [
{ columnName: 'To-Do' },
{ columnName: 'In Progress' },
{ columnName: 'PR Raised' },
{ columnName: 'Done' }
];

const BoardColumns = () => {
const tempData = [
{ columnName: 'To-Do' },
{ columnName: 'In Progress' },
{ columnName: 'PR Raised' },
{ columnName: 'Done' }
];

const [columns, setColumns] = useState(tempData);

const loadColumns = (column, index) => {
if (columns.length - 1 !== index) {
return (
<React.Fragment key={index}>
<Heading as="h6" size="sm" mt="5px" textAlign="center">
{column.columnName}
</Heading>
<Button size="xs" my="10px" mx="5px" bg="brand" color="white">
Add a card
</Button>
</React.Fragment>
);
}

return (
<Button
key={index}
size="xs"
my="10px"
mx="5px"
colorScheme="blue"
color="white"
onClick={addColumn}>
Add a Column
</Button>
);
};

const addColumn = () => {
setColumns([...columns, { columnName: 'Test' }]);

console.log('test', columns);
};

// const addCard = () => {};

return (
<Box display="flex" height="calc(100vh - 200px)" bg="lightblue" overflowY="scroll">
<Box display="flex" overflowX="scroll">
{columns.map((column, index) => (
<Box
key={index}
Expand All @@ -22,16 +58,10 @@ const BoardColumns = () => {
flexDirection="column"
mt="10px"
mx="10px"
bg="gray">
<Heading color="white" as="h6" size="sm" mt="5px" textAlign="center">
{column.columnName}
</Heading>
<Button size="sm" my="10px" mx="5px">
Add a card
</Button>
bg={column.columnName === 'addColumn' ? '' : '#F0F0F0'}>
{loadColumns(column, index)}
</Box>
))}
{/* <Button size='sm' my='10px' mx='5px' width='20vw'>Add a column</Button> */}
</Box>
);
};
Expand Down
13 changes: 10 additions & 3 deletions src/components/sub-navbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { Box, Wrap, WrapItem, Avatar, Heading } from '@chakra-ui/react';
import { Box, Wrap, WrapItem, Avatar, Heading, Button } from '@chakra-ui/react';
import PropType from 'prop-types';
import Link from 'next/link';

import React from 'react';

const SubNavbar = ({ board }) => {
return (
<Box height="50px" bg="brand" boxShadow="md" display="flex">
<Heading ml="0.5rem" color="white" as="h3" size="lg" alignSelf="center" whiteSpace="nowrap">
<Box height="50px" bg="brand" boxShadow="md" display="flex" alignItems="center">
<Heading ml="0.5rem" color="white" as="h3" size="lg" whiteSpace="nowrap">
{board.name}
</Heading>
<Link href="/boards">
<Button size="xs" ml="10px">
Boards
</Button>
</Link>
<Box display="flex" alignItems="center" justifyContent="center" width="100%">
<Wrap>
<WrapItem>
Expand Down

1 comment on commit 4ee588b

@vercel
Copy link

@vercel vercel bot commented on 4ee588b Apr 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.