Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 3x 3x | import React from "react";
import classNames from "classnames";
import { StyledProps } from "../_type";
import { useConfig } from "../_util/config-context";
export interface MediaObjectProps extends StyledProps {
/**
* 媒体元素
*/
media: React.ReactNode;
/**
* 内容块
*/
children: React.ReactNode;
/**
* 媒体元素与内容块对齐方式
* @default "top"
*/
align?: "top" | "middle" | "bottom";
/**
* 媒体元素与内容块反置
* @default false
*/
reverse?: boolean;
}
export function MediaObject({
align = "top",
reverse,
media,
children,
}: MediaObjectProps) {
const { classPrefix } = useConfig();
return (
<div
className={classNames(`${classPrefix}-media`, {
[`${classPrefix}-media--reverse`]: reverse,
[`${classPrefix}-media--middle`]: align === "middle",
[`${classPrefix}-media--bottom`]: align === "bottom",
})}
>
<div className={`${classPrefix}-media__left`}>{media}</div>
<div className={`${classPrefix}-media__body`}>{children}</div>
</div>
);
}
|