DmDrawer
DmDrawer documents the DmDrawer export from duskmoon.
@duskmoon-dev/components/dm-drawer 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.
DmDrawer is most often configured through `closeIcon`, `footer`, `footerText`, `submitText`.
Wraps Drawer with Dm class names and right placement defaults
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 DmDrawer from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { DmDrawer } from "@duskmoon-dev/components/dm-drawer";
export function Example() {
return (<DmDrawer>DuskMoon Dm Drawer</DmDrawer>);
} Wraps Drawer with Dm class names and right placement defaults
test-backedDmDrawer scenario from the component test coverage: wraps drawer with dm class names and right placement defaults.
import "@duskmoon-dev/components/styles.css";
import { DmDrawer } from "@duskmoon-dev/components/dm-drawer";
export function DmDrawerWrapsDrawerWithDmDemo() {
return (<DmDrawer>DuskMoon Dm Drawer</DmDrawer>);
} Renders submit footer from footerText and calls onSubmit
test-backedDmDrawer scenario from the component test coverage: renders submit footer from footertext and calls onsubmit.
import "@duskmoon-dev/components/styles.css";
import { DmDrawer } from "@duskmoon-dev/components/dm-drawer";
export function DmDrawerRendersSubmitFooterFromDemo() {
return (<DmDrawer>DuskMoon Dm Drawer</DmDrawer>);
} Prefers custom footer over submit footer
test-backedDmDrawer scenario from the component test coverage: prefers custom footer over submit footer.
import "@duskmoon-dev/components/styles.css";
import { DmDrawer } from "@duskmoon-dev/components/dm-drawer";
export function DmDrawerPrefersCustomFooterOverDemo() {
return (<DmDrawer>DuskMoon Dm Drawer</DmDrawer>);
} Keeps close behavior and supports submit disabled state
test-backedDmDrawer scenario from the component test coverage: keeps close behavior and supports submit disabled state.
import "@duskmoon-dev/components/styles.css";
import { DmDrawer } from "@duskmoon-dev/components/dm-drawer";
export function DmDrawerKeepsCloseBehaviorAndDemo() {
return (<DmDrawer>DuskMoon Dm Drawer</DmDrawer>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<DmDrawer>DuskMoon Dm Drawer</DmDrawer>
</div>
<div data-theme="moonlight">
<DmDrawer>DuskMoon Dm Drawer</DmDrawer>
</div> API
The API reference below lists every parsed exported type or interface for DmDrawer. Start with `closeIcon`, `footer`, `footerText`, `submitText` for common usage.
packages/components/src/components/dm-drawer/DmDrawer.types.ts
Scenarios: packages/components/src/components/dm-drawer/DmDrawer.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
className | string | No | className configures DmDrawer. |
closeIcon | ReactNode | No | closeIcon configures DmDrawer. |
footer | ReactNode | No | footer configures DmDrawer. |
footerText | ReactNode | No | footerText configures DmDrawer. |
submitText | ReactNode | No | submitText configures DmDrawer. |
submitProps | Omit<ButtonProps, "children" | "onClick"> | No | submitProps configures DmDrawer. |
submitLoading | boolean | No | submitLoading configures DmDrawer. |
submitDisabled | boolean | No | submitDisabled configures DmDrawer. |
footerAlign | "left" | "center" | "right" | No | footerAlign configures DmDrawer. |
onSubmit | () => void | No | onSubmit configures DmDrawer. |
onClose | (event: MouseEvent<HTMLButtonElement>) => void | No | onClose configures DmDrawer. |