Skip to content

Commit 8a88925

Browse files
fix: enhance Button component with hover effects and styling. also re… (#1393)
1 parent eaa48e2 commit 8a88925

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

docs/src/components/GitHubButton/index.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,14 @@ type ButtonProps = {
99
};
1010

1111
function Button({ href, children, margin = '0' }: ButtonProps): ReactNode {
12-
return (
12+
return (
1313
<a
14-
href={href}
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
style={{
18-
display: 'inline-block',
19-
padding: '8px 12px',
20-
margin: margin,
21-
borderRadius: '4px',
22-
textDecoration: 'none',
23-
border: '1px solid #ccc',
24-
color: 'var(--ifm-color-default)',
25-
fontSize: '0.85rem',
26-
}}
27-
>
28-
{children}
14+
href={href}
15+
target='_blank'
16+
rel='noopener noreferrer'
17+
className='button-interactive'
18+
>
19+
{children}
2920
</a>
3021
);
3122
}
@@ -38,7 +29,7 @@ type GitHubButtonProps = {
3829
function GitHubButton({ url, margin = '0' }: GitHubButtonProps): ReactNode {
3930
return (
4031
<Button href={url} margin={margin}>
41-
<FaGithub style={{ marginRight: '8px', verticalAlign: 'middle', fontSize: '1rem' }} />
32+
<FaGithub className='icon-button' />
4233
View on GitHub
4334
</Button>
4435
);
@@ -52,7 +43,7 @@ type YouTubeButtonProps = {
5243
function YouTubeButton({ url, margin = '0' }: YouTubeButtonProps): ReactNode {
5344
return (
5445
<Button href={url} margin={margin}>
55-
<FaYoutube style={{ marginRight: '8px', verticalAlign: 'middle', fontSize: '1rem' }} />
46+
<FaYoutube className='icon-button' />
5647
Watch on YouTube
5748
</Button>
5849
);

docs/src/css/custom.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,36 @@
215215
margin-right: 40px;
216216
}
217217
}
218+
219+
.button-interactive{
220+
display: inline-flex;
221+
align-items: center;
222+
padding: 0.5rem 1rem;
223+
font-size: 0.85rem;
224+
cursor: pointer;
225+
text-decoration: none;
226+
border: 1px solid var(--ifm-color-primary);
227+
border-radius: var(--ifm-button-border-radius, 4px);
228+
color: var(--ifm-color-primary);
229+
background: transparent;
230+
transition: background-color 150ms ease, color 150ms ease;
231+
}
232+
233+
.button-interactive:hover,
234+
.button-interactive:active,
235+
.button-interactive:focus{
236+
color: #fff;
237+
background-color: var(--ifm-color-primary);
238+
}
239+
240+
.button-interactive:focus-visible{
241+
outline: none;
242+
}
243+
244+
/* Icon spacing */
245+
.icon-button,
246+
.button-interactive svg {
247+
margin-right: 8px;
248+
vertical-align: middle;
249+
font-size: 1rem;
250+
}

0 commit comments

Comments
 (0)