-
Notifications
You must be signed in to change notification settings - Fork 31
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
Conversation
There was a problem hiding this 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!
packages/AlertDialog/index.tsx
Outdated
flex-grow: 1; | ||
flex-shrink: 1; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
packages/AlertDialog/index.tsx
Outdated
interface ColorProps { | ||
color: string; | ||
} |
There was a problem hiding this comment.
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
...
packages/AlertDialog/index.tsx
Outdated
{ | ||
isOpen = false, | ||
type = 'alert', | ||
color = '#000000', |
There was a problem hiding this comment.
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 🤔
packages/AlertDialog/index.tsx
Outdated
`; | ||
|
||
type Styles = { | ||
modalContainer?: StyleProp<ViewStyle>; |
There was a problem hiding this comment.
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'];
packages/AlertDialog/index.tsx
Outdated
<> | ||
<Modal | ||
isOpen={isOpen} | ||
style={modalStyles.modal} |
There was a problem hiding this comment.
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!
packages/AlertDialog/package.json
Outdated
"types": "lib/index.d.ts", | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"postinstall": "tsc", |
There was a problem hiding this comment.
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'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/AlertDialog/README.md
Outdated
|
||
``` | ||
yarn add dooboo-ui | ||
``` | ||
|
||
or | ||
|
There was a problem hiding this comment.
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.
- 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
f145d66
to
b7b8779
Compare
There was a problem hiding this 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
packages/AlertDialog/index.tsx
Outdated
<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 = ( |
There was a problem hiding this comment.
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
.
packages/AlertDialog/index.tsx
Outdated
{type === 'alert' && renderAlert} | ||
{type === 'confirm' && renderConfirm} | ||
{type === 'prompt' && renderPrompt} |
There was a problem hiding this comment.
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()
.
packages/AlertDialog/index.tsx
Outdated
`; | ||
|
||
type Styles = { | ||
modalContainer?: StyleProp<ViewStyle>; | ||
modal?: ModalProps['style']; |
There was a problem hiding this comment.
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.
packages/AlertDialog/index.tsx
Outdated
<ButtonText isAdditional style={styles?.buttonText}> | ||
CANCEL | ||
</ButtonText> |
There was a problem hiding this comment.
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!
packages/AlertDialog/index.tsx
Outdated
<ButtonText isAdditional style={styles?.buttonText}> | ||
CANCEL | ||
</ButtonText> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here!
There was a problem hiding this 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.
- replace createRef -> useRef - renderAlert make FC - separate style, styles - destructure props, styles
- Update Readme - Implement renderPrimaryButton, renderAdditionalButton
Codecov Report
@@ 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 |
There was a problem hiding this 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 🙏
Description
[Implement] AlertDialog
Drafted and implemented AlertDialog.
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.yarn test
oryarn test -u
if you need to update snapshot.yarn lint