feature(Project): add ability to create new task groups
This commit is contained in:
@ -8,7 +8,7 @@ type Props = {
|
||||
onLabelToggle: (labelId: string) => void;
|
||||
onLabelEdit: (labelId: string, labelName: string, color: string) => void;
|
||||
};
|
||||
const LabelManager = ({ labels, onLabelToggle, onLabelEdit }: Props) => {
|
||||
const LabelManager: React.FC<Props> = ({ labels, onLabelToggle, onLabelEdit }) => {
|
||||
const [currentLabel, setCurrentLabel] = useState('');
|
||||
return (
|
||||
<>
|
||||
|
@ -1,7 +1,10 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useRef } from 'react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import LabelColors from 'shared/constants/labelColors';
|
||||
import MenuTypes from 'shared/constants/menuTypes';
|
||||
import LabelManager from 'shared/components/PopupMenu/LabelManager';
|
||||
import LabelEditor from 'shared/components/PopupMenu/LabelEditor';
|
||||
import ListActions from 'shared/components/ListActions';
|
||||
|
||||
import PopupMenu from '.';
|
||||
|
||||
export default {
|
||||
@ -34,16 +37,9 @@ export const LabelsPopup = () => {
|
||||
return (
|
||||
<>
|
||||
{isPopupOpen && (
|
||||
<PopupMenu
|
||||
title="Label"
|
||||
menuType={MenuTypes.LABEL_MANAGER}
|
||||
top={10}
|
||||
onClose={() => setPopupOpen(false)}
|
||||
left={10}
|
||||
onLabelEdit={action('label edit')}
|
||||
onLabelToggle={action('label toggle')}
|
||||
labels={labelData}
|
||||
/>
|
||||
<PopupMenu title="Label" top={10} onClose={() => setPopupOpen(false)} left={10}>
|
||||
<LabelManager labels={labelData} onLabelToggle={action('label toggle')} onLabelEdit={action('label edit')} />
|
||||
</PopupMenu>
|
||||
)}
|
||||
<button type="submit" onClick={() => setPopupOpen(true)}>
|
||||
Open
|
||||
@ -57,16 +53,9 @@ export const LabelsLabelEditor = () => {
|
||||
return (
|
||||
<>
|
||||
{isPopupOpen && (
|
||||
<PopupMenu
|
||||
title="Change Label"
|
||||
menuType={MenuTypes.LABEL_EDITOR}
|
||||
top={10}
|
||||
onClose={() => setPopupOpen(false)}
|
||||
left={10}
|
||||
onLabelEdit={action('label edit')}
|
||||
onLabelToggle={action('label toggle')}
|
||||
labels={labelData}
|
||||
/>
|
||||
<PopupMenu title="Change Label" top={10} onClose={() => setPopupOpen(false)} left={10}>
|
||||
<LabelEditor label={labelData[0]} onLabelEdit={action('label edit')} />
|
||||
</PopupMenu>
|
||||
)}
|
||||
<button type="submit" onClick={() => setPopupOpen(true)}>
|
||||
Open
|
||||
@ -74,3 +63,39 @@ export const LabelsLabelEditor = () => {
|
||||
</>
|
||||
);
|
||||
};
|
||||
const initalState = { left: 0, top: 0, isOpen: false };
|
||||
|
||||
export const ListActionsPopup = () => {
|
||||
const $buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const [popupData, setPopupData] = useState(initalState);
|
||||
return (
|
||||
<>
|
||||
{popupData.isOpen && (
|
||||
<PopupMenu
|
||||
title="List Actions"
|
||||
top={popupData.top}
|
||||
onClose={() => setPopupData(initalState)}
|
||||
left={popupData.left}
|
||||
>
|
||||
<ListActions taskGroupID="1" />
|
||||
</PopupMenu>
|
||||
)}
|
||||
<button
|
||||
ref={$buttonRef}
|
||||
type="submit"
|
||||
onClick={() => {
|
||||
if ($buttonRef && $buttonRef.current) {
|
||||
const pos = $buttonRef.current.getBoundingClientRect();
|
||||
setPopupData({
|
||||
isOpen: true,
|
||||
left: pos.left,
|
||||
top: pos.top + pos.height + 10,
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
Open
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
@ -1,25 +1,16 @@
|
||||
import React, { useRef } from 'react';
|
||||
import { Cross } from 'shared/icons';
|
||||
import useOnOutsideClick from 'shared/hooks/onOutsideClick';
|
||||
import MenuTypes from 'shared/constants/menuTypes';
|
||||
import LabelColors from 'shared/constants/labelColors';
|
||||
import LabelManager from './LabelManager';
|
||||
import LabelEditor from './LabelEditor';
|
||||
import { Container, Header, HeaderTitle, Content, Label, CloseButton } from './Styles';
|
||||
import { Container, Header, HeaderTitle, Content, CloseButton } from './Styles';
|
||||
|
||||
type Props = {
|
||||
title: string;
|
||||
top: number;
|
||||
left: number;
|
||||
menuType: number;
|
||||
labels?: Label[];
|
||||
onClose: () => void;
|
||||
|
||||
onLabelToggle: (labelId: string) => void;
|
||||
onLabelEdit: (labelId: string, labelName: string, color: string) => void;
|
||||
};
|
||||
|
||||
const PopupMenu = ({ title, menuType, labels, top, left, onClose, onLabelToggle, onLabelEdit }: Props) => {
|
||||
const PopupMenu: React.FC<Props> = ({ title, top, left, onClose, children }) => {
|
||||
const $containerRef = useRef();
|
||||
useOnOutsideClick($containerRef, true, onClose, null);
|
||||
|
||||
@ -31,17 +22,7 @@ const PopupMenu = ({ title, menuType, labels, top, left, onClose, onLabelToggle,
|
||||
<Cross />
|
||||
</CloseButton>
|
||||
</Header>
|
||||
<Content>
|
||||
{menuType === MenuTypes.LABEL_MANAGER && (
|
||||
<LabelManager onLabelEdit={onLabelEdit} onLabelToggle={onLabelToggle} labels={labels} />
|
||||
)}
|
||||
{menuType === MenuTypes.LABEL_EDITOR && (
|
||||
<LabelEditor
|
||||
onLabelEdit={onLabelEdit}
|
||||
label={{ active: false, color: LabelColors.GREEN, name: 'General', labelId: 'general' }}
|
||||
/>
|
||||
)}
|
||||
</Content>
|
||||
<Content>{children}</Content>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user