@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
46 lines (45 loc) • 1.54 kB
JavaScript
"use client";
import _extends from "@babel/runtime/helpers/esm/extends";
import React, { useContext } from 'react';
import classnames from 'classnames';
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";
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 = React.createElement(FlexItem, _extends({
innerSpace: {
left: 'small'
},
className: classnames('dnb-list__item__title', className, appliedSkeleton && createSkeletonClass('font', true))
}, rest), React.createElement("span", {
className: `dnb-t__size--${fontSize}` + (fontWeight === 'medium' ? " dnb-t__weight--medium" : "")
}, children));
if (appliedSkeleton) {
return React.createElement(Context.Provider, {
value: {
...context,
skeleton: appliedSkeleton
}
}, content);
}
return content;
}
ItemTitleBase._supportsSpacingProps = true;
const ItemTitle = ItemTitleBase;
ItemTitle.Overline = ItemOverline;
ItemTitle.Subline = ItemSubline;
export default ItemTitle;
//# sourceMappingURL=ItemTitle.js.map