Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __snapshots__/badge--button-example-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/badge--button-example-firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/badge--button-example-webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/badge--variants-chromium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/badge--variants-firefox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added __snapshots__/badge--variants-webkit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions src/components/badge/Badge.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {Meta} from "@storybook/react";
import React from "react";
import Badge from "./Badge";
import Button from "../button/Button";
import {IconGitBranch} from "@tabler/icons-react";

const meta: Meta = {
title: "Badge",
component: Badge
}

export const Variants = () => {
return <>

{
["primary", "secondary", "info", "success", "warning", "error"].map(value => {
// @ts-ignore
return <Badge style={{marginRight: ".5rem"}} variant={value}>
{value}
</Badge>
})
}

</>
}

export const ButtonExample = () => {
return <Button variant={"primary"}>
<Button.Icon>
<IconGitBranch/>
</Button.Icon>
Merge Branch
<Badge style={{marginLeft: ".5rem"}} variant={"secondary"}>
Badge
</Badge>
</Button>
}

export default meta
19 changes: 19 additions & 0 deletions src/components/badge/Badge.style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "../../styles/helpers";

.badge {
@include opacityBox(false);

padding: .25rem;
display: inline-flex;
font-size: $tertiaryFontSize;
border: none;
width: fit-content;
}

@each $name, $color in $variants {
.badge--#{$name} {
@include opacityBox(false, $color);
font-size: $tertiaryFontSize;
border: none;
}
}
19 changes: 19 additions & 0 deletions src/components/badge/Badge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, {HTMLProps} from "react";
import "./Badge.style.scss"

export interface BadgeType extends HTMLProps<HTMLSpanElement>{
children: string
//defaults to primary
variant?: "primary" | "secondary" | "info" | "success" | "warning" | "error"
}

const Badge: React.FC<BadgeType> = (props) => {

const {variant = "primary", children, ...args} = props

return <span {...args} className={`badge badge--${variant}`}>
{children}
</span>
}

export default Badge
16 changes: 16 additions & 0 deletions src/styles/_helpers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@
}
}

@mixin opacityBox($active: true, $color: $secondary) {
background: rgba($color, 0.1);
@include border($active);
border-radius: $borderRadius;
color: rgba($white, .5);
font-family: Ubuntu, sans-serif;
font-size: $secondaryFontSize;
position: relative;

@if ($active == true) {
@include hoverAndActiveContent {
background: rgba($color, .2);
}
}
}

@mixin hoverAndActiveContent() {
&:hover, &:active, &--active {
@content
Expand Down