@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
50 lines (49 loc) • 1.5 kB
JavaScript
"use client";
import { useContext } from 'react';
import { clsx } from 'clsx';
import FlexItem from "../flex/Item.js";
import ItemOverline from "./ItemOverline.js";
import ItemSubline from "./ItemSubline.js";
import { ListContext } from "./ListContext.js";
import { createSkeletonClass } from "../skeleton/SkeletonHelper.js";
import Context from "../../shared/Context.js";
import { jsx as _jsx } from "react/jsx-runtime";
function ItemTitleBase({
className,
fontSize = 'basis',
fontWeight,
skeleton,
children,
...rest
}) {
const context = useContext(Context);
const inheritedSkeleton = useContext(ListContext)?.skeleton;
const appliedSkeleton = skeleton !== null && skeleton !== void 0 ? skeleton : inheritedSkeleton;
const content = _jsx(FlexItem, {
innerSpace: {
left: 'small'
},
className: clsx('dnb-list__item__title', appliedSkeleton && createSkeletonClass('font', true), className),
...rest,
children: _jsx("span", {
className: clsx(`dnb-t__size--${fontSize}`, fontWeight === 'medium' && 'dnb-t__weight--medium'),
children: children
})
});
if (appliedSkeleton) {
return _jsx(Context, {
value: {
...context,
skeleton: appliedSkeleton
},
children: content
});
}
return content;
}
ItemTitleBase._supportsSpacingProps = true;
const ItemTitle = ItemTitleBase;
ItemTitle.Overline = ItemOverline;
ItemTitle.Subline = ItemSubline;
export default ItemTitle;
//# sourceMappingURL=ItemTitle.js.map