Skip to content

Commit 05c8d95

Browse files
committed
Refactor Button props to use prefixed variables and enhance modal options with _onShow and _onHide handlers. Add updated framer-motion dependencies.
1 parent f67cdc1 commit 05c8d95

File tree

5 files changed

+52
-17
lines changed

5 files changed

+52
-17
lines changed

example/src/components/atoms/Button/Button.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ const Button = ({
6161
className={className}
6262
type={type}
6363
style={style}
64-
color={color}
65-
size={size}
66-
isBlock={isBlock}
67-
isOutline={isOutline}
68-
isLink={isLink}
64+
$color={color}
65+
$size={size}
66+
$isBlock={isBlock}
67+
$isOutline={isOutline}
68+
$isLink={isLink}
6969
onClick={handleClick}
7070
onMouseDown={onMouseDown}
7171
disabled={disabled}
@@ -82,11 +82,11 @@ export default Button;
8282

8383

8484
const ButtonRoot = styled.button<{
85-
isBlock?: boolean,
86-
isOutline?: boolean,
87-
isLink?: boolean,
88-
color?: TThemeColor,
89-
size?: TLabelSize,
85+
$isBlock?: boolean,
86+
$isOutline?: boolean,
87+
$isLink?: boolean,
88+
$color?: TThemeColor,
89+
$size?: TLabelSize,
9090
onClick?: any,
9191
}>`
9292
@@ -102,13 +102,13 @@ const ButtonRoot = styled.button<{
102102
border-radius: .25rem;
103103
transition: background .15s ease-in-out, color .15s ease-in-out,background-color .15s ease-in-out,box-shadow .15s ease-in-out, transform .15s;
104104
border: 0 solid #444;
105-
width: ${props => props.isBlock ? '100%': 'auto'};
105+
width: ${props => props.$isBlock ? '100%': 'auto'};
106106
white-space:nowrap;
107107
box-shadow: none;
108108
109109
110-
${props => getThemeColor(props.color)}
111-
${props => getSize(props.size)}
110+
${props => getThemeColor(props.$color)}
111+
${props => getSize(props.$size)}
112112
113113
114114
@@ -125,7 +125,7 @@ const ButtonRoot = styled.button<{
125125
126126
127127
128-
${props => props.isOutline && css`
128+
${props => props.$isOutline && css`
129129
color: var(--button-bg-color);
130130
border-color: var(--button-bg-color);
131131
background-color: transparent;

example/src/components/examples/ZoomInCenter/ZoomInCenter.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ export default createModal(
2828
animation: animation.zoomInCenter,
2929
isHideWithMaskClick: true,
3030
// isFixedDisabled: false,
31+
_onShow: () => {
32+
console.log('onShow');
33+
},
34+
_onHide: () => {
35+
console.log('onHide');
36+
}
3137
}
3238
);
3339

example/yarn.lock

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,6 +2149,15 @@ framer-motion@12:
21492149
motion-utils "^12.12.1"
21502150
tslib "^2.4.0"
21512151

2152+
framer-motion@^12.x:
2153+
version "12.23.6"
2154+
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-12.23.6.tgz#29a78d0b05081fda3fdfd2f3eb4f570d7989d2e8"
2155+
integrity sha512-dsJ389QImVE3lQvM8Mnk99/j8tiZDM/7706PCqvkQ8sSCnpmWxsgX+g0lj7r5OBVL0U36pIecCTBoIWcM2RuKw==
2156+
dependencies:
2157+
motion-dom "^12.23.6"
2158+
motion-utils "^12.23.6"
2159+
tslib "^2.4.0"
2160+
21522161
fsevents@~2.3.2, fsevents@~2.3.3:
21532162
version "2.3.3"
21542163
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6"
@@ -2581,11 +2590,23 @@ motion-dom@^12.12.1:
25812590
dependencies:
25822591
motion-utils "^12.12.1"
25832592

2593+
motion-dom@^12.23.6:
2594+
version "12.23.6"
2595+
resolved "https://registry.yarnpkg.com/motion-dom/-/motion-dom-12.23.6.tgz#03856178d92a3b460797b57fa3b20e06847f8dab"
2596+
integrity sha512-G2w6Nw7ZOVSzcQmsdLc0doMe64O/Sbuc2bVAbgMz6oP/6/pRStKRiVRV4bQfHp5AHYAKEGhEdVHTM+R3FDgi5w==
2597+
dependencies:
2598+
motion-utils "^12.23.6"
2599+
25842600
motion-utils@^12.12.1:
25852601
version "12.12.1"
25862602
resolved "https://registry.yarnpkg.com/motion-utils/-/motion-utils-12.12.1.tgz#63e28751325cb9d1cd684f3c273a570022b0010e"
25872603
integrity sha512-f9qiqUHm7hWSLlNW8gS9pisnsN7CRFRD58vNjptKdsqFLpkVnX00TNeD6Q0d27V9KzT7ySFyK1TZ/DShfVOv6w==
25882604

2605+
motion-utils@^12.23.6:
2606+
version "12.23.6"
2607+
resolved "https://registry.yarnpkg.com/motion-utils/-/motion-utils-12.23.6.tgz#fafef80b4ea85122dd0d6c599a0c63d72881f312"
2608+
integrity sha512-eAWoPgr4eFEOFfg2WjIsMoqJTW6Z8MTUCgn/GZ3VRpClWBdnbjryiA3ZSNLyxCTmCQx4RmYX6jX1iWHbenUPNQ==
2609+
25892610
ms@^2.1.3:
25902611
version "2.1.3"
25912612
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"

src/MotionDrawer/MotionDrawer.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const MotionDrawer = ({
4242
modalOptions,
4343
children,
4444
}: IProps, ref?: ForwardedRef<HTMLDivElement>) => {
45-
const {style, className, isMaskHidden, isHideWithMaskClick, isBodyScrollEnable, isFixedDisabled, animation} = modalOptions ?? {className: ''};
45+
const {style, className, isMaskHidden, isHideWithMaskClick, isBodyScrollEnable, isFixedDisabled, animation, _onHide, _onShow} = modalOptions ?? {className: ''};
4646
const id = useId();
4747
const isPresent = useIsPresent();
4848

@@ -67,6 +67,14 @@ const MotionDrawer = ({
6767
};
6868
}, []);
6969

70+
useEffect(() => {
71+
if(_onShow) _onShow(id);
72+
73+
return () => {
74+
if(_onHide) _onHide(id);
75+
};
76+
}, [_onShow, _onHide]);
77+
7078

7179
/**
7280
* 渲染主內容

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export type TAnimationConfig = {
4848
transition?: Transition,
4949
}
5050

51-
export interface IModalOptions {
51+
export interface IModalOptions extends IControlVisibleStatus{
5252
animation?: TAnimationConfig
5353
className?: string
5454
style?: CSS.Properties
@@ -58,7 +58,7 @@ export interface IModalOptions {
5858
isFixedDisabled?: boolean
5959
}
6060

61-
export interface IStageModalOptions extends IModalOptions, IControlVisibleStatus{
61+
export interface IStageModalOptions extends IModalOptions{
6262
queueKey?: string
6363
animatePresenceMode?: AnimatePresenceProps['mode']
6464
}

0 commit comments

Comments
 (0)