DmTruncate
DmTruncate documents the DmTruncate export from duskmoon.
@duskmoon-dev/components/dm-truncate Usage
When to use
- Use it in DuskMoon application screens that need a packaged, opinionated workflow component.
- Reach for the lower-level standard component when the screen needs custom composition.
Implementation notes
Features
Wraps lower-level primitives into a higher-level DuskMoon-prefixed workflow API.
Examples show the defaults and composition points expected by internal DuskMoon app screens.
DmTruncate is most often configured through `showOverflowTag`, `overflowContent`, `emptyValue`, `overflowPercent`.
Renders emptyValue and custom class names
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and DmTruncate from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { DmTruncate } from "@duskmoon-dev/components/dm-truncate";
export function Example() {
return (<DmTruncate>DuskMoon Dm Truncate</DmTruncate>);
} Renders emptyValue and custom class names
test-backedDmTruncate scenario from the component test coverage: renders emptyvalue and custom class names.
import "@duskmoon-dev/components/styles.css";
import { DmTruncate } from "@duskmoon-dev/components/dm-truncate";
export function DmTruncateRendersEmptyValueAndCustomDemo() {
return (<DmTruncate>DuskMoon Dm Truncate</DmTruncate>);
} Detects single-line overflow and shows overflow tag tooltip
test-backedDmTruncate scenario from the component test coverage: detects single-line overflow and shows overflow tag tooltip.
import "@duskmoon-dev/components/styles.css";
import { DmTruncate } from "@duskmoon-dev/components/dm-truncate";
export function DmTruncateDetectsSingleLineOverflowDemo() {
return (<DmTruncate>DuskMoon Dm Truncate</DmTruncate>);
} Uses text tooltip when overflow tag is disabled
test-backedDmTruncate scenario from the component test coverage: uses text tooltip when overflow tag is disabled.
import "@duskmoon-dev/components/styles.css";
import { DmTruncate } from "@duskmoon-dev/components/dm-truncate";
export function DmTruncateUsesTextTooltipWhenDemo() {
return (<DmTruncate>DuskMoon Dm Truncate</DmTruncate>);
} Copies string content
test-backedDmTruncate scenario from the component test coverage: copies string content.
import "@duskmoon-dev/components/styles.css";
import { DmTruncate } from "@duskmoon-dev/components/dm-truncate";
export function DmTruncateCopiesStringContentDemo() {
return (<DmTruncate>DuskMoon Dm Truncate</DmTruncate>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<DmTruncate>DuskMoon Dm Truncate</DmTruncate>
</div>
<div data-theme="moonlight">
<DmTruncate>DuskMoon Dm Truncate</DmTruncate>
</div> API
The API reference below lists every parsed exported type or interface for DmTruncate. Start with `showOverflowTag`, `overflowContent`, `emptyValue`, `overflowPercent` for common usage.
packages/components/src/components/dm-truncate/DmTruncate.types.ts
Scenarios: packages/components/src/components/dm-truncate/DmTruncate.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
children | ReactNode | No | children configures DmTruncate. |
showOverflowTag | boolean | No | showOverflowTag configures DmTruncate. |
overflowContent | ReactNode | ((value: string) => ReactNode) | No | overflowContent configures DmTruncate. |
emptyValue | ReactNode | No | emptyValue configures DmTruncate. |
overflowPercent | number | No | overflowPercent configures DmTruncate. |
tooltipProps | Partial<TooltipProps> | No | tooltipProps configures DmTruncate. |
isShowPopover | boolean | No | isShowPopover configures DmTruncate. |
copyable | boolean | No | copyable configures DmTruncate. |
maxLines | number | No | maxLines configures DmTruncate. |
tooltipPreserveLineBreak | boolean | No | tooltipPreserveLineBreak configures DmTruncate. |
textClassName | string | No | textClassName configures DmTruncate. |
textStyle | CSSProperties | No | textStyle configures DmTruncate. |
onCopy | (value: string) => void | No | onCopy configures DmTruncate. |