mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
6d13347806
fix: Toolbar too small on embed link editor
29 lines
549 B
TypeScript
29 lines
549 B
TypeScript
import * as React from "react";
|
|
import useMeasure from "react-use-measure";
|
|
|
|
export const MeasuredContainer = <T extends React.ElementType>({
|
|
as: As = "div",
|
|
name,
|
|
children,
|
|
...rest
|
|
}: {
|
|
as: T;
|
|
name: string;
|
|
children?: React.ReactNode;
|
|
} & React.ComponentProps<T>) => {
|
|
const [measureRef, rect] = useMeasure();
|
|
|
|
return (
|
|
<As
|
|
{...rest}
|
|
ref={measureRef}
|
|
style={{
|
|
[`--${name}-width`]: `${rect.width}px`,
|
|
[`--${name}-height`]: `${rect.height}px`,
|
|
}}
|
|
>
|
|
{children}
|
|
</As>
|
|
);
|
|
};
|