Skip to content

Commit

Permalink
Feat/button ghost (#38)
Browse files Browse the repository at this point in the history
* fist draft

* add whitespace nowrap

* udpate changelog
  • Loading branch information
severinlandolt authored Jun 19, 2024
1 parent a3de51b commit 3e1f3a6
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Tremor Raw Button [v0.0.0]
// Tremor Raw Button [v0.1.0]

import React from "react"
import { Slot } from "@radix-ui/react-slot"
Expand All @@ -11,7 +11,7 @@ import { focusRing } from "../../utils/focusRing"
const buttonVariants = tv({
base: [
// base
"relative inline-flex items-center justify-center rounded-md border px-3 py-1.5 text-center text-sm font-medium shadow-sm transition-all duration-100 ease-in-out",
"relative inline-flex items-center justify-center whitespace-nowrap rounded-md border px-3 py-1.5 text-center text-sm font-medium shadow-sm transition-all duration-100 ease-in-out",
// disabled
"disabled:pointer-events-none disabled:shadow-none",
// focus
Expand Down Expand Up @@ -60,6 +60,19 @@ const buttonVariants = tv({
"disabled:bg-gray-100 disabled:text-gray-400",
"disabled:dark:bg-gray-800 disabled:dark:text-gray-600",
],
ghost: [
// base
"shadow-none",
// border
"border-transparent",
// text color
"text-gray-900 dark:text-gray-50",
// hover color
"bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800/80",
// disabled
"disabled:text-gray-400",
"disabled:dark:text-gray-600",
],
destructive: [
// text color
"text-white",
Expand Down
8 changes: 8 additions & 0 deletions src/components/Button/button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ test.describe("Expect button variant", () => {
.getByRole("button", { name: "Light" }),
).toBeVisible()
})
test("ghost to exist", async ({ page }) => {
await page.goto("http://localhost:6006/?path=/story/ui-button--ghost")
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByRole("button", { name: "Ghost" }),
).toBeVisible()
})
test("destructive to exist", async ({ page }) => {
await page.goto("http://localhost:6006/?path=/story/ui-button--destructive")
await expect(
Expand Down
7 changes: 7 additions & 0 deletions src/components/Button/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ export const Light: Story = {
},
}

export const Ghost: Story = {
args: {
variant: "ghost",
children: "Ghost",
},
}

export const Destructive: Story = {
args: {
variant: "destructive",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Button/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Tremor Raw Button Changelog

## 0.0.0
## 0.1.0

### Changes

- Feat: Ghost variant

0 comments on commit 3e1f3a6

Please sign in to comment.