Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AlertDialog (#71) #87

Merged
merged 7 commits into from
Sep 18, 2021
Merged

Conversation

do02reen24
Copy link
Contributor

Description

[Implement] AlertDialog

Drafted and implemented AlertDialog.

  • Provides three types of dialog: alert, confirm, and prompt.

Please comment about the structure of Component.

Related Issues

Feature request for [AlertDialog] #71

Tests

I did not add the test yet.
This PR needs more implementation.

Checklist

Before you create this PR confirms that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • Run yarn test or yarn test -u if you need to update snapshot.
  • Run yarn lint
  • I am willing to follow-up on review comments in a timely manner.

@hyochan hyochan added the 🎯 feature New feature label Aug 29, 2021
Copy link
Owner

@hyochan hyochan left a comment

Choose a reason for hiding this comment

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

Overall this is greatly done!

Just a few small improvements I can suggest here!

Comment on lines 8 to 9
flex-grow: 1;
flex-shrink: 1;
Copy link
Owner

Choose a reason for hiding this comment

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

Is there any reason not using flex: 1 instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Recently, there was an issue where UI appears differently by browser due to the change of policy that interprets flex : 1 as chrome update. I didn't use abbreviation to prevent similar issues from occurring in the future.

Comment on lines 60 to 62
interface ColorProps {
color: string;
}
Copy link
Owner

Choose a reason for hiding this comment

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

The styling principle in dooboo-ui is not to expose each nested style prop and rather expose the style itself.
For example, ViewStyle, TextStyle...

{
isOpen = false,
type = 'alert',
color = '#000000',
Copy link
Owner

Choose a reason for hiding this comment

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

This is not a request, but I think we need to think about how we can support default theme in packages 🤔

`;

type Styles = {
modalContainer?: StyleProp<ViewStyle>;
Copy link
Owner

Choose a reason for hiding this comment

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

I'd recommend you to install types for this to support typescript for dev env.

"@types/react-native-modalbox": "^1.4.9"

Then I think you'd want to change this to

modal?: ModalProps['style'];

<>
<Modal
isOpen={isOpen}
style={modalStyles.modal}
Copy link
Owner

Choose a reason for hiding this comment

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

I think it is enough to use like below.

style={[{borderRadius: 4}, styles.modal]}

Note that default styles should come first!

"types": "lib/index.d.ts",
"version": "0.0.1",
"license": "MIT",
"postinstall": "tsc",
Copy link
Owner

Choose a reason for hiding this comment

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

Adding dooboolab-welcome postinstall would make dooboolab-welcome package installed meaningful 😅

import {ContainerDeco} from '../../../storybook/decorators';
import {storiesOf} from '@storybook/react-native';
import styled from '@emotion/native';

Copy link
Owner

@hyochan hyochan Aug 29, 2021

Choose a reason for hiding this comment

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

Screen Shot 2021-08-29 at 11 29 47 PM

I think we can make this bit better by giving some paddings or margins :)

Comment on lines 17 to 23

```
yarn add dooboo-ui
```

or

Copy link
Owner

Choose a reason for hiding this comment

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

I think we need to remove this since this will be provided independently.

do02reen24 and others added 4 commits September 10, 2021 17:33
- Provides three types of dialog: alert, confirm, and prompt.
- improve style props
- add @types/react-native-modalbox
- add dooboolab-welcome postinstall
- improve storybook example improvement
- update readme
- reflect the figma design
Copy link
Owner

@hyochan hyochan left a comment

Choose a reason for hiding this comment

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

Great work overall! Hope you can take a look at few other reviews.

@yujong-lee You might want to check out how to support defaultTheme in separate package components 🤔 which is related to your recent work #105

<ModalButton onPress={() => onPress(true)}>
<ButtonText color={color}>OK</ButtonText>
<ModalButton style={styles?.button} onPress={() => onPress(true)}>
<ButtonText style={styles?.buttonText}>OK</ButtonText>
</ModalButton>
</>
);

const renderPrompt = (
Copy link
Owner

@hyochan hyochan Sep 10, 2021

Choose a reason for hiding this comment

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

I'd like to point out here that renderAlert is not a function. If you want to provide this as a function I want to ask you to change it to function renderAlert = () => ....

Currently, it is a component then you should separate the component on the outer side. Then also don't forget to rename it to PascalCase.

Comment on lines 130 to 132
{type === 'alert' && renderAlert}
{type === 'confirm' && renderConfirm}
{type === 'prompt' && renderPrompt}
Copy link
Owner

Choose a reason for hiding this comment

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

When changing render function correctly you might want to call it here renderAlert().

`;

type Styles = {
modalContainer?: StyleProp<ViewStyle>;
modal?: ModalProps['style'];
Copy link
Owner

Choose a reason for hiding this comment

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

Since modal is a parent component, I think this should go to style instead of styles.

Also in styles, I think buttonContainer, and container, modalInput can be included to customize styles.

Comment on lines 95 to 97
<ButtonText isAdditional style={styles?.buttonText}>
CANCEL
</ButtonText>
Copy link
Owner

Choose a reason for hiding this comment

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

How do user customize this text? User might want to localize this!

Comment on lines 114 to 116
<ButtonText isAdditional style={styles?.buttonText}>
CANCEL
</ButtonText>
Copy link
Owner

Choose a reason for hiding this comment

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

Same here!

stories/packages/AlertDialogStories/index.tsx Outdated Show resolved Hide resolved
stories/packages/AlertDialogStories/index.tsx Outdated Show resolved Hide resolved
stories/packages/AlertDialogStories/index.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@yujonglee yujonglee left a comment

Choose a reason for hiding this comment

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

I just left some suggestions. Hope it helps.

packages/AlertDialog/index.tsx Outdated Show resolved Hide resolved
packages/AlertDialog/index.tsx Show resolved Hide resolved
packages/AlertDialog/index.tsx Outdated Show resolved Hide resolved
stories/packages/AlertDialogStories/index.tsx Outdated Show resolved Hide resolved
- replace createRef -> useRef
- renderAlert make FC
- separate style, styles
- destructure props, styles
- Update Readme
- Implement renderPrimaryButton, renderAdditionalButton
@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #87 (e206938) into master (b69c16d) will increase coverage by 0.31%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
+ Coverage   95.50%   95.81%   +0.31%     
==========================================
  Files          22       22              
  Lines         578      574       -4     
  Branches      265      261       -4     
==========================================
- Hits          552      550       -2     
+ Misses         26       24       -2     

@yujonglee yujonglee self-requested a review September 16, 2021 16:41
Copy link
Owner

@hyochan hyochan left a comment

Choose a reason for hiding this comment

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

You've worked really hard. Thank you for giving your precious time 🙏

@hyochan hyochan merged commit 906c1c5 into hyochan:master Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants