Skip to content

Commit

Permalink
💄 add Pill component
Browse files Browse the repository at this point in the history
  • Loading branch information
ElianCodes committed Mar 19, 2023
1 parent 34c9b5f commit f2d9441
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
5 changes: 3 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ declare module '@eliancodes/brutal-ui' {

export function Button(props: ButtonProps): any;

type CardProps = {
type DefaultColorProps = {
color?: string;
}

export function Card(props: CardProps): any;
export function Card(props: DefaultColorProps): any;
export function Pill(props: DefaultColorProps): any;
}
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as Button } from './src/components/Button.astro';
export { default as Card } from './src/components/Card.astro';
export { default as Card } from './src/components/Card.astro';
export { default as Pill } from './src/components/Pill.astro';
39 changes: 39 additions & 0 deletions src/components/Pill.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
interface Props {
color?: string;
}
import colors from '../config/colors.json';
if (Astro.props.color === undefined) {
Astro.props.color =
colors.colors[Math.floor(Math.random() * colors.colors.length)];
}
const { color } = Astro.props;
---

<style define:vars={{ color: color }}>
span.brutal-pill {
filter: drop-shadow(3px 3px 0 rgb(0 0 0 / 1));
user-select: none;
background-color: white;
border-radius: 9999px;
border: 2px solid black;
padding: 0.25rem 0.75rem;
transition: all;
transition-duration: 0.5s;
animation: ease-in-out;
font-size: small;
}

span.brutal-pill:hover {
filter: drop-shadow(5px 5px 0 rgb(0 0 0 / 1));
background-color: var(--color);
}
</style>

<span
class="brutal-pill"
>
<slot />
</span>

0 comments on commit f2d9441

Please sign in to comment.