Skip to content
Open
7 changes: 7 additions & 0 deletions src/components/Card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
opacity: 1;
}
}

border: 2px solid transparent;

&:focus {
border: 2px solid var(--focus-outline-color-light);
outline: none;
}
}

.shape {
Expand Down
10 changes: 8 additions & 2 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ export type CardItem = {
buttonIcon?: 'arrow-right' | 'external-arrow'
}

export default function Card({ title, href, description, theme, buttonIcon = "arrow-right" }: CardItem) {
export default function Card({
title,
href,
description,
theme,
buttonIcon = 'arrow-right',
}: CardItem) {
const [isHovered, setIsHovered] = useState(false)

return (
Expand Down Expand Up @@ -47,7 +53,7 @@ export default function Card({ title, href, description, theme, buttonIcon = "ar

{href && (
<Button
as="button"
as="div"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Button Component Fails with as="div"

The Button component, when as="div", fails to resolve the component type if linkComponentMap lacks a 'div' entry, causing a runtime error ('Element type is invalid'). Additionally, its logic incorrectly passes anchor-specific attributes (href, target, rel, download, disabled) to the div element (due to applying them whenever as !== 'button'), resulting in invalid HTML and React warnings. The Button component should ensure proper component resolution for as="div" and only apply anchor-related attributes for 'a' or 'link' types.

Additional Locations (1)
Fix in Cursor Fix in Web

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Button Component Fails When Using as="div"

The Button component in Card.tsx now uses as="div". This is problematic because the Button component relies on linkComponentMap to resolve its underlying element. If linkComponentMap does not include a 'div' entry, the resolved component will be undefined, leading to a React "Element type is invalid" runtime error. Additionally, even if 'div' were supported, the Button component currently passes link-specific props (like href) to non-button elements when as is not 'button', which would result in invalid attributes on the div. This change introduces a high risk of a runtime crash.

Fix in Cursor Fix in Web

label={false}
type={theme === 'dark' ? 'secondary' : 'primary'}
icon={buttonIcon}
Expand Down
1 change: 0 additions & 1 deletion src/components/Input/input.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
overflow: hidden;
color: var(--input-color);
font-style: normal;
outline: none;
width: 100%;
margin-bottom: 4px;

Expand Down
7 changes: 7 additions & 0 deletions src/components/elements/buttons/button/button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@

mask-image: radial-gradient(white, black);

border: 2px solid transparent;

&:focus {
border: 2px solid var(--focus-outline-color-light);
outline: none;
}

&:before {
content: '';

Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/buttons/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ButtonProps {
href?: string
onClick?: () => void
disabled?: boolean
as?: 'link' | 'a' | 'button'
as?: 'link' | 'a' | 'button' | 'div'
external?: boolean
rel?: string | boolean
download?: boolean | string
Expand Down
1 change: 1 addition & 0 deletions src/scss/app.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import 'commons/reset';
@import 'commons/focus';
@import 'commons/typescale';
@import 'commons/utils';
@import 'commons/animations';
Expand Down
8 changes: 8 additions & 0 deletions src/scss/commons/_focus.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
:root {
--focus-outline-color-light: #0066cc;
--focus-outline-color-dark: #4da6ff;
}

[data-theme='dark'] {
--focus-outline-color-light: var(--focus-outline-color-dark);
}
7 changes: 0 additions & 7 deletions src/scss/commons/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ button {
background: none;
}

a,
li,
button {
outline-color: var(--general-white);
}

input,
select,
button,
Expand All @@ -168,7 +162,6 @@ textarea {

appearance: none;
border: none;
outline: none;
}

input[type='submit'] {
Expand Down
Loading