-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add IconButton component (only for navbar use tbh) (#411)
* feat: add IconButton component (only for navbar use tbh) * feat: use IconButton in Navbar * fix: use custom tv * fix: make padding right slightly smaller on mobile on navbar for alignment of buttons with navbar
- Loading branch information
Showing
6 changed files
with
135 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
packages/components/src/templates/next/components/internal/IconButton/IconButton.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { BiSearch } from "react-icons/bi" | ||
|
||
import { IconButton } from "./IconButton" | ||
|
||
const meta: Meta<typeof IconButton> = { | ||
title: "Next/Internal Components/IconButton", | ||
component: IconButton, | ||
parameters: { | ||
themes: { | ||
themeOverride: "Isomer Next", | ||
}, | ||
}, | ||
} | ||
export default meta | ||
type Story = StoryObj<typeof IconButton> | ||
|
||
export const Default: Story = { | ||
args: { | ||
icon: BiSearch, | ||
}, | ||
} |
75 changes: 75 additions & 0 deletions
75
packages/components/src/templates/next/components/internal/IconButton/IconButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
"use client" | ||
|
||
import type { ButtonProps as AriaButtonProps } from "react-aria-components" | ||
import type { IconType } from "react-icons" | ||
import type { VariantProps } from "tailwind-variants" | ||
import type { SetRequired } from "type-fest" | ||
import { forwardRef } from "react" | ||
import { Button as AriaButton, composeRenderProps } from "react-aria-components" | ||
|
||
import { tv } from "~/lib/tv" | ||
import { focusRing } from "~/utils/focusRing" | ||
|
||
export const iconButtonStyles = tv({ | ||
base: "box-border w-fit cursor-pointer rounded text-center transition", | ||
extend: focusRing, | ||
variants: { | ||
variant: { | ||
clear: | ||
"bg-transparent hover:bg-base-canvas-backdrop/50 active:bg-base-canvas-backdrop/80", | ||
}, | ||
isDisabled: { | ||
true: "cursor-not-allowed", | ||
}, | ||
colorScheme: { | ||
default: "", | ||
}, | ||
size: { | ||
base: "flex h-12 w-12 items-center justify-center p-2", | ||
}, | ||
}, | ||
compoundVariants: [ | ||
{ | ||
variant: "clear", | ||
colorScheme: "default", | ||
className: "text-base-content", | ||
}, | ||
], | ||
defaultVariants: { | ||
size: "base", | ||
variant: "clear", | ||
colorScheme: "default", | ||
}, | ||
}) | ||
|
||
export const iconButtonIconStyles = tv({ | ||
base: "h-6 w-6", | ||
}) | ||
|
||
export interface IconButtonProps | ||
extends SetRequired<Omit<AriaButtonProps, "children">, "aria-label">, | ||
VariantProps<typeof iconButtonStyles> { | ||
icon: IconType | ||
} | ||
|
||
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>( | ||
({ icon: Icon, className, variant, size, colorScheme, ...props }, ref) => { | ||
return ( | ||
<AriaButton | ||
{...props} | ||
ref={ref} | ||
className={composeRenderProps(className, (className, renderProps) => | ||
iconButtonStyles({ | ||
...renderProps, | ||
variant, | ||
size, | ||
className, | ||
colorScheme, | ||
}), | ||
)} | ||
> | ||
<Icon className={iconButtonIconStyles()} /> | ||
</AriaButton> | ||
) | ||
}, | ||
) |
1 change: 1 addition & 0 deletions
1
packages/components/src/templates/next/components/internal/IconButton/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./IconButton" |
14 changes: 0 additions & 14 deletions
14
packages/components/src/templates/next/components/internal/Navbar/HamburgerIcon.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters