-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update ModalRoot/ModalPage/ModalCard
- Loading branch information
Showing
58 changed files
with
2,193 additions
and
3,043 deletions.
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,55 @@ | ||
.host { | ||
position: absolute; | ||
inset: 0; | ||
background-color: rgba(0, 0, 0, 0.4); | ||
user-select: none; | ||
-webkit-tap-highlight-color: transparent; | ||
transition: opacity 0.5s ease; | ||
will-change: opacity; | ||
} | ||
|
||
.hostStateEnter { | ||
opacity: 0; | ||
transition-property: none; | ||
} | ||
|
||
.hostStateEntering { | ||
opacity: var(--vkui_internal--backdrop--opacity); | ||
transition-timing-function: ease-in; | ||
} | ||
|
||
.hostStateEntered { | ||
opacity: var(--vkui_internal--backdrop--opacity); | ||
} | ||
|
||
.hostStateExit { | ||
opacity: var(--vkui_internal--backdrop--opacity); | ||
transition-property: none; | ||
} | ||
|
||
.hostStateExiting { | ||
opacity: 0; | ||
transition-timing-function: ease-out; | ||
} | ||
|
||
.hostStateExited { | ||
opacity: 0; | ||
transition-property: none; | ||
} | ||
/* Mobile */ | ||
@media (--viewWidth-smallTabletMinus) { | ||
.hostStateEntering, | ||
.hostStateExiting { | ||
transition-duration: var(--vkui--animation_duration_l); | ||
} | ||
} | ||
/* Desktop */ | ||
@media (--viewWidth-smallTabletPlus) { | ||
.hostStateEntering { | ||
transition-duration: 0.2s; | ||
} | ||
|
||
.hostStateExiting { | ||
transition-duration: 0.1s; | ||
} | ||
} |
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 @@ | ||
'use client'; | ||
|
||
import { classNames } from '@vkontakte/vkjs'; | ||
import { useExternRef } from '../../hooks/useExternRef'; | ||
import { useCSSTransition, type UseCSSTransitionState } from '../../lib/animation/useCSSTransition'; | ||
import type { HasRootRef } from '../../types'; | ||
import styles from './Backdrop.module.css'; | ||
|
||
const transitionStateClassNames: Partial<Record<UseCSSTransitionState, string>> = { | ||
appear: styles['hostStateEnter'], | ||
appearing: styles['hostStateEntering'], | ||
appeared: styles['hostStateEntered'], | ||
enter: styles['hostStateEnter'], | ||
entering: styles['hostStateEntering'], | ||
entered: styles['hostStateEntered'], | ||
exit: styles['hostStateExit'], | ||
exiting: styles['hostStateExiting'], | ||
exited: styles['hostStateExited'], | ||
}; | ||
|
||
export interface BackdropProps extends HasRootRef<HTMLDivElement> { | ||
visible?: boolean; | ||
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void; | ||
} | ||
|
||
/** | ||
* @private | ||
*/ | ||
export const Backdrop = ({ visible, getRootRef, onClick, ...restProps }: BackdropProps) => { | ||
const [transitionState, { ref, onTransitionEnd }] = useCSSTransition<HTMLDivElement>(visible, { | ||
enableAppear: true, | ||
}); | ||
const handleRef = useExternRef(getRootRef, ref); | ||
|
||
return ( | ||
<div | ||
{...restProps} | ||
ref={handleRef} | ||
aria-hidden="true" | ||
className={classNames(styles.host, transitionStateClassNames[transitionState])} | ||
onClick={onClick} | ||
onTransitionEnd={onTransitionEnd} | ||
/> | ||
); | ||
}; |
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
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
105 changes: 61 additions & 44 deletions
105
packages/vkui/src/components/ModalCard/ModalCard.module.css
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 |
---|---|---|
@@ -1,65 +1,82 @@ | ||
.host { | ||
box-sizing: border-box; | ||
position: absolute; | ||
inset-block-start: 0; | ||
padding: 8px; | ||
inset-inline-start: 0; | ||
padding: var(--vkui--spacing_size_m); | ||
margin-inline: auto; | ||
inline-size: 100%; | ||
block-size: 100%; | ||
display: flex; | ||
align-items: flex-end; | ||
box-sizing: border-box; | ||
} | ||
|
||
.host:focus { | ||
outline: none; | ||
} | ||
|
||
.in { | ||
inline-size: 100%; | ||
margin-inline: auto; | ||
transform: translateY(calc(100% + 16px)); | ||
transition: transform 340ms var(--vkui--animation_easing_platform); | ||
.hostMaxWidthS { | ||
max-inline-size: calc(400px + var(--vkui--spacing_size_2xl)); | ||
} | ||
|
||
/** | ||
* iOS | ||
*/ | ||
.hostMaxWidthM { | ||
max-inline-size: calc(414px + var(--vkui--spacing_size_2xl)); | ||
} | ||
|
||
.ios .in { | ||
max-inline-size: 414px; | ||
.hostMaxWidthL { | ||
max-inline-size: calc(440px + var(--vkui--spacing_size_2xl)); | ||
} | ||
|
||
/** | ||
* Android + vkcom | ||
*/ | ||
/* Mobile */ | ||
@media (--viewWidth-smallTabletMinus) { | ||
.host { | ||
--vkui_internal_ModalCard--snapPoint: 100%; | ||
--vkui_internal_ModalCard--safeAreaInsetBottom: var(--vkui_internal--safe_area_inset_bottom); | ||
|
||
.android .in { | ||
max-inline-size: 440px; | ||
} | ||
position: absolute; | ||
inset-inline: 0; | ||
inset-block-end: 0; | ||
margin-block-end: var(--vkui_internal_ModalCard--safeAreaInsetBottom); | ||
transform: translate3d(0, calc(100% - var(--vkui_internal_ModalCard--snapPoint)), 0); | ||
transition: transform var(--vkui--animation_duration_l) var(--vkui--animation_easing_platform); | ||
} | ||
|
||
.vkcom .in { | ||
max-inline-size: 400px; | ||
} | ||
.hostStateEnter { | ||
transform: translate3d(0, 100%, 0); | ||
transition-property: none; | ||
} | ||
|
||
/** | ||
* Desktop | ||
*/ | ||
.hostStateEntering { | ||
transition-property: transform; | ||
transition-delay: 0.2s; | ||
} | ||
|
||
.desktop { | ||
align-items: center; | ||
} | ||
.hostStateExiting { | ||
transform: translate3d(0, 100%, 0); | ||
transition-property: transform; | ||
} | ||
|
||
.desktop .in { | ||
transform: unset; | ||
opacity: 0; | ||
transition: opacity 340ms var(--vkui--animation_easing_platform); | ||
.hostStateExited { | ||
transform: translate3d(0, 100%, 0); | ||
transition-property: transform; | ||
} | ||
} | ||
/* Desktop */ | ||
@media (--viewWidth-smallTabletPlus) { | ||
.host { | ||
margin-block: auto; | ||
opacity: 1; | ||
transition: opacity 340ms var(--vkui--animation_easing_platform); | ||
} | ||
|
||
.hostStateEnter { | ||
opacity: 0; | ||
transition-property: none; | ||
} | ||
|
||
.hostStateEntering { | ||
opacity: 1; | ||
} | ||
|
||
.hostStateExiting { | ||
opacity: 0; | ||
} | ||
|
||
/** | ||
* CMP: | ||
* ModalRoot | ||
*/ | ||
/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */ | ||
:global(.vkuiInternalModalRoot--touched) .in { | ||
transition: none; | ||
.hostStateExited { | ||
opacity: 0; | ||
} | ||
} |
Oops, something went wrong.