Skip to content

Commit

Permalink
Fixed Hovering
Browse files Browse the repository at this point in the history
  • Loading branch information
MysticalMike60t committed Sep 10, 2024
1 parent 41cf1e1 commit a004fe1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
30 changes: 20 additions & 10 deletions src/components/UI/Buttons/Submit.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import React from "react";
import React, { useState } from "react";
import PropTypes from "prop-types";
import styles from "../../../styles";
import css from "./Submit.style";

console.log(styles); // Add this line to log the styles object

const getButtonStyles = (type) => {
const [hovering, setHovering] = useState(false);
switch (type) {
case "submit":
console.log(css(
styles.defaults.buttons.primary.background,
styles.defaults.buttons.primary.color,
styles.defaults.buttons.primary.border.color,
styles.defaults.buttons.primary.hover.background,
styles.defaults.buttons.primary.hover.color,
styles.defaults.buttons.primary.hover.border.color
));
console.log(
css(
styles.defaults.buttons.primary.background,
styles.defaults.buttons.primary.color,
styles.defaults.buttons.primary.border.color,
styles.defaults.buttons.primary.hover.background,
styles.defaults.buttons.primary.hover.color,
styles.defaults.buttons.primary.hover.border.color
)
);
return css(
styles.defaults.buttons.primary.background,
styles.defaults.buttons.primary.color,
Expand Down Expand Up @@ -54,7 +57,14 @@ const Submit = ({
const style = getButtonStyles(type);

return (
<button type={type} className={className} style={style} {...props}>
<button
type={type}
className={className}
style={hovering ? { ...style.base, ...style.hover } : style.base}
onMouseEnter={() => setHovering(true)}
onMouseLeave={() => setHovering(false)}
{...props}
>
<span className="button-content">{children}</span>
</button>
);
Expand Down
16 changes: 9 additions & 7 deletions src/components/UI/Buttons/Submit.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ const css = (
primaryHoverBorder
) => {
return {
background: primaryBackground,
color: primaryColor,
border: `1px solid ${primaryBorder}`,
borderRadius: "10px",
padding: "10px 20px",
transition: "100ms ease all",
":hover": {
base: {
background: primaryBackground,
color: primaryColor,
border: `1px solid ${primaryBorder}`,
borderRadius: "10px",
padding: "10px 20px",
transition: "100ms ease all",
},
hover: {
background: primaryHoverBackground,
color: primaryHoverColor,
border: `1px solid ${primaryHoverBorder}`,
Expand Down

0 comments on commit a004fe1

Please sign in to comment.