Skip to content

Commit

Permalink
add cn overrideable className
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAlec committed Aug 14, 2024
1 parent 59c9fa6 commit a36945a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions site/docs/pages/swap/types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ type SwapReact = {

```ts
type SwapSettingsReact = {
className?: string; // Optional className override for top div element.
icon: ReactNode;
title: string;
};
Expand Down
9 changes: 7 additions & 2 deletions src/swap/components/SwapSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { isValidElement, useMemo } from 'react';
import { SwapSettingsSvg } from '../../internal/svg/swapSettings';
import { cn } from '../../styles/theme';
import type { SwapSettingsReact } from '../types';

export function SwapSettings({ icon, title = 'Auto' }: SwapSettingsReact) {
export function SwapSettings({
className,
icon,
title = 'Auto',
}: SwapSettingsReact) {
const iconSvg = useMemo(() => {
if (icon === undefined) {
return SwapSettingsSvg;
Expand All @@ -14,7 +19,7 @@ export function SwapSettings({ icon, title = 'Auto' }: SwapSettingsReact) {

return (
<div
className="flex w-full items-center justify-between"
className={cn('flex w-full items-center justify-between', className)}
data-testid="ockSwapSettings_Settings"
>
<div className="flex items-center space-x-1">
Expand Down
1 change: 1 addition & 0 deletions src/swap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export type SwapReact = {
* Note: exported as public Type
*/
export type SwapSettingsReact = {
className?: string; // Optional className override for top div element.
icon: ReactNode;
title: string;
};
Expand Down

0 comments on commit a36945a

Please sign in to comment.