Skip to content

Commit

Permalink
chore(sparkle): unify button props (always use variant instead of `…
Browse files Browse the repository at this point in the history
…type`) (#1309)
  • Loading branch information
fontanierh authored Sep 7, 2023
1 parent 4570cb3 commit 30fe38c
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sparkle/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dust-tt/sparkle",
"version": "0.1.46",
"version": "0.1.47",
"scripts": {
"build": "rm -rf dist && rollup -c",
"build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
Expand Down
6 changes: 3 additions & 3 deletions sparkle/src/components/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Icon, IconProps } from "./Icon";
import { Tooltip, TooltipProps } from "./Tooltip";

type IconButtonProps = {
type?: "primary" | "warning" | "secondary" | "tertiary";
variant?: "primary" | "warning" | "secondary" | "tertiary";
onClick?: MouseEventHandler<HTMLButtonElement>;
size?: "xs" | "sm" | "md";
tooltip?: string;
Expand Down Expand Up @@ -71,7 +71,7 @@ const iconClasses = {
};

export function IconButton({
type = "tertiary",
variant = "tertiary",
onClick,
disabled = false,
tooltip,
Expand All @@ -81,7 +81,7 @@ export function IconButton({
size = "sm",
}: IconButtonProps) {
// Choose the correct group of classes based on 'type'
const iconGroup = iconClasses[type];
const iconGroup = iconClasses[variant];

const finalIconClasses = classNames(
className,
Expand Down
6 changes: 3 additions & 3 deletions sparkle/src/components/IconToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Icon, IconProps } from "./Icon";
import { Tooltip, TooltipProps } from "./Tooltip";

type IconToggleButtonProps = {
type?: "secondary" | "tertiary";
variant?: "secondary" | "tertiary";
onClick?: MouseEventHandler<HTMLButtonElement>;
size?: "xs" | "sm" | "md";
tooltip?: string;
Expand Down Expand Up @@ -53,7 +53,7 @@ const iconClasses = {
};

export function IconToggleButton({
type = "tertiary",
variant = "tertiary",
onClick,
disabled = false,
tooltip,
Expand All @@ -64,7 +64,7 @@ export function IconToggleButton({
selected = false,
size = "sm",
}: IconToggleButtonProps) {
const iconGroup = iconClasses[type];
const iconGroup = iconClasses[variant];
const finalIconClasses = classNames(
className,
baseClasses,
Expand Down
2 changes: 1 addition & 1 deletion sparkle/src/components/SliderToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { MouseEventHandler } from "react";
import { classNames } from "@sparkle/lib/utils";

type SliderToggleProps = {
onClick?: MouseEventHandler<HTMLButtonElement>;
onClick?: MouseEventHandler<HTMLElement>;
className?: string;
disabled?: boolean;
selected?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions sparkle/src/stories/IconButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ type Story = StoryObj<typeof meta>;

export const IconButtonPrimary: Story = {
args: {
type: "primary",
variant: "primary",
size: "md",
icon: Cog6ToothIcon,
},
};

export const IconButtonWithTooltip: Story = {
args: {
type: "primary",
variant: "primary",
tooltip: "Your settings",
tooltipPosition: "below",
icon: Cog6ToothIcon,
Expand All @@ -29,7 +29,7 @@ export const IconButtonWithTooltip: Story = {

export const IconButtonSecondary: Story = {
args: {
type: "secondary",
variant: "secondary",
tooltip: "This a secondary IconButton",
tooltipPosition: "below",
icon: Cog6ToothIcon,
Expand All @@ -38,7 +38,7 @@ export const IconButtonSecondary: Story = {

export const IconButtonTertiary: Story = {
args: {
type: "tertiary",
variant: "tertiary",
tooltip: "This a tertiary IconButton",
tooltipPosition: "below",
icon: Cog6ToothIcon,
Expand Down
4 changes: 2 additions & 2 deletions sparkle/src/stories/IconToggleButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Story = StoryObj<typeof meta>;

export const IconToggleButtonSecondary: Story = {
args: {
type: "secondary",
variant: "secondary",
tooltip: "This a secondary IconButton",
icon: Cog6ToothStrokeIcon,
iconSelected: Cog6ToothIcon,
Expand All @@ -26,7 +26,7 @@ export const IconToggleButtonSecondary: Story = {

export const IconToggleButtonTertiary: Story = {
args: {
type: "tertiary",
variant: "tertiary",
tooltip: "This a tertiary IconButton",
icon: Cog6ToothIcon,
selected: false,
Expand Down
2 changes: 1 addition & 1 deletion sparkle/src/stories/SectionHeader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const BasicPageHeader: Story = {
"This is an optional short description of the section that says stuff about it. Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
action: {
label: "Add a new Data Source",
type: "secondary",
variant: "secondary",
icon: ChatBubbleBottomCenterPlusIcon,
},
},
Expand Down

0 comments on commit 30fe38c

Please sign in to comment.