Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: muted listbox button #67

Merged
merged 2 commits into from
Dec 16, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@inkonchain/ink-kit",
"version": "0.3.6",
"version": "0.3.8",
"description": "",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
Expand Down
4 changes: 3 additions & 1 deletion src/components/ListItem/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { classNames, variantClassNames } from "../../util/classes";

export interface ListItemProps
extends PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>> {
variant?: "default" | "secondary" | "error";
variant?: "default" | "secondary" | "error" | "muted";
disabled?: boolean;
asChild?: boolean;
className?: string;
Expand Down Expand Up @@ -35,6 +35,8 @@ export const ListItem: React.FC<ListItemProps> = ({
secondary:
"ink:bg-button-secondary ink:hover:bg-button-secondary-hover ink:active:bg-button-secondary-pressed ink:data-active:bg-button-secondary-pressed ink:text-button-secondary-text",
error: "ink:text-status-error ink:hover:bg-status-error-bg",
muted:
"ink:bg-background-container ink:text-text-muted ink:border-1 ink:border-transparent ink:focus:border-text-on-secondary ink:transition-colors ink:transition-default-animation",
}),
"ink:data-disabled:text-text-muted ink:data-disabled:cursor-not-allowed",
className
Expand Down
23 changes: 23 additions & 0 deletions src/components/Listbox/Listbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,26 @@ export const WithManyOptions: Story = {
);
},
};

export const WithADifferentButtonVariant: Story = {
args: {
children: (
<ListboxOptions>
{[...defaultItems, ...moreItems].map((item) => (
<ListboxOption key={item.value} value={item}>
{item.label}
</ListboxOption>
))}
</ListboxOptions>
),
},
render: (args) => {
const [item, setValue] = useState<ListboxStoryItem>(defaultItems[0]);
return (
<Listbox value={item} onChange={setValue}>
<ListboxButton variant="muted">Selected: {item.label}</ListboxButton>
{args.children}
</Listbox>
);
},
};
1 change: 0 additions & 1 deletion src/components/Listbox/Listbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { PropsWithChildren } from "react";
export interface ListboxProps<T> extends PropsWithChildren {
value: T;
onChange: (value: T) => void;
className?: string;
/** If you provide `multiple`, then `value` and `onChange` must use an array. */
multiple?: boolean;
}
Expand Down
10 changes: 7 additions & 3 deletions src/components/Listbox/ListboxButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ import { ListboxButton as HeadlessListboxButton } from "@headlessui/react";
import { forwardRef } from "react";
import { InkIcon } from "../..";
import { ListItem, ListItemProps } from "../ListItem";
import { classNames } from "../../util/classes";

interface ListboxButtonProps extends ListItemProps {
className?: string;
}

export const ListboxButton = forwardRef<HTMLButtonElement, ListboxButtonProps>(
({ className, children, ...props }, ref) => {
({ className, children, variant = "secondary", ...props }, ref) => {
return (
<HeadlessListboxButton
className={className}
className={classNames(
className,
"ink:focus-visible:outline-none ink:data-active:border-text-on-secondary"
)}
ref={ref}
as={ListItem}
variant="secondary"
variant={variant}
iconRight={<InkIcon.Chevron />}
{...props}
>
Expand Down
2 changes: 1 addition & 1 deletion src/layout/InkLayout/InkLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const InkLayout: React.FC<InkLayoutProps> = ({
{sideNavigation && (
<div
className={classNames(
"ink:w-[260px] ink:px-4 ink:hidden ink:lg:block ink:shrink-0"
"ink:w-[244px] ink:px-4 ink:hidden ink:lg:block ink:shrink-0 ink:box-border"
)}
>
{sideNavigation}
Expand Down
Loading