-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fix/dialog beta #3833
Merged
Merged
Fix/dialog beta #3833
Changes from 8 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
610336f
feat(DialogBeta): init
wlliaml 23e9446
fix(SetPasswordDialog): Use DialogBeta instead of Dialog
wlliaml b057846
feat(Message): revise p style
wlliaml 97fcf37
fix(SetEmailDialog): Use DialogBeta instead of Dialog
wlliaml ae03eee
fix(AddWalletLoginDialog): Use DialogBeta instead of Dialog
wlliaml bcfe7bf
fix(RemoveWalletLoginDialog): Use DialogBeta instead of Dialog
wlliaml f249390
fix(DialogBeta): revise selector
wlliaml d451f09
feat(DialogBeta): fix bottom space in mobile
wlliaml d2f09ac
fix(SetUserName): Use DialogBeta instead of Dialog
wlliaml 11461b3
fix(RemoveSocialLogin): Use DialogBeta instead of Dialog
wlliaml 0bf142e
fix(UniversalAuthDialog): Use DialogBeta instead of Dialog
wlliaml 7e80e4b
fix(SelectAuthMethodForm): Use DialogBeta instead of Dialog
wlliaml 38a40f5
fix(EmailLoginForm): Use DialogBeta instead of Dialog
wlliaml 44eb65e
fix(EmailSignUp): Use DialogBeta instead of Dialog
wlliaml 313f3a0
fix(DialogBeta): reuse dialog component
wlliaml 9595016
Merge branch 'develop' into fix/DialogBeta
wlliaml 9453ec4
fix(DialogBeta): reuse dialog component 2
wlliaml 6d60317
fix(AddWalletLoginDialog): fix typo
wlliaml ca718a9
fix(WalletAuthForm.Connect): remove unused code
wlliaml File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { forwardRef } from 'react' | ||
|
||
import { TextId } from '~/common/enums' | ||
import { | ||
Button, | ||
ButtonProps, | ||
IconSpinner16, | ||
TextIcon, | ||
Translate, | ||
} from '~/components' | ||
|
||
export type DialogTextButtonProps = { | ||
text: TextId | React.ReactNode | ||
color?: 'greyDarker' | 'green' | 'red' | ||
loading?: boolean | ||
} & ButtonProps | ||
|
||
export const TextButton: React.FC<DialogTextButtonProps> = ({ | ||
text, | ||
color = 'green', | ||
loading, | ||
...restProps | ||
}) => { | ||
let buttonProps: ButtonProps = restProps | ||
|
||
switch (color) { | ||
case 'greyDarker': | ||
buttonProps = { | ||
...buttonProps, | ||
textColor: 'greyDarker', | ||
textActiveColor: 'black', | ||
} | ||
break | ||
case 'green': | ||
buttonProps = { | ||
...buttonProps, | ||
textColor: 'green', | ||
textActiveColor: 'greenDark', | ||
} | ||
break | ||
case 'red': | ||
buttonProps = { | ||
...buttonProps, | ||
textColor: 'red', | ||
textActiveColor: 'redDark', | ||
} | ||
break | ||
} | ||
|
||
return ( | ||
<Button {...buttonProps}> | ||
<TextIcon | ||
size="md" | ||
weight="md" | ||
icon={loading && <IconSpinner16 size="sm" />} | ||
> | ||
{!loading ? ( | ||
typeof text === 'string' ? ( | ||
<Translate id={text as TextId} /> | ||
) : ( | ||
text | ||
) | ||
) : null} | ||
</TextIcon> | ||
</Button> | ||
) | ||
} | ||
|
||
export type DialogRoundedButtonProps = { | ||
text: TextId | React.ReactNode | ||
color?: 'greyDarker' | 'green' | 'red' | ||
icon?: React.ReactNode | ||
loading?: boolean | ||
} & ButtonProps | ||
|
||
export const RoundedButton: React.FC< | ||
React.PropsWithChildren<DialogRoundedButtonProps> | ||
> = forwardRef( | ||
({ text, color = 'green', loading, icon, disabled, ...restProps }, ref) => { | ||
let buttonProps: ButtonProps = restProps | ||
|
||
switch (color) { | ||
case 'greyDarker': | ||
buttonProps = { | ||
...buttonProps, | ||
borderColor: 'greyDarker', | ||
textColor: 'greyDarker', | ||
} | ||
break | ||
case 'green': | ||
buttonProps = { | ||
...buttonProps, | ||
borderColor: 'green', | ||
textColor: 'green', | ||
} | ||
break | ||
case 'red': | ||
buttonProps = { ...buttonProps, borderColor: 'red', textColor: 'red' } | ||
break | ||
} | ||
|
||
return ( | ||
<Button | ||
size={['100%', '3rem']} | ||
disabled={disabled || loading} | ||
ref={ref} | ||
{...buttonProps} | ||
> | ||
<TextIcon | ||
icon={icon || (loading && <IconSpinner16 size="md" />)} | ||
size="xm" | ||
weight="md" | ||
textPlacement="left" | ||
> | ||
{!loading ? ( | ||
typeof text === 'string' ? ( | ||
<Translate id={text as TextId} /> | ||
) : ( | ||
text | ||
) | ||
) : null} | ||
</TextIcon> | ||
</Button> | ||
) | ||
} | ||
) | ||
|
||
RoundedButton.displayName = 'RoundedButton' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import classNames from 'classnames' | ||
|
||
import Message from '../Message' | ||
import styles from './styles.module.css' | ||
|
||
interface DialogContentProps { | ||
noSpacing?: boolean | ||
smExtraSpacing?: boolean | ||
fixedHeight?: boolean | ||
noSpacingBottom?: boolean | ||
noMaxHeight?: boolean | ||
} | ||
|
||
const DialogContent: React.FC<React.PropsWithChildren<DialogContentProps>> & { | ||
Message: typeof Message | ||
} = ({ | ||
noSpacing, | ||
smExtraSpacing = true, | ||
noSpacingBottom, | ||
noMaxHeight, | ||
fixedHeight, | ||
children, | ||
}) => { | ||
const contentClasses = classNames({ | ||
[styles.content]: true, | ||
[styles.spacing]: !noSpacing, | ||
[styles.smExtraSpacing]: smExtraSpacing, | ||
[styles.fixedHeight]: !!fixedHeight, | ||
[styles.noSpacingBottom]: !!noSpacingBottom, | ||
[styles.noMaxHeight]: !!noMaxHeight, | ||
}) | ||
|
||
return ( | ||
<section className={contentClasses} data-dialog-entity> | ||
{children} | ||
</section> | ||
) | ||
} | ||
|
||
DialogContent.Message = Message | ||
|
||
export default DialogContent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
flex-shrink: 1; | ||
max-height: calc(70vh - 4.25rem); /* 4.25rem is the height of header */ | ||
overflow-x: hidden; | ||
overflow-y: auto; | ||
-webkit-overflow-scrolling: touch; | ||
|
||
&.fixedHeight { | ||
height: calc(70vh - 4.25rem); /* 4.25rem is the height of header */ | ||
|
||
@media (--sm-up) { | ||
height: min(30rem, 64vh); | ||
} | ||
} | ||
|
||
@media (--sm-up) { | ||
max-height: min(30rem, 64vh); | ||
} | ||
} | ||
|
||
.smExtraSpacing { | ||
padding-bottom: var(--spacing-xx-loose); | ||
|
||
@media (--sm-up) { | ||
padding-bottom: 0; | ||
} | ||
} | ||
|
||
.spacing { | ||
padding: var(--spacing-base); | ||
|
||
@media (--sm-up) { | ||
padding: 0 var(--spacing-base-loose); | ||
} | ||
} | ||
|
||
.noSpacingBottom { | ||
padding-bottom: 0; | ||
} | ||
|
||
.noMaxHeight { | ||
max-height: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import classNames from 'classnames' | ||
import React from 'react' | ||
import { FormattedMessage } from 'react-intl' | ||
|
||
import { Media } from '~/components' | ||
|
||
import { RoundedButton, TextButton } from '../Buttons' | ||
import styles from './styles.module.css' | ||
|
||
type FooterProps = { | ||
btns?: React.ReactNode | ||
smUpBtns?: React.ReactNode | ||
// smUpContentNoSpacingBottom?: boolean | ||
// smUpSpaceBetween?: boolean | ||
closeText?: React.ReactNode | ||
closeDialog?: () => any | ||
} | ||
|
||
const Footer: React.FC<FooterProps> = ({ | ||
btns, | ||
smUpBtns, | ||
// smUpContentNoSpacingBottom = false, | ||
// smUpSpaceBetween = false, | ||
closeText, | ||
closeDialog, | ||
}) => { | ||
if (!btns && !smUpBtns && !closeDialog) { | ||
return null | ||
} | ||
|
||
const text = closeText || <FormattedMessage defaultMessage="Cancel" /> | ||
|
||
const footerClasses = classNames({ | ||
[styles.footer]: true, | ||
}) | ||
const hasBtns = btns || closeDialog | ||
const hasSmUpBtns = smUpBtns || closeDialog | ||
|
||
const smUpContentClasses = classNames({ | ||
[styles.smUpContent]: true, | ||
// [styles.smUpSpaceBetween]: !!smUpSpaceBetween, | ||
// [styles.smUpContentNoSpacingBottom]: !!smUpContentNoSpacingBottom, | ||
}) | ||
|
||
const SmUpBtns = () => ( | ||
<> | ||
{hasSmUpBtns && ( | ||
<Media greaterThan="sm"> | ||
<section className={smUpContentClasses}> | ||
{closeDialog && ( | ||
<TextButton | ||
text={text} | ||
color="greyDarker" | ||
onClick={closeDialog} | ||
/> | ||
)} | ||
{smUpBtns} | ||
</section> | ||
</Media> | ||
)} | ||
</> | ||
) | ||
|
||
if (hasBtns) { | ||
return ( | ||
<footer className={footerClasses} data-dialog-entity> | ||
<Media at="sm"> | ||
<section className={styles.content}> | ||
{btns} | ||
{closeDialog && ( | ||
<RoundedButton | ||
text={text} | ||
color="greyDarker" | ||
onClick={closeDialog} | ||
/> | ||
)} | ||
</section> | ||
</Media> | ||
|
||
<SmUpBtns /> | ||
</footer> | ||
) | ||
} | ||
|
||
return ( | ||
<footer className={footerClasses}> | ||
<SmUpBtns /> | ||
</footer> | ||
) | ||
} | ||
|
||
export default Footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.footer { | ||
position: relative; | ||
} | ||
|
||
.content { | ||
@mixin flex-center-space-between; | ||
@mixin safe-area-botttom; | ||
|
||
flex-direction: column; | ||
flex-shrink: 0; | ||
padding: var(--spacing-base-loose) var(--spacing-base) 0; | ||
|
||
& > * { | ||
flex: 1; | ||
width: 100%; | ||
} | ||
|
||
& > * + * { | ||
margin-top: var(--spacing-base); | ||
} | ||
} | ||
|
||
.smUpContent { | ||
@mixin flex-center-end; | ||
|
||
padding: 0 var(--spacing-base-loose) 0; | ||
margin: var(--spacing-base) 0 var(--spacing-base-loose); | ||
text-align: right; | ||
|
||
& > * + * { | ||
margin-left: var(--spacing-x-loose); | ||
} | ||
} | ||
|
||
/* .smUpContentNoSpacingBottom { | ||
margin-bottom: 0; | ||
} | ||
.smUpSpaceBetween { | ||
@mixin flex-center-space-between; | ||
} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useIntl } from 'react-intl' | ||
|
||
import styles from './styles.module.css' | ||
|
||
interface HandleProps { | ||
closeDialog: () => void | ||
} | ||
|
||
const Handle: React.FC<HandleProps> = ({ closeDialog, ...props }) => { | ||
const intl = useIntl() | ||
|
||
return ( | ||
<button | ||
type="button" | ||
className={styles.handle} | ||
aria-label={intl.formatMessage({ defaultMessage: 'Close' })} | ||
onClick={closeDialog} | ||
{...props} | ||
> | ||
<span className={styles.icon} /> | ||
</button> | ||
) | ||
} | ||
|
||
export default Handle |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 as previous comment. can import from the original one so we can keep track the changes easier.