Skip to content

WIP: Feature/dialog component#115

Open
votoan410 wants to merge 16 commits intomasterfrom
feature/dialog-component
Open

WIP: Feature/dialog component#115
votoan410 wants to merge 16 commits intomasterfrom
feature/dialog-component

Conversation

@votoan410
Copy link
Copy Markdown
Collaborator

work in progress (WIP): working on unit test.

const handleClose = (inputValue: string) => {
action(inputValue);
setModalState(false);
console.log('value from dialog: ', inputValue);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove for production

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed console.log

const handleClose = (inputValue?: string) => {
setModalState(false);
if (inputValue) {
console.log('value from dialog: ', inputValue);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since we are using the storybook, would it be better to use action instead of console.log?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed console.log

const handleClose = (inputValue?: string) => {
setModalState(false);
if (inputValue) {
console.log('value from dialog: ', inputValue);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as line 81

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed console.log

const handleClose = (inputValue: string) => {
action(inputValue);
setModalState(false);
console.log('value from dialog: ', inputValue);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as line 81

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed console.log

const handleClose = (inputValue: string) => {
action(inputValue);
setModalState(false);
console.log('value from dialog: ', inputValue);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as line 81

Comment on lines +14 to +15
import { action } from '@storybook/addon-actions';
import { DiffColorIcon } from '../Icon/Icon.stories';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove unused imports

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed

Children,
ReactElement,
cloneElement,
ReactNode,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove unused import

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed

Comment on lines +63 to +65
useEffect(() => {
// console.log('current onclose: ', onClose);
}, [onClose]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

seems like a useless code, should be removed

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed

Comment on lines +141 to +150
useEffect(() => {
if (props.children) {
console.log(
'children props: ',
props.children,
' and its types: ',
typeof props.children
);
}
}, [props.children]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this part for testing purposes? Try to avoid any console.log statements for production

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed

Comment on lines +168 to +170
// style={{
// width: widthOutput,
// }}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove useless code

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

removed

<button
className={`${showModal ? 'blur' : ''}`}
onClick={() => {
// action('button clicked');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove if not used

import { render, cleanup, fireEvent } from '@testing-library/react';
import Dialog from './index';

// react
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not sure what this line does

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You mean cleanup? I want to prevent memory leak and tests which are not "idempotent" (which can lead to difficult to debug errors in your tests), that's why I call cleanup after each test.

width: widthOutput,
};

// fullview logic
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

you mean full screen here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yes MUI they call it full view as props name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants