Skip to content

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

Migrate TextArea off Emotion (#83278)

Andrei Chernykhfbc4c685e7e3
diff --git a/frontend/src/metabase/common/components/TextArea/TextArea.module.css b/frontend/src/metabase/common/components/TextArea/TextArea.module.css
new file mode 100644
index 00000000000..ced74e1087a
--- /dev/null
+++ b/frontend/src/metabase/common/components/TextArea/TextArea.module.css
@@ -0,0 +1,23 @@
+.root {
+ border: 1px solid var(--mb-color-border-neutral);
+ outline: none;
+
+ &:hover,
+ &:focus {
+ border-color: var(--mb-color-core-brand);
+ transition: border 300ms ease-in-out;
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--mb-color-input-focus);
+ }
+
+ &:disabled {
+ pointer-events: none;
+ opacity: 0.4;
+ }
+}
+
+.error {
+ border-color: var(--mb-color-feedback-negative);
+}
diff --git a/frontend/src/metabase/common/components/TextArea/TextArea.styled.tsx b/frontend/src/metabase/common/components/TextArea/TextArea.styled.tsx
deleted file mode 100644
index d35dbabb3ad..00000000000
--- a/frontend/src/metabase/common/components/TextArea/TextArea.styled.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-// eslint-disable-next-line no-restricted-imports
-import { css } from "@emotion/react";
-// eslint-disable-next-line no-restricted-imports
-import styled from "@emotion/styled";
-
-import { focusOutlineStyle } from "metabase/common/style/focus-outline";
-
-interface TextAreaRootProps {
- readOnly?: boolean;
- hasError?: boolean;
- fullWidth?: boolean;
-}
-
-export const TextAreaRoot = styled.textarea<TextAreaRootProps>`
- font-family: inherit;
- font-weight: 700;
- font-size: 1rem;
- color: var(--mb-color-text-primary);
- padding: 0.75rem;
- border: 1px solid var(--mb-color-border-neutral);
- border-radius: 0.5rem;
- background-color: ${(props) =>
- props.readOnly
- ? "var(--mb-color-background_page-secondary)"
- : "var(--mb-color-background_page-primary)"};
- outline: none;
- text-align: inherit;
-
- &:focus,
- &:hover {
- border-color: var(--mb-color-core-brand);
- transition: border 300ms ease-in-out;
- }
-
- ${focusOutlineStyle("core-brand")};
-
- &:disabled {
- pointer-events: none;
- opacity: 0.4;
- }
-
- ${(props) =>
- props.hasError &&
- css`
- border-color: var(--mb-color-feedback-negative);
- `};
-
- ${(props) =>
- props.fullWidth &&
- css`
- width: 100%;
- `}
-`;
diff --git a/frontend/src/metabase/common/components/TextArea/TextArea.tsx b/frontend/src/metabase/common/components/TextArea/TextArea.tsx
index ca8f5fd6f11..10614e8a8d3 100644
--- a/frontend/src/metabase/common/components/TextArea/TextArea.tsx
+++ b/frontend/src/metabase/common/components/TextArea/TextArea.tsx
@@ -1,22 +1,36 @@
+import cx from "classnames";
import type { Ref, TextareaHTMLAttributes } from "react";
import { forwardRef } from "react";
-import { TextAreaRoot } from "./TextArea.styled";
+import { Box } from "metabase/ui";
+
+import S from "./TextArea.module.css";
export interface TextAreaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
error?: boolean;
fullWidth?: boolean;
}
-const TextAreaInner = forwardRef(function TextArea(
- { error, fullWidth, ...props }: TextAreaProps,
+export const TextArea = forwardRef(function TextArea(
+ { error, fullWidth, readOnly, className, ...props }: TextAreaProps,
ref: Ref<HTMLTextAreaElement>,
) {
return (
- <TextAreaRoot {...props} ref={ref} hasError={error} fullWidth={fullWidth} />
+ <Box
+ component="textarea"
+ {...props}
+ ref={ref}
+ readOnly={readOnly}
+ className={cx(S.root, { [S.error]: error }, className)}
+ w={fullWidth ? "100%" : undefined}
+ p="md"
+ bdrs="sm"
+ bg={readOnly ? "background_page-secondary" : "background_page-primary"}
+ c="text-primary"
+ ff="inherit"
+ fz="1rem"
+ fw={700}
+ ta="inherit"
+ />
);
});
-
-export const TextArea = Object.assign(TextAreaInner, {
- Root: TextAreaRoot,
-});