@rpg-engine/long-bow 0.8.53 → 0.8.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.8.53",
3
+ "version": "0.8.55",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,8 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
- import styled from 'styled-components';
2
+ import styled, { createGlobalStyle } from 'styled-components';
3
3
  import ModalPortal from './Abstractions/ModalPortal';
4
4
  import { Button, ButtonTypes } from './Button';
5
- import { DraggableContainer } from './DraggableContainer';
6
5
 
7
6
  export interface IConfirmModalProps {
8
7
  onConfirm: () => void;
@@ -10,90 +9,161 @@ export interface IConfirmModalProps {
10
9
  message?: string | ReactNode;
11
10
  }
12
11
 
12
+ // Global style to prevent body scrolling when modal is open
13
+ const GlobalStyle = createGlobalStyle`
14
+ body {
15
+ overflow: hidden;
16
+
17
+ width: 100%;
18
+ height: 100%;
19
+ }
20
+ `;
21
+
13
22
  export const ConfirmModal: React.FC<IConfirmModalProps> = ({
14
23
  onConfirm,
15
24
  onClose,
16
25
  message = 'Are you sure?',
17
26
  }) => {
18
- const handleConfirm = (e: React.MouseEvent) => {
19
- e.preventDefault();
20
- e.stopPropagation();
27
+ const handleConfirm = () => {
21
28
  onConfirm();
22
29
  };
23
30
 
24
- const handleClose = (e: React.MouseEvent) => {
25
- e.preventDefault();
26
- e.stopPropagation();
31
+ const handleClose = () => {
27
32
  onClose();
28
33
  };
29
34
 
35
+ const stopPropagation = (e: React.PointerEvent) => {
36
+ e.stopPropagation();
37
+ };
38
+
30
39
  return (
31
40
  <ModalPortal>
32
- <Background />
33
- <Container onClick={handleClose}>
34
- <DraggableContainer width="auto" dragDisabled>
35
- <Wrapper onClick={e => e.stopPropagation()}>
36
- {typeof message === 'string' ? <p>{message}</p> : message}
37
-
38
- <ButtonsWrapper>
39
- <div className="cancel-button">
40
- <Button
41
- buttonType={ButtonTypes.RPGUIButton}
42
- onClick={handleClose}
43
- >
44
- No
45
- </Button>
46
- </div>
41
+ <GlobalStyle />
42
+ <Overlay onPointerDown={handleClose} />
43
+ <ModalContainer>
44
+ <ModalContent onPointerDown={stopPropagation}>
45
+ <MessageContainer>
46
+ {typeof message === 'string' ? (
47
+ <Message>{message}</Message>
48
+ ) : (
49
+ message
50
+ )}
51
+ </MessageContainer>
52
+
53
+ <ButtonsContainer>
54
+ <CancelButtonWrapper>
47
55
  <Button
48
56
  buttonType={ButtonTypes.RPGUIButton}
49
- onClick={handleConfirm}
57
+ onPointerDown={handleClose}
50
58
  >
51
- Yes
59
+ No
52
60
  </Button>
53
- </ButtonsWrapper>
54
- </Wrapper>
55
- </DraggableContainer>
56
- </Container>
61
+ </CancelButtonWrapper>
62
+ <Button
63
+ buttonType={ButtonTypes.RPGUIButton}
64
+ onPointerDown={handleConfirm}
65
+ >
66
+ Yes
67
+ </Button>
68
+ </ButtonsContainer>
69
+ </ModalContent>
70
+ </ModalContainer>
57
71
  </ModalPortal>
58
72
  );
59
73
  };
60
74
 
61
- const Background = styled.div`
62
- position: absolute;
63
- width: 100%;
64
- height: 100%;
65
- background-color: #000000;
66
- opacity: 0.5;
67
- left: 0;
75
+ const Overlay = styled.div`
76
+ position: fixed;
68
77
  top: 0;
78
+ left: 0;
79
+ right: 0;
80
+ bottom: 0;
81
+ background-color: rgba(0, 0, 0, 1);
69
82
  z-index: 1000;
83
+ animation: fadeIn 0.2s ease-out;
84
+
85
+ @keyframes fadeIn {
86
+ from {
87
+ opacity: 0;
88
+ }
89
+ to {
90
+ opacity: 1;
91
+ }
92
+ }
70
93
  `;
71
94
 
72
- const Container = styled.div`
73
- position: absolute;
74
- width: 100%;
75
- height: 100%;
76
- left: 0;
95
+ const ModalContainer = styled.div`
96
+ position: fixed;
77
97
  top: 0;
98
+ left: 0;
99
+ right: 0;
100
+ bottom: 0;
78
101
  display: flex;
79
- justify-content: center;
80
102
  align-items: center;
103
+ justify-content: center;
81
104
  z-index: 1001;
105
+ padding: env(safe-area-inset-top) env(safe-area-inset-right)
106
+ env(safe-area-inset-bottom) env(safe-area-inset-left);
107
+ touch-action: none;
108
+ `;
109
+
110
+ const ModalContent = styled.div`
111
+ background: url('/assets/ui/paper-dialog.png') no-repeat center center;
112
+ background-size: 100% 100%;
113
+ padding: 20px;
114
+ min-width: 300px;
115
+ max-width: 90%;
116
+ margin: 0 auto;
117
+ animation: scaleIn 0.2s ease-out;
118
+ transform-origin: center;
119
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
120
+
121
+ @keyframes scaleIn {
122
+ from {
123
+ transform: scale(0.8);
124
+ opacity: 0;
125
+ }
126
+ to {
127
+ transform: scale(1);
128
+ opacity: 1;
129
+ }
130
+ }
131
+
132
+ @media (max-width: 768px) {
133
+ padding: 25px;
134
+ width: 85%;
135
+ }
136
+ `;
137
+
138
+ const MessageContainer = styled.div`
139
+ margin-bottom: 20px;
140
+ text-align: center;
82
141
  `;
83
142
 
84
- const Wrapper = styled.div`
85
- p {
86
- margin: 0;
143
+ const Message = styled.p`
144
+ margin: 0;
145
+ font-size: 16px;
146
+ color: #333;
147
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
148
+
149
+ @media (max-width: 768px) {
150
+ font-size: 18px;
87
151
  }
88
152
  `;
89
153
 
90
- const ButtonsWrapper = styled.div`
154
+ const ButtonsContainer = styled.div`
91
155
  display: flex;
92
- justify-content: flex-end;
93
- gap: 5px;
94
- margin-top: 5px;
156
+ justify-content: center;
157
+ gap: 20px;
95
158
 
96
- .cancel-button {
97
- filter: grayscale(0.7);
159
+ @media (max-width: 768px) {
160
+ gap: 30px;
161
+ /* Increase button size for better touch targets */
162
+ transform: scale(1.1);
163
+ margin-top: 5px;
98
164
  }
99
165
  `;
166
+
167
+ const CancelButtonWrapper = styled.div`
168
+ filter: grayscale(0.7);
169
+ `;