From 5a2dbfa69c9cf9bb155ef35fb8aa8ada63709f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Soko=C5=82owski?= Date: Wed, 24 Feb 2021 20:57:34 +0100 Subject: [PATCH] add modal onclick node --- src/components/Navigation/index.jsx | 112 ++-------------------------- src/components/Node/Joint.jsx | 50 ++++++++++--- src/components/Node/Leaf.jsx | 40 ++++++++-- src/components/Tree.jsx | 6 +- src/css/inputs.scss | 4 + src/css/main.scss | 2 + 6 files changed, 94 insertions(+), 120 deletions(-) diff --git a/src/components/Navigation/index.jsx b/src/components/Navigation/index.jsx index e0d8052..2a62e3b 100644 --- a/src/components/Navigation/index.jsx +++ b/src/components/Navigation/index.jsx @@ -46,28 +46,7 @@ function Navigation({ onPrepareConfig }) { { value: 'fries', name: 'Fries' }, { value: 'milkshake', name: 'Milkshake' }, ]); - - // useEffect(() => { - // //window.addEventListener('resize', () => handleResizeButtonsStyle()); - // }, []); - - const handleSetAttributes = () => { - let array = []; - builder.allAttributes.forEach(element => { - if (decisionAttribute != null && element === decisionAttribute) - array.push({ value: element, name: element, disabled: true }); - else array.push({ value: element, name: element }); - }); - return array; - }; - // const handleResizeButtonsStyle = () => { - // const windowSize = window.innerWidth; - // if (windowSize < 6000) setSize('xl'); - // if (windowSize < 3000) setSize('lg'); - // if (windowSize < 1900) setSize('md'); - // if (windowSize < 1200) setSize('sm'); - // if (windowSize < 530) setSize('xs'); - // }; + const [isLoad, setIsLoad] = useState(false); function handleSelectDecision(value) { //console.log(value); @@ -95,7 +74,7 @@ function Navigation({ onPrepareConfig }) { * */ function handleGetAllAttributes({ allAttributes, data }) { - //console.log(allAttributes, data); + console.log(allAttributes, data); let array = []; allAttributes.forEach(element => { array.push({ value: element, name: element }); @@ -123,6 +102,8 @@ function Navigation({ onPrepareConfig }) { function handleDrawTree() { setConfig(prepareConfig()); onPrepareConfig(prepareConfig()); + setIsLoad(true); + setTimeout(() => setIsLoad(false), 500); } return ( @@ -135,7 +116,7 @@ function Navigation({ onPrepareConfig }) { backgroundColor={'#a9bcd0ff'} fontSize={['xs', 'xs', 'sm', 'sm', 'md']} > - + @@ -152,7 +134,7 @@ function Navigation({ onPrepareConfig }) { - + Decision attribute Draw @@ -230,85 +213,6 @@ function Navigation({ onPrepareConfig }) { - // ); } diff --git a/src/components/Node/Joint.jsx b/src/components/Node/Joint.jsx index d5a5e85..071d3c1 100644 --- a/src/components/Node/Joint.jsx +++ b/src/components/Node/Joint.jsx @@ -1,21 +1,53 @@ -import React from 'react'; +import { + Badge, + Box, + Button, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + useDisclosure, +} from '@chakra-ui/react'; +import React, { useState } from 'react'; function Joint({ children, attr2, predicateName, pivot, match, notMatch, onChange }) { + const { isOpen, onOpen, onClose } = useDisclosure(); + const [size, setSize] = useState('lg'); + + const handleSizeClick = () => { + onOpen(); + }; return ( -
-

+ + {attr2} {predicateName} {pivot} -

-
+ + + + + + {attr2} {predicateName} {pivot} + + + Text ( kolejny komponent z konfiguratorem) + + + + + + {/*
Match - {/* {JSON.stringify(match)} */} + {JSON.stringify(match)}
notMatch - {/* {JSON.stringify(notMatch)} */} -
+ {JSON.stringify(notMatch)} +
*/} {children} -
+ ); } diff --git a/src/components/Node/Leaf.jsx b/src/components/Node/Leaf.jsx index de1337a..d077d87 100644 --- a/src/components/Node/Leaf.jsx +++ b/src/components/Node/Leaf.jsx @@ -1,12 +1,42 @@ +import { Box } from '@chakra-ui/react'; import React from 'react'; function Leaf({ category, matchedCount, notMatchedCount, quality }) { return ( -
-

- {category} {matchedCount} {notMatchedCount} {quality} -

-
+ + + Category: {category} + + + {matchedCount} good • {notMatchedCount} bad + + + {quality}% + + ); } diff --git a/src/components/Tree.jsx b/src/components/Tree.jsx index b3aeae5..6ca6fc8 100644 --- a/src/components/Tree.jsx +++ b/src/components/Tree.jsx @@ -1,4 +1,5 @@ import React, { useEffect, useMemo } from 'react'; +import { Box } from '@chakra-ui/react'; import { buildDecisionTree } from '../utils/decision-tree'; // import { start } from '../services/Playground'; // import { dt } from '../services/TSP'; @@ -29,10 +30,11 @@ const Tree = ({ options }) => {

Nodes:

- {}} /> + + {}} /> + ); }; -//{/* */} export default Tree; diff --git a/src/css/inputs.scss b/src/css/inputs.scss index f1d822b..7a4a547 100644 --- a/src/css/inputs.scss +++ b/src/css/inputs.scss @@ -5,3 +5,7 @@ border-radius: 0.375rem; } } +.select-search__value { + z-index: 2; + position: absolute; +} diff --git a/src/css/main.scss b/src/css/main.scss index 18d65ce..a4f7b46 100644 --- a/src/css/main.scss +++ b/src/css/main.scss @@ -53,6 +53,7 @@ $gradient-radial: radial-gradient(#d8dbe2ff, #a9bcd0ff, #58a4b0ff, #373f51ff, #1 transition: all 0.5s; background: white; color: #333; + // width: 50%; } .node.highlight { background: #09f; @@ -61,4 +62,5 @@ $gradient-radial: radial-gradient(#d8dbe2ff, #a9bcd0ff, #58a4b0ff, #373f51ff, #1 #tree { text-align: left; + //background-color: green; }