mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
* Bump @chakra-ui/icons from 1.0.3 to 1.0.6 Bumps [@chakra-ui/icons](https://github.com/chakra-ui/chakra-ui) from 1.0.3 to 1.0.6. - [Release notes](https://github.com/chakra-ui/chakra-ui/releases) - [Commits](https://github.com/chakra-ui/chakra-ui/compare/@chakra-ui/icons@1.0.3...@chakra-ui/icons@1.0.6) Signed-off-by: dependabot[bot] <support@github.com> * Bump tsdx from 0.13.3 to 0.14.1 Bumps [tsdx](https://github.com/formium/tsdx) from 0.13.3 to 0.14.1. - [Release notes](https://github.com/formium/tsdx/releases) - [Commits](https://github.com/formium/tsdx/compare/v0.13.3...v0.14.1) Signed-off-by: dependabot[bot] <support@github.com> * Bump @types/react from 16.9.52 to 17.0.3 Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 16.9.52 to 17.0.3. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react) Signed-off-by: dependabot[bot] <support@github.com> * Bump express-graphql from 0.11.0 to 0.12.0 Bumps [express-graphql](https://github.com/graphql/express-graphql) from 0.11.0 to 0.12.0. - [Release notes](https://github.com/graphql/express-graphql/releases) - [Commits](https://github.com/graphql/express-graphql/compare/v0.11.0...v0.12.0) Signed-off-by: dependabot[bot] <support@github.com> * Bump eslint-plugin-simple-import-sort from 5.0.3 to 7.0.0 Bumps [eslint-plugin-simple-import-sort](https://github.com/lydell/eslint-plugin-simple-import-sort) from 5.0.3 to 7.0.0. - [Release notes](https://github.com/lydell/eslint-plugin-simple-import-sort/releases) - [Changelog](https://github.com/lydell/eslint-plugin-simple-import-sort/blob/main/CHANGELOG.md) - [Commits](https://github.com/lydell/eslint-plugin-simple-import-sort/compare/v5.0.3...v7.0.0) Signed-off-by: dependabot[bot] <support@github.com> * Bump eslint-plugin-jsx-a11y from 6.3.1 to 6.4.1 Bumps [eslint-plugin-jsx-a11y](https://github.com/evcohen/eslint-plugin-jsx-a11y) from 6.3.1 to 6.4.1. - [Release notes](https://github.com/evcohen/eslint-plugin-jsx-a11y/releases) - [Changelog](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/CHANGELOG.md) - [Commits](https://github.com/evcohen/eslint-plugin-jsx-a11y/compare/v6.3.1...v6.4.1) Signed-off-by: dependabot[bot] <support@github.com> * Bump eslint-plugin-jest from 24.1.3 to 24.3.1 Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 24.1.3 to 24.3.1. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.3...v24.3.1) Signed-off-by: dependabot[bot] <support@github.com> * Bump eslint-import-resolver-typescript from 2.2.1 to 2.4.0 Bumps [eslint-import-resolver-typescript](https://github.com/alexgorbatchev/eslint-import-resolver-typescript) from 2.2.1 to 2.4.0. - [Release notes](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/releases) - [Changelog](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/blob/master/CHANGELOG.md) - [Commits](https://github.com/alexgorbatchev/eslint-import-resolver-typescript/compare/v2.2.1...v2.4.0) Signed-off-by: dependabot[bot] <support@github.com> * Bump eslint-config-airbnb-typescript from 9.0.0 to 12.3.1 Bumps [eslint-config-airbnb-typescript](https://github.com/iamturns/eslint-config-airbnb-typescript) from 9.0.0 to 12.3.1. - [Release notes](https://github.com/iamturns/eslint-config-airbnb-typescript/releases) - [Changelog](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/CHANGELOG.md) - [Commits](https://github.com/iamturns/eslint-config-airbnb-typescript/compare/v9.0.0...v12.3.1) Signed-off-by: dependabot[bot] <support@github.com> * Fix eslint imports * Fix tslint * lint! * lint Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
205 lines
8.3 KiB
TypeScript
205 lines
8.3 KiB
TypeScript
import { Button, ButtonGroup } from '@chakra-ui/core';
|
|
import { FC } from 'react';
|
|
import { connect } from 'react-redux';
|
|
|
|
import { MenuContainer } from '../styles/Menu';
|
|
import { ButtonColor,WhiteColor } from '../styles/Styles';
|
|
|
|
export interface MenuProps {
|
|
dispatch: any;
|
|
menu: boolean;
|
|
menuType: string;
|
|
selectedItem: number;
|
|
menuX: number;
|
|
menuY: number;
|
|
urlText: string;
|
|
popupText: string;
|
|
};
|
|
|
|
export const MenuComponent: FC<MenuProps> = ({ dispatch, menu, menuType, selectedItem, menuX, menuY, urlText, popupText }) => {
|
|
if (menuType === 'normal') {
|
|
return(
|
|
<MenuContainer style={{ left: menuX, top: menuY, opacity: menu ? 1 : 0, pointerEvents: menu ? 'inherit' : 'none' }}>
|
|
<ButtonGroup spacing={4}>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'CREATE_SQUARE' })
|
|
}}
|
|
>Square</Button>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'CREATE_CIRCLE' })
|
|
}}
|
|
>Circle</Button>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'CREATE_LINE' })
|
|
}}
|
|
>Line</Button>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
const el: any = document.querySelector('input#file-input');
|
|
el.click();
|
|
dispatch({ type: 'CREATE_IMAGE' });
|
|
}}
|
|
>Image</Button>
|
|
|
|
<input
|
|
id="file-input"
|
|
type="file"
|
|
accept="image/*"
|
|
onChange={(e: any) => {
|
|
const el: any = document.querySelector('input#file-input');
|
|
const file = el.files[0];
|
|
const reader = new FileReader();
|
|
reader.onload = (e2: any) => {
|
|
const img: any = document.querySelector(`img#image-${selectedItem}`);
|
|
img.setAttribute('src', e2.target.result);
|
|
}
|
|
reader.readAsDataURL(file);
|
|
}}
|
|
/>
|
|
</ButtonGroup>
|
|
</MenuContainer>
|
|
)
|
|
} if (menuType === 'SQUARE' || menuType === 'CIRCLE' || menuType === 'IMAGE') {
|
|
return(
|
|
<MenuContainer style={{ left: menuX, top: menuY, opacity: menu ? 1 : 0, pointerEvents: menu ? 'inherit' : 'none' }}>
|
|
<ButtonGroup spacing={4}>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'RESIZE_ITEM', index: selectedItem })
|
|
}}
|
|
>Resize</Button>
|
|
<Button
|
|
data-type="no-left-click"
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
e.preventDefault();
|
|
dispatch({ type: 'UPDATE_URL_BUTTON', index: selectedItem })
|
|
}}
|
|
>Add URL</Button>
|
|
<Button
|
|
data-type="no-left-click"
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'UPDATE_POPUP_BUTTON', index: selectedItem })
|
|
}}
|
|
>Add Popup</Button>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'DELETE_ITEM', index: selectedItem })
|
|
}}
|
|
>Delete</Button>
|
|
</ButtonGroup>
|
|
</MenuContainer>
|
|
)
|
|
} if (menuType === 'LINE') {
|
|
return(
|
|
<MenuContainer style={{ left: menuX, top: menuY, opacity: menu ? 1 : 0, pointerEvents: menu ? 'inherit' : 'none' }}>
|
|
<ButtonGroup spacing={4}>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'DELETE_ITEM', index: selectedItem })
|
|
}}
|
|
>Delete</Button>
|
|
</ButtonGroup>
|
|
</MenuContainer>
|
|
)
|
|
} if (menuType === 'url') {
|
|
return(
|
|
<MenuContainer style={{ left: menuX, top: menuY, opacity: menu ? 1 : 0, pointerEvents: menu ? 'inherit' : 'none' }} data-type="no-left-click">
|
|
<input
|
|
data-type="no-left-click"
|
|
type="text"
|
|
placeholder="URL"
|
|
value={urlText}
|
|
onChange={e => dispatch({ type: 'UPDATE_URL_TEXT', value: e.target.value })}
|
|
/>
|
|
<ButtonGroup spacing={4}>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'UPDATE_URL', index: selectedItem })
|
|
}}
|
|
>Update URL</Button>
|
|
</ButtonGroup>
|
|
</MenuContainer>
|
|
)
|
|
} if (menuType === 'popup') {
|
|
return(
|
|
<MenuContainer
|
|
className="textarea"
|
|
style={{ left: menuX, top: menuY, opacity: menu ? 1 : 0, pointerEvents: menu ? 'inherit' : 'none' }}
|
|
data-type="no-left-click">
|
|
<textarea
|
|
data-type="no-left-click"
|
|
placeholder="Popup Text"
|
|
value={popupText}
|
|
onChange={e => dispatch({ type: 'UPDATE_POPUP_TEXT', value: e.target.value })}
|
|
/>
|
|
<ButtonGroup spacing={4}>
|
|
<Button
|
|
size="sm"
|
|
leftIcon="plus-square"
|
|
backgroundColor={ButtonColor}
|
|
color={WhiteColor}
|
|
onClick={(e: any) => {
|
|
dispatch({ type: 'UPDATE_POPUP', index: selectedItem })
|
|
}}
|
|
>Update Popup</Button>
|
|
</ButtonGroup>
|
|
</MenuContainer>
|
|
)
|
|
}
|
|
return(<div/>)
|
|
}
|
|
|
|
export const Menu = connect(
|
|
(state: any) => ({
|
|
menu: state.menu,
|
|
menuType: state.menuType,
|
|
selectedItem: state.selectedItem,
|
|
menuX: state.menuX,
|
|
menuY: state.menuY,
|
|
urlText: state.urlText,
|
|
popupText: state.popupText,
|
|
}),
|
|
)(MenuComponent); |