Skip to content

Commit f6bc1b1

Browse files
committed
chore: run lint
1 parent db2289d commit f6bc1b1

4 files changed

Lines changed: 70 additions & 69 deletions

File tree

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import type { FC } from "react";
1+
import type { FC } from "react"
22

3-
export interface DropdownDividerProps extends React.HTMLAttributes<HTMLElement> {
4-
children?: React.ReactNode;
3+
export interface DropdownDividerProps
4+
extends React.HTMLAttributes<HTMLElement> {
5+
children?: React.ReactNode
56
}
67

78
export const DropdownDivider: FC<DropdownDividerProps> = ({
@@ -12,7 +13,7 @@ export const DropdownDivider: FC<DropdownDividerProps> = ({
1213
<div {...rest} className="h-px my-2">
1314
<hr className="border-gray-200" />
1415
</div>
15-
);
16-
};
16+
)
17+
}
1718

18-
DropdownDivider.displayName = "DropdownDivider";
19+
DropdownDivider.displayName = "DropdownDivider"

packages/app-elements/src/ui/composite/Dropdown/DropdownItem.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import cn from "classnames";
2-
import { type FC, useMemo } from "react";
3-
import { Icon, type IconProps } from "#ui/atoms/Icon/Icon";
4-
import { withSkeletonTemplate } from "#ui/atoms/SkeletonTemplate";
5-
import { enforceAllowedTags } from "#utils/htmltags";
1+
import cn from "classnames"
2+
import { type FC, useMemo } from "react"
3+
import { Icon, type IconProps } from "#ui/atoms/Icon/Icon"
4+
import { withSkeletonTemplate } from "#ui/atoms/SkeletonTemplate"
5+
import { enforceAllowedTags } from "#utils/htmltags"
66

77
export type DropdownItemProps = React.HTMLAttributes<HTMLElement> & {
8-
label: string;
9-
info?: string;
10-
icon?: IconProps["name"] | "keep-space";
8+
label: string
9+
info?: string
10+
icon?: IconProps["name"] | "keep-space"
1111
} & (
1212
| {
1313
/**
1414
* render the component as anchor tag
1515
*/
16-
href: string;
17-
target?: string;
16+
href: string
17+
target?: string
1818
}
1919
| {
20-
href?: never;
21-
disabled?: boolean;
20+
href?: never
21+
disabled?: boolean
2222
}
23-
);
23+
)
2424

2525
/**
2626
* Render a dropdown item to be used inside a `Dropdown` component.
@@ -47,16 +47,16 @@ export const DropdownItem = withSkeletonTemplate<DropdownItemProps>(
4747
defaultTag: "button",
4848
}),
4949
[href, onClick],
50-
);
50+
)
5151

52-
const isDisabled = Boolean("disabled" in rest && rest.disabled);
52+
const isDisabled = Boolean("disabled" in rest && rest.disabled)
5353

5454
return (
5555
<JsxTag
5656
{...rest}
5757
onClick={(e) => {
5858
if (!isDisabled) {
59-
onClick?.(e);
59+
onClick?.(e)
6060
}
6161
}}
6262
href={href}
@@ -98,11 +98,11 @@ export const DropdownItem = withSkeletonTemplate<DropdownItemProps>(
9898
</span>
9999
)}
100100
</JsxTag>
101-
);
101+
)
102102
},
103-
);
104-
DropdownItem.displayName = "DropdownItem";
103+
)
104+
DropdownItem.displayName = "DropdownItem"
105105

106106
const FakeIcon: FC = () => {
107-
return <div className="w-[16px]" />;
108-
};
107+
return <div className="w-[16px]" />
108+
}

packages/app-elements/src/ui/composite/Dropdown/DropdownMenu.tsx

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import cn from "classnames";
2-
import { type FC, useEffect, useState } from "react";
3-
import { DropdownDivider } from "./DropdownDivider";
1+
import cn from "classnames"
2+
import { type FC, useEffect, useState } from "react"
3+
import { DropdownDivider } from "./DropdownDivider"
44

55
export interface DropdownMenuProps extends React.HTMLAttributes<HTMLElement> {
66
/** Menu content */
7-
children?: React.ReactNode;
7+
children?: React.ReactNode
88
/** Set to `none` to hide the top arrow */
9-
arrow?: "none";
9+
arrow?: "none"
1010
/** Optional header for the dropdown menu */
11-
menuHeader?: string;
11+
menuHeader?: string
1212
/**
1313
* Opening position of the dropdown menu
1414
* @default bottom-right
1515
*/
16-
menuPosition?: "bottom-left" | "bottom-right" | "top-left" | "top-right";
16+
menuPosition?: "bottom-left" | "bottom-right" | "top-left" | "top-right"
1717
/**
1818
* If set, the arrow will be centered when trigger button is smaller than 50px
1919
* Otherwise it will fallback to a default centering based on 32px trigger button
2020
*/
21-
parentElementRef?: React.RefObject<HTMLDivElement>;
21+
parentElementRef?: React.RefObject<HTMLDivElement>
2222
/**
2323
* Set a wider menu, fixed to 280px.
2424
* By default, when no width is set, the menu adjusts its width dynamically to accommodate content, within a range of 150px to 250px.
2525
**/
26-
menuWidth?: "wide";
26+
menuWidth?: "wide"
2727
}
2828

