-
Notifications
You must be signed in to change notification settings - Fork 325
refactor: enhance button components with interactive states and styling #1386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,92 +1,131 @@ | ||||
| import type { ReactNode } from 'react'; | ||||
| import { FaGithub, FaYoutube } from 'react-icons/fa'; | ||||
| import { MdMenuBook, MdDriveEta } from 'react-icons/md'; | ||||
| import type { ReactNode } from "react"; | ||||
| import { FaGithub, FaYoutube } from "react-icons/fa"; | ||||
| import { MdMenuBook, MdDriveEta } from "react-icons/md"; | ||||
| import { useState } from "react"; | ||||
|
|
||||
| type ButtonProps = { | ||||
| href: string; | ||||
| children: ReactNode; | ||||
| margin?: string; | ||||
| href: string; | ||||
| children: ReactNode; | ||||
| margin?: string; | ||||
| }; | ||||
|
|
||||
| function Button({ href, children, margin = '0' }: ButtonProps): ReactNode { | ||||
| return ( | ||||
| <a | ||||
| href={href} | ||||
| target="_blank" | ||||
| rel="noopener noreferrer" | ||||
| style={{ | ||||
| display: 'inline-block', | ||||
| padding: '8px 12px', | ||||
| margin: margin, | ||||
| borderRadius: '4px', | ||||
| textDecoration: 'none', | ||||
| border: '1px solid #ccc', | ||||
| color: 'var(--ifm-color-default)', | ||||
| fontSize: '0.85rem', | ||||
| }} | ||||
| > | ||||
| {children} | ||||
| </a> | ||||
| ); | ||||
| function Button({ href, children, margin = "0" }: ButtonProps): ReactNode { | ||||
| const [hover, setHover] = useState(false); | ||||
|
|
||||
| return ( | ||||
| <a | ||||
| href={href} | ||||
| target="_blank" | ||||
| rel="noopener noreferrer" | ||||
| className="button button--outline button--secondary" | ||||
|
||||
| className="button button--outline button--secondary" |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The button's cursor style is set to "pointer" in inline styles, but anchor tags with href already have pointer cursor by default. This is redundant and can be removed.
| cursor: "pointer", |
Copilot
AI
Dec 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline style object contains complex conditional logic for hover states, making it difficult to maintain and test. Consider extracting the style logic into a separate function or using CSS-in-JS libraries that support pseudo-selectors, or moving these styles to a CSS module where hover states can be defined declaratively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using useState for hover effects causes unnecessary re-renders on every mouse enter/leave event. Consider using CSS pseudo-classes (:hover, :focus) instead, which would be more performant and avoid component re-renders. CSS transitions can handle all the visual effects without state management.