Skip to content

Commit 8fdedc5

Browse files
authored
fix: The FAB floating button gets triggered when I am near to its padding area. (#243)
* Formated the code for future use with code maintainability. Signed-off-by: Owaise Imdad <owaiseimdad@gmail.com> * Fab global is added. Signed-off-by: Owaise Imdad <owaiseimdad@gmail.com> --------- Signed-off-by: Owaise Imdad <owaiseimdad@gmail.com>
1 parent 4acb5e9 commit 8fdedc5

File tree

2 files changed

+57
-45
lines changed

2 files changed

+57
-45
lines changed

src/components/FabButton.tsx

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,66 @@ import { Fab, Action } from "react-tiny-fab";
22
import { MdExplore } from "react-icons/md";
33
import { FaCircleQuestion } from "react-icons/fa6";
44
import tour from "../components/Tour";
5+
import FabGlobalStyle from "../styles/components/FabGlobalStyles";
56

67
const FloatingFAB = () => {
78
const startTourEvent = () => {
89
void tour.start();
910
};
1011

1112
return (
12-
<Fab
13-
icon={<FaCircleQuestion />}
14-
alwaysShowTitle
15-
mainButtonStyles={{
16-
backgroundColor: "#1B2540",
17-
color: "white",
18-
width: "50px",
19-
height: "50px",
20-
boxShadow: "0px 6px 10px rgba(0, 0, 0, 0.25)",
21-
borderRadius: "50%",
22-
transition: "all 0.3s ease-in-out",
23-
display: "flex",
24-
justifyContent: "center",
25-
alignItems: "center",
26-
fontSize: "24px",
27-
}}
28-
style={{
29-
position: "fixed",
30-
bottom: "20px",
31-
right: "20px",
32-
zIndex: 1000,
33-
marginBottom: "2.813rem",
34-
marginRight: "0.625rem"
35-
}}
36-
>
37-
<Action
38-
text="Start Tour"
39-
onClick={startTourEvent}
40-
style={{
41-
backgroundColor: "#444444",
13+
<>
14+
<FabGlobalStyle />
15+
<Fab
16+
icon={<FaCircleQuestion />}
17+
alwaysShowTitle
18+
mainButtonStyles={{
19+
backgroundColor: "#1B2540",
4220
color: "white",
43-
width: "45px",
44-
height: "45px",
21+
width: "50px",
22+
height: "50px",
23+
boxShadow: "0px 6px 10px rgba(0, 0, 0, 0.25)",
24+
borderRadius: "50%",
25+
transition: "all 0.3s ease-in-out",
4526
display: "flex",
4627
justifyContent: "center",
4728
alignItems: "center",
48-
borderRadius: "50%",
49-
fontSize: "22px",
50-
transition: "transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out",
51-
boxShadow: "0px 4px 8px rgba(0, 0, 0, 0.2)",
29+
fontSize: "24px",
30+
padding: "5px",
31+
}}
32+
style={{
33+
position: "fixed",
34+
bottom: "20px",
35+
right: "20px",
36+
zIndex: 1000,
37+
marginBottom: "2.813rem",
38+
marginRight: "0.625rem",
5239
}}
53-
onMouseEnter={(e) =>
54-
(e.currentTarget.style.transform = "scale(1.1)")
55-
}
56-
onMouseLeave={(e) =>
57-
(e.currentTarget.style.transform = "scale(1)")
58-
}
5940
>
60-
<MdExplore />
61-
</Action>
62-
</Fab>
41+
<Action
42+
text="Start Tour"
43+
onClick={startTourEvent}
44+
style={{
45+
backgroundColor: "#444444",
46+
color: "white",
47+
width: "45px",
48+
height: "45px",
49+
display: "flex",
50+
justifyContent: "center",
51+
alignItems: "center",
52+
borderRadius: "50%",
53+
fontSize: "22px",
54+
transition:
55+
"transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out",
56+
boxShadow: "0px 4px 8px rgba(0, 0, 0, 0.2)",
57+
}}
58+
onMouseEnter={(e) => (e.currentTarget.style.transform = "scale(1.1)")}
59+
onMouseLeave={(e) => (e.currentTarget.style.transform = "scale(1)")}
60+
>
61+
<MdExplore />
62+
</Action>
63+
</Fab>
64+
</>
6365
);
6466
};
6567

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createGlobalStyle } from 'styled-components';
2+
3+
const FabGlobalStyle = createGlobalStyle`
4+
.rtf--mb__c {
5+
margin: 0 !important;
6+
padding: 0 !important;
7+
}
8+
`;
9+
10+
export default FabGlobalStyle;

0 commit comments

Comments
 (0)