2929
export const DropdownMenu: FC<DropdownMenuProps> = ({
@@ -35,10 +35,10 @@ export const DropdownMenu: FC<DropdownMenuProps> = ({
3535
menuWidth,
3636
...rest
3737
}) => {
38-
const [centerToWidth, setCenterToWidth] = useState<number>();
38+
const [centerToWidth, setCenterToWidth] = useState<number>()
3939
useEffect(() => {
40-
setCenterToWidth(parentElementRef?.current?.clientWidth);
41-
}, [parentElementRef]);
40+
setCenterToWidth(parentElementRef?.current?.clientWidth)
41+
}, [parentElementRef])
4242

4343
return (
4444
<div
@@ -76,28 +76,28 @@ export const DropdownMenu: FC<DropdownMenuProps> = ({
7676
{children}
7777
</div>
7878
</div>
79-
);
80-
};
79+
)
80+
}
8181

82-
DropdownMenu.displayName = "DropdownMenu";
82+
DropdownMenu.displayName = "DropdownMenu"
8383

8484
const Arrow: FC<{
85-
menuPosition: DropdownMenuProps["menuPosition"];
86-
centerToWidth?: number;
85+
menuPosition: DropdownMenuProps["menuPosition"]
86+
centerToWidth?: number
8787
}> = ({ menuPosition = "bottom-right", centerToWidth }) => {
88-
const arrowHeight = 5;
89-
const arrowWidth = 12;
88+
const arrowHeight = 5
89+
const arrowWidth = 12
9090

9191
const centeringOffset = calculateArrowCenteringOffset({
9292
arrowWidth,
9393
centerToWidth,
94-
});
94+
})
9595

96-
const alignProp = menuPosition.includes("right") ? "right" : "left";
96+
const alignProp = menuPosition.includes("right") ? "right" : "left"
9797
const arrowDirection =
9898
menuPosition === "bottom-right" || menuPosition === "bottom-left"
9999
? "top"
100-
: "bottom";
100+
: "bottom"
101101
const cssForPointingDirection =
102102
arrowDirection === "top"
103103
? {
@@ -107,7 +107,7 @@ const Arrow: FC<{
107107
: {
108108
borderTopWidth: arrowHeight,
109109
borderBottomColor: "transparent",
110-
};
110+
}
111111

112112
return (
113113
<span
@@ -121,8 +121,8 @@ const Arrow: FC<{
121121
[alignProp]: centeringOffset,
122122
}}
123123
/>
124-
);
125-
};
124+
)
125+
}
126126

127127
// Calculate the offset for centering the arrow on the dropdown button when this does not excide 50px
128128
// This means that for smaller buttons (up to 50px) the arrow will be centered on the button
@@ -131,13 +131,13 @@ function calculateArrowCenteringOffset({
131131
arrowWidth,
132132
centerToWidth,
133133
}: {
134-
arrowWidth: number;
135-
centerToWidth?: number;
134+
arrowWidth: number
135+
centerToWidth?: number
136136
}): number {
137137
if (centerToWidth == null || centerToWidth > 50) {
138-
return 10; // default offset calculated on a base of 32px button width
138+
return 10 // default offset calculated on a base of 32px button width
139139
}
140140

141-
const centeringOffset = centerToWidth / 2 - arrowWidth / 2;
142-
return centeringOffset;
141+
const centeringOffset = centerToWidth / 2 - arrowWidth / 2
142+
return centeringOffset
143143
}

