Skip to content

Commit

Permalink
[feat] add button component (#8)
Browse files Browse the repository at this point in the history
* add graphics, button

* update global button style

* update button styles
  • Loading branch information
jinkang-0 authored Jan 11, 2024
1 parent ff6a3eb commit 76b0d89
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 17 deletions.
63 changes: 63 additions & 0 deletions src/components/Button.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
interface Props {
href?: string; // no href = disabled
variant?: 'primary' | 'secondary' | 'menu';
}
const { href, variant = 'primary', ...rest } = Astro.props;
const classes: string[] = [];
if (!href) classes.push('disabled');
if (variant !== 'secondary') classes.push('primary');
if (variant === 'menu') classes.push('menu');
---

<a
class={classes.join(' ')}
href={href}
target="_blank"
referrerpolicy="no-referrer"
{...rest}
>
<slot />
</a>

<style lang="scss">
@use '../styles/colors';

$primary-hover: #6dbeda;
$primary-pressed: #53a0bc;

a {
border-radius: 8px;
padding: 1.25rem;
background-color: colors.$secondary;
color: colors.$text;
display: flex;
width: fit-content;
align-items: center;
gap: 0.5rem;
cursor: pointer;
transition: 100ms;

&.menu {
padding: 0.75rem;
}

&.disabled {
cursor: default;
}
}

a.primary {
background-color: colors.$primary;

&:hover {
background-color: $primary-hover;
}

&:active {
background-color: $primary-pressed;
}
}
</style>
11 changes: 11 additions & 0 deletions src/graphics/redirect_arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/graphics/stopwatch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 0 additions & 17 deletions src/styles/_global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,5 @@ a {
button {
background: none;
border: none;
border-radius: 8px;
display: flex;
gap: 0.5rem;
font-size: 1.25rem;
cursor: pointer;
}

button.primary,
button.menu {
background: colors.$primary;
}

button.secondary {
background: colors.$secondary;
}

button.menu {
font-family: fonts.$mono;
}

0 comments on commit 76b0d89

Please sign in to comment.