mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Fix code style
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
11ab79b568
commit
65f04b6e38
@ -26,21 +26,8 @@ export interface ButtonProps extends ButtonHTMLAttributes<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Button = withTooltip((props: ButtonProps) => {
|
export const Button = withTooltip((props: ButtonProps) => {
|
||||||
const {
|
const { waiting, label, primary, accent, plain, hidden, active, big, round, outlined, light, children, ...btnProps } =
|
||||||
waiting,
|
props;
|
||||||
label,
|
|
||||||
primary,
|
|
||||||
accent,
|
|
||||||
plain,
|
|
||||||
hidden,
|
|
||||||
active,
|
|
||||||
big,
|
|
||||||
round,
|
|
||||||
outlined,
|
|
||||||
light,
|
|
||||||
children,
|
|
||||||
...btnProps
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
return null;
|
return null;
|
||||||
@ -70,11 +57,7 @@ export const Button = withTooltip((props: ButtonProps) => {
|
|||||||
|
|
||||||
// render as button
|
// render as button
|
||||||
return (
|
return (
|
||||||
<button
|
<button type="button" {...btnProps} data-waiting={typeof waiting === "boolean" ? String(waiting) : undefined}>
|
||||||
type="button"
|
|
||||||
{...btnProps}
|
|
||||||
data-waiting={typeof waiting === "boolean" ? String(waiting) : undefined}
|
|
||||||
>
|
|
||||||
{label}
|
{label}
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -115,8 +115,7 @@ export const computeNextPosition = ({
|
|||||||
tooltipBounds,
|
tooltipBounds,
|
||||||
targetBounds,
|
targetBounds,
|
||||||
});
|
});
|
||||||
const fitsToWindow =
|
const fitsToWindow = left >= 0 && top >= 0 && right <= viewportWidth && bottom <= viewportHeight;
|
||||||
left >= 0 && top >= 0 && right <= viewportWidth && bottom <= viewportHeight;
|
|
||||||
|
|
||||||
if (fitsToWindow) {
|
if (fitsToWindow) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -11,9 +11,7 @@ import React from "react";
|
|||||||
import { computeNextPosition, RectangleDimensions } from "./helpers";
|
import { computeNextPosition, RectangleDimensions } from "./helpers";
|
||||||
import { Tooltip, TooltipPosition } from "./tooltip";
|
import { Tooltip, TooltipPosition } from "./tooltip";
|
||||||
|
|
||||||
const getRectangle = (
|
const getRectangle = (parts: Omit<RectangleDimensions, "width" | "height">): RectangleDimensions => {
|
||||||
parts: Omit<RectangleDimensions, "width" | "height">,
|
|
||||||
): RectangleDimensions => {
|
|
||||||
assert(parts.right >= parts.left);
|
assert(parts.right >= parts.left);
|
||||||
assert(parts.bottom >= parts.top);
|
assert(parts.bottom >= parts.top);
|
||||||
|
|
||||||
@ -382,9 +380,7 @@ describe("computeNextPosition technical tests", () => {
|
|||||||
TooltipPosition.TOP_LEFT,
|
TooltipPosition.TOP_LEFT,
|
||||||
TooltipPosition.BOTTOM_RIGHT,
|
TooltipPosition.BOTTOM_RIGHT,
|
||||||
TooltipPosition.BOTTOM_LEFT,
|
TooltipPosition.BOTTOM_LEFT,
|
||||||
])(
|
])("computes to the %p if there is space and it is specified as a preferred position", (position) => {
|
||||||
"computes to the %p if there is space and it is specified as a preferred position",
|
|
||||||
(position) => {
|
|
||||||
expect(
|
expect(
|
||||||
computeNextPosition({
|
computeNextPosition({
|
||||||
preferredPositions: position,
|
preferredPositions: position,
|
||||||
@ -408,7 +404,6 @@ describe("computeNextPosition technical tests", () => {
|
|||||||
).toMatchObject({
|
).toMatchObject({
|
||||||
position,
|
position,
|
||||||
});
|
});
|
||||||
},
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -16,14 +16,12 @@ type MyComponentProps = {
|
|||||||
"data-testid"?: string;
|
"data-testid"?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MyComponent = withTooltip(
|
const MyComponent = withTooltip(({ text, "data-testid": testId, id, children }: MyComponentProps) => (
|
||||||
({ text, "data-testid": testId, id, children }: MyComponentProps) => (
|
|
||||||
<div id={id} data-testid={testId}>
|
<div id={id} data-testid={testId}>
|
||||||
{text}
|
{text}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
),
|
));
|
||||||
);
|
|
||||||
|
|
||||||
describe("withTooltip tests", () => {
|
describe("withTooltip tests", () => {
|
||||||
it("does not render a tooltip when not specified", () => {
|
it("does not render a tooltip when not specified", () => {
|
||||||
@ -42,9 +40,7 @@ describe("withTooltip tests", () => {
|
|||||||
let result: RenderResult;
|
let result: RenderResult;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
result = render(
|
result = render(<MyComponent text="foobar" data-testid="my-test-id" tooltip="my-tooltip" id="bat" />);
|
||||||
<MyComponent text="foobar" data-testid="my-test-id" tooltip="my-tooltip" id="bat" />,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("renders", () => {
|
it("renders", () => {
|
||||||
@ -71,12 +67,7 @@ describe("withTooltip tests", () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
result = render(
|
result = render(
|
||||||
<MyComponent
|
<MyComponent text="foobar" data-testid="my-test-id" tooltip={{ children: "my-tooltip" }} id="bat" />,
|
||||||
text="foobar"
|
|
||||||
data-testid="my-test-id"
|
|
||||||
tooltip={{ children: "my-tooltip" }}
|
|
||||||
id="bat"
|
|
||||||
/>,
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -32,13 +32,7 @@ export function withTooltip<TargetProps>(
|
|||||||
const [defaultTooltipId] = useState(uniqueId("tooltip_target_"));
|
const [defaultTooltipId] = useState(uniqueId("tooltip_target_"));
|
||||||
|
|
||||||
let { id: targetId, children: targetChildren } = props;
|
let { id: targetId, children: targetChildren } = props;
|
||||||
const {
|
const { tooltip, tooltipOverrideDisabled, id: _unusedId, children: _unusedTargetChildren, ...targetProps } = props;
|
||||||
tooltip,
|
|
||||||
tooltipOverrideDisabled,
|
|
||||||
id: _unusedId,
|
|
||||||
children: _unusedTargetChildren,
|
|
||||||
...targetProps
|
|
||||||
} = props;
|
|
||||||
|
|
||||||
if (tooltip) {
|
if (tooltip) {
|
||||||
const tooltipProps: TooltipProps = {
|
const tooltipProps: TooltipProps = {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user