packages/app-elements/src/ui/composite/Dropdown/__snapshots__/Dropdown.test.tsx.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ exports[`Dropdown > Should be rendering bottom-left 1`] = `
3131
class="flex flex-col items-start"
3232
>
3333
<span
34-
class="relative border-black border-l-transparent border-r-transparent"
34+
class="relative border-gray-200 border-l-transparent border-r-transparent"
3535
style="border-left-width: 6px; border-right-width: 6px; border-bottom-width: 5px; border-top-color: transparent; left: 10px;"
3636
/>
3737
<div
38-
class="bg-black text-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 min-w-[150px] md:max-w-[250px]"
38+
class="bg-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 border shadow-lg min-w-[150px] md:max-w-[250px]"
3939
>
4040
<div />
4141
</div>
@@ -76,11 +76,11 @@ exports[`Dropdown > Should be rendering top-left 1`] = `
7676
class="flex flex-col-reverse items-start"
7777
>
7878
<span
79-
class="relative border-black border-l-transparent border-r-transparent"
79+
class="relative border-gray-200 border-l-transparent border-r-transparent"
8080
style="border-left-width: 6px; border-right-width: 6px; border-top-width: 5px; border-bottom-color: transparent; left: 10px;"
8181
/>
8282
<div
83-
class="bg-black text-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 min-w-[150px] md:max-w-[250px]"
83+
class="bg-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 border shadow-lg min-w-[150px] md:max-w-[250px]"
8484
>
8585
<div />
8686
</div>
@@ -121,11 +121,11 @@ exports[`Dropdown > Should be rendering top-right 1`] = `
121121
class="flex flex-col-reverse items-end"
122122
>
123123
<span
124-
class="relative border-black border-l-transparent border-r-transparent"
124+
class="relative border-gray-200 border-l-transparent border-r-transparent"
125125
style="border-left-width: 6px; border-right-width: 6px; border-top-width: 5px; border-bottom-color: transparent; right: 10px;"
126126
/>
127127
<div
128-
class="bg-black text-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 min-w-[150px] md:max-w-[250px]"
128+
class="bg-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 border shadow-lg min-w-[150px] md:max-w-[250px]"
129129
>
130130
<div />
131131
</div>
@@ -166,15 +166,15 @@ exports[`Dropdown > Should be rendering with default bottom-right position 1`] =
166166
class="flex flex-col items-end"
167167
>
168168
<span
169-
class="relative border-black border-l-transparent border-r-transparent"
169+
class="relative border-gray-200 border-l-transparent border-r-transparent"
170170
style="border-left-width: 6px; border-right-width: 6px; border-bottom-width: 5px; border-top-color: transparent; right: 10px;"
171171
/>
172172
<div
173-
class="bg-black text-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 min-w-[150px] md:max-w-[250px]"
173+
class="bg-white rounded overflow-x-hidden overflow-y-auto max-h-[450px] py-2 border shadow-lg min-w-[150px] md:max-w-[250px]"
174174
>
175175
<button
176176
aria-label="Payments"
177-
class="w-full bg-black text-white! py-1.5 pl-4 text-sm font-medium flex items-center focus:outline-hidden! pr-8 hover:bg-gray-600 cursor-pointer focus:bg-gray-600 group"
177+
class="w-[calc(100%-1rem)] bg-white text-black! py-1.5 pl-4 mx-2 text-sm font-regular flex items-center focus:outline-hidden! pr-8 hover:bg-gray-100 hover:rounded cursor-pointer focus:bg-gray-100 group"
178178
>
179179
<div
180180
class="mr-2"
@@ -200,7 +200,7 @@ exports[`Dropdown > Should be rendering with default bottom-right position 1`] =
200200
</button>
201201
<button
202202
aria-label="Items"
203-
class="w-full bg-black text-white! py-1.5 pl-4 text-sm font-medium flex items-center focus:outline-hidden! pr-8 hover:bg-gray-600 cursor-pointer focus:bg-gray-600 group"
203+
class="w-[calc(100%-1rem)] bg-white text-black! py-1.5 pl-4 mx-2 text-sm font-regular flex items-center focus:outline-hidden! pr-8 hover:bg-gray-100 hover:rounded cursor-pointer focus:bg-gray-100 group"
204204
>
205205
<div
206206
class="mr-2"
@@ -220,12 +220,12 @@ exports[`Dropdown > Should be rendering with default bottom-right position 1`] =
220220
class="h-px my-2"
221221
>
222222
<hr
223-
class="border-gray-600"
223+
class="border-gray-200"
224224
/>
225225
</div>
226226
<button
227227
aria-label="Delete"
228-
class="w-full bg-black text-white! py-1.5 pl-4 text-sm font-medium flex items-center focus:outline-hidden! pr-8 hover:bg-gray-600 cursor-pointer focus:bg-gray-600 group"
228+
class="w-[calc(100%-1rem)] bg-white text-black! py-1.5 pl-4 mx-2 text-sm font-regular flex items-center focus:outline-hidden! pr-8 hover:bg-gray-100 hover:rounded cursor-pointer focus:bg-gray-100 group"
229229
>
230230
<div
231231
class="mr-2"

0 commit comments

Comments
 (0)