Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Convert SidebarLayout to TypeScript (#69074)

Fraser5ce4289d08f4
diff --git a/frontend/src/metabase/common/components/SidebarLayout/SidebarLayout.jsx b/frontend/src/metabase/common/components/SidebarLayout/SidebarLayout.jsx
deleted file mode 100644
index b26a807bcdd..00000000000
--- a/frontend/src/metabase/common/components/SidebarLayout/SidebarLayout.jsx
+++ /dev/null
@@ -1,48 +0,0 @@
-/* eslint "react/prop-types": "warn" */
-import cx from "classnames";
-import PropTypes from "prop-types";
-import { Children, cloneElement } from "react";
-
-import CS from "metabase/css/core/index.css";
-
-export const SidebarLayout = ({ className, style, sidebar, children }) => (
- <div
- className={className}
- style={{ ...style, display: "flex", flexDirection: "row" }}
- >
- {cloneElement(
- sidebar,
- {
- style: { flexShrink: 0, alignSelf: "stretch" },
- className: cx(
- CS.scrollY,
- CS.scrollShow,
- CS.scrollLight,
- CS.scrollShowHover,
- ),
- },
- sidebar.props.children,
- )}
- {children &&
- cloneElement(
- Children.only(children),
- {
- style: {
- flex: 1,
- overflowY: "auto",
- display: "flex",
- flexDirection: "column",
- height: "100%",
- },
- },
- Children.only(children).props.children,
- )}
- </div>
-);
-
-SidebarLayout.propTypes = {
- className: PropTypes.string,
- style: PropTypes.object,
- sidebar: PropTypes.element.isRequired,
- children: PropTypes.element.isRequired,
-};
diff --git a/frontend/src/metabase/common/components/SidebarLayout/SidebarLayout.tsx b/frontend/src/metabase/common/components/SidebarLayout/SidebarLayout.tsx
new file mode 100644
index 00000000000..7ee92a47cb7
--- /dev/null
+++ b/frontend/src/metabase/common/components/SidebarLayout/SidebarLayout.tsx
@@ -0,0 +1,51 @@
+import cx from "classnames";
+import type { CSSProperties, ReactElement } from "react";
+import { Children, cloneElement } from "react";
+
+import CS from "metabase/css/core/index.css";
+
+interface SidebarLayoutProps {
+ className?: string;
+ style?: CSSProperties;
+ sidebar: ReactElement;
+ children: ReactElement;
+}
+
+export const SidebarLayout = ({
+ className,
+ style,
+ sidebar,
+ children,
+}: SidebarLayoutProps) => (
+ <div
+ className={className}
+ style={{ ...style, display: "flex", flexDirection: "row" }}
+ >
+ {cloneElement(
+ sidebar,
+ {
+ style: { flexShrink: 0, alignSelf: "stretch" },
+ className: cx(
+ CS.scrollY,
+ CS.scrollShow,
+ CS.scrollLight,
+ CS.scrollShowHover,
+ ),
+ },
+ sidebar.props.children,
+ )}
+ {cloneElement(
+ Children.only(children),
+ {
+ style: {
+ flex: 1,
+ overflowY: "auto",
+ display: "flex",
+ flexDirection: "column",
+ height: "100%",
+ },
+ },
+ Children.only(children).props.children,
+ )}
+ </div>
+);