@moni-labs/moni-ui 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -194
- package/custom-elements.json +1709 -338
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +6 -0
- package/dist/components/_base/field-styles.d.ts +51 -16
- package/dist/components/_base/field-styles.d.ts.map +1 -1
- package/dist/components/_base/field-styles.js +164 -36
- package/dist/components/_base/index.d.ts +25 -0
- package/dist/components/_base/index.d.ts.map +1 -1
- package/dist/components/_base/index.js +25 -0
- package/dist/components/_base/interaction-styles.d.ts +39 -12
- package/dist/components/_base/interaction-styles.d.ts.map +1 -1
- package/dist/components/_base/interaction-styles.js +85 -33
- package/dist/components/_base/moni-element.d.ts +43 -8
- package/dist/components/_base/moni-element.d.ts.map +1 -1
- package/dist/components/_base/moni-element.js +43 -8
- package/dist/components/_base/shared-styles.d.ts +41 -17
- package/dist/components/_base/shared-styles.d.ts.map +1 -1
- package/dist/components/_base/shared-styles.js +113 -21
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -0
- package/dist/components/loading-shapes.d.ts +6 -0
- package/dist/components/loading-shapes.d.ts.map +1 -1
- package/dist/components/loading-shapes.js +6 -0
- package/dist/components/moni-app-bar.d.ts +128 -33
- package/dist/components/moni-app-bar.d.ts.map +1 -1
- package/dist/components/moni-app-bar.js +121 -26
- package/dist/components/moni-badge.d.ts +122 -14
- package/dist/components/moni-badge.d.ts.map +1 -1
- package/dist/components/moni-badge.js +122 -14
- package/dist/components/moni-bottom-sheet.d.ts +120 -15
- package/dist/components/moni-bottom-sheet.d.ts.map +1 -1
- package/dist/components/moni-bottom-sheet.js +116 -12
- package/dist/components/moni-button-group.d.ts +53 -27
- package/dist/components/moni-button-group.d.ts.map +1 -1
- package/dist/components/moni-button-group.js +49 -23
- package/dist/components/moni-button-segment.d.ts +28 -8
- package/dist/components/moni-button-segment.d.ts.map +1 -1
- package/dist/components/moni-button-segment.js +27 -7
- package/dist/components/moni-button.d.ts +51 -32
- package/dist/components/moni-button.d.ts.map +1 -1
- package/dist/components/moni-button.js +50 -31
- package/dist/components/moni-card.d.ts +91 -31
- package/dist/components/moni-card.d.ts.map +1 -1
- package/dist/components/moni-card.js +86 -26
- package/dist/components/moni-carousel.d.ts +80 -17
- package/dist/components/moni-carousel.d.ts.map +1 -1
- package/dist/components/moni-carousel.js +258 -34
- package/dist/components/moni-checkbox.d.ts +122 -17
- package/dist/components/moni-checkbox.d.ts.map +1 -1
- package/dist/components/moni-checkbox.js +118 -14
- package/dist/components/moni-chip.d.ts +56 -30
- package/dist/components/moni-chip.d.ts.map +1 -1
- package/dist/components/moni-chip.js +51 -25
- package/dist/components/moni-color-field.d.ts +44 -6
- package/dist/components/moni-color-field.d.ts.map +1 -1
- package/dist/components/moni-color-field.js +43 -5
- package/dist/components/moni-context-menu.d.ts +44 -22
- package/dist/components/moni-context-menu.d.ts.map +1 -1
- package/dist/components/moni-context-menu.js +43 -21
- package/dist/components/moni-dialog.d.ts +107 -15
- package/dist/components/moni-dialog.d.ts.map +1 -1
- package/dist/components/moni-dialog.js +105 -14
- package/dist/components/moni-divider.d.ts +50 -15
- package/dist/components/moni-divider.d.ts.map +1 -1
- package/dist/components/moni-divider.js +49 -14
- package/dist/components/moni-expansion.d.ts +44 -8
- package/dist/components/moni-expansion.d.ts.map +1 -1
- package/dist/components/moni-expansion.js +43 -7
- package/dist/components/moni-fab-menu.d.ts +39 -20
- package/dist/components/moni-fab-menu.d.ts.map +1 -1
- package/dist/components/moni-fab-menu.js +38 -19
- package/dist/components/moni-fab.d.ts +49 -23
- package/dist/components/moni-fab.d.ts.map +1 -1
- package/dist/components/moni-fab.js +46 -20
- package/dist/components/moni-file-field.d.ts +54 -14
- package/dist/components/moni-file-field.d.ts.map +1 -1
- package/dist/components/moni-file-field.js +53 -13
- package/dist/components/moni-icon.d.ts +78 -11
- package/dist/components/moni-icon.d.ts.map +1 -1
- package/dist/components/moni-icon.js +77 -10
- package/dist/components/moni-list-item.d.ts +61 -30
- package/dist/components/moni-list-item.d.ts.map +1 -1
- package/dist/components/moni-list-item.js +55 -24
- package/dist/components/moni-list.d.ts +37 -13
- package/dist/components/moni-list.d.ts.map +1 -1
- package/dist/components/moni-list.js +36 -12
- package/dist/components/moni-loading-indicator.d.ts +38 -11
- package/dist/components/moni-loading-indicator.d.ts.map +1 -1
- package/dist/components/moni-loading-indicator.js +37 -10
- package/dist/components/moni-menu-item.d.ts +31 -8
- package/dist/components/moni-menu-item.d.ts.map +1 -1
- package/dist/components/moni-menu-item.js +30 -7
- package/dist/components/moni-menu.d.ts +58 -33
- package/dist/components/moni-menu.d.ts.map +1 -1
- package/dist/components/moni-menu.js +51 -26
- package/dist/components/moni-morph-modal.d.ts +7 -1
- package/dist/components/moni-morph-modal.d.ts.map +1 -1
- package/dist/components/moni-morph-modal.js +46 -24
- package/dist/components/moni-nav-item.d.ts +50 -10
- package/dist/components/moni-nav-item.d.ts.map +1 -1
- package/dist/components/moni-nav-item.js +48 -8
- package/dist/components/moni-nav.d.ts +57 -22
- package/dist/components/moni-nav.d.ts.map +1 -1
- package/dist/components/moni-nav.js +53 -18
- package/dist/components/moni-progress.d.ts +108 -20
- package/dist/components/moni-progress.d.ts.map +1 -1
- package/dist/components/moni-progress.js +104 -16
- package/dist/components/moni-radio.d.ts +106 -14
- package/dist/components/moni-radio.d.ts.map +1 -1
- package/dist/components/moni-radio.js +104 -13
- package/dist/components/moni-ripple.d.ts +121 -10
- package/dist/components/moni-ripple.d.ts.map +1 -1
- package/dist/components/moni-ripple.js +120 -9
- package/dist/components/moni-segmented-button.d.ts +31 -11
- package/dist/components/moni-segmented-button.d.ts.map +1 -1
- package/dist/components/moni-segmented-button.js +30 -10
- package/dist/components/moni-select-option.d.ts +43 -9
- package/dist/components/moni-select-option.d.ts.map +1 -1
- package/dist/components/moni-select-option.js +41 -7
- package/dist/components/moni-select.d.ts +59 -2
- package/dist/components/moni-select.d.ts.map +1 -1
- package/dist/components/moni-select.js +58 -1
- package/dist/components/moni-shape.d.ts +1 -1
- package/dist/components/moni-side-sheet.d.ts +56 -19
- package/dist/components/moni-side-sheet.d.ts.map +1 -1
- package/dist/components/moni-side-sheet.js +53 -16
- package/dist/components/moni-slider.d.ts +56 -25
- package/dist/components/moni-slider.d.ts.map +1 -1
- package/dist/components/moni-slider.js +55 -24
- package/dist/components/moni-snackbar.d.ts +86 -17
- package/dist/components/moni-snackbar.d.ts.map +1 -1
- package/dist/components/moni-snackbar.js +85 -16
- package/dist/components/moni-split-button.d.ts +38 -9
- package/dist/components/moni-split-button.d.ts.map +1 -1
- package/dist/components/moni-split-button.js +37 -8
- package/dist/components/moni-step.d.ts +42 -9
- package/dist/components/moni-step.d.ts.map +1 -1
- package/dist/components/moni-step.js +41 -8
- package/dist/components/moni-stepper.d.ts +43 -6
- package/dist/components/moni-stepper.d.ts.map +1 -1
- package/dist/components/moni-stepper.js +42 -5
- package/dist/components/moni-switch.d.ts +103 -16
- package/dist/components/moni-switch.d.ts.map +1 -1
- package/dist/components/moni-switch.js +99 -13
- package/dist/components/moni-tab.d.ts +35 -8
- package/dist/components/moni-tab.d.ts.map +1 -1
- package/dist/components/moni-tab.js +34 -7
- package/dist/components/moni-tabs.d.ts +51 -13
- package/dist/components/moni-tabs.d.ts.map +1 -1
- package/dist/components/moni-tabs.js +48 -10
- package/dist/components/moni-text-field.d.ts +55 -10
- package/dist/components/moni-text-field.d.ts.map +1 -1
- package/dist/components/moni-text-field.js +54 -9
- package/dist/components/moni-textarea.d.ts +51 -21
- package/dist/components/moni-textarea.d.ts.map +1 -1
- package/dist/components/moni-textarea.js +48 -18
- package/dist/components/moni-time-picker.d.ts +41 -11
- package/dist/components/moni-time-picker.d.ts.map +1 -1
- package/dist/components/moni-time-picker.js +40 -10
- package/dist/components/moni-toolbar.d.ts +43 -15
- package/dist/components/moni-toolbar.d.ts.map +1 -1
- package/dist/components/moni-toolbar.js +42 -14
- package/dist/components/moni-tooltip.d.ts +55 -25
- package/dist/components/moni-tooltip.d.ts.map +1 -1
- package/dist/components/moni-tooltip.js +54 -24
- package/dist/components/moni-typography.d.ts +43 -18
- package/dist/components/moni-typography.d.ts.map +1 -1
- package/dist/components/moni-typography.js +42 -17
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -2
- package/dist/styles/tailwind.css +67 -0
- package/dist/styles/tokens.css +111 -99
- package/dist/utils/color.d.ts +181 -2
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js +182 -4
- package/dist/utils/theme.svelte.d.ts +305 -2
- package/dist/utils/theme.svelte.d.ts.map +1 -1
- package/dist/utils/theme.svelte.js +331 -2
- package/dist/web-components.d.ts +28 -0
- package/dist/web-components.d.ts.map +1 -1
- package/dist/web-components.js +29 -2
- package/package.json +1 -1
- package/src/actions/index.ts +7 -0
- package/src/components/_base/field-styles.ts +165 -37
- package/src/components/_base/index.ts +27 -0
- package/src/components/_base/interaction-styles.ts +86 -33
- package/src/components/_base/moni-element.ts +44 -8
- package/src/components/_base/shared-styles.ts +114 -21
- package/src/components/index.ts +7 -0
- package/src/components/loading-shapes.ts +7 -0
- package/src/components/moni-app-bar.ts +127 -26
- package/src/components/moni-badge.ts +128 -14
- package/src/components/moni-bottom-sheet.ts +125 -13
- package/src/components/moni-button-group.ts +50 -23
- package/src/components/moni-button-segment.ts +28 -7
- package/src/components/moni-button.ts +51 -31
- package/src/components/moni-card.ts +90 -26
- package/src/components/moni-carousel.ts +282 -34
- package/src/components/moni-checkbox.ts +125 -14
- package/src/components/moni-chip.ts +52 -25
- package/src/components/moni-color-field.ts +44 -5
- package/src/components/moni-context-menu.ts +44 -21
- package/src/components/moni-dialog.ts +111 -14
- package/src/components/moni-divider.ts +50 -14
- package/src/components/moni-expansion.ts +44 -7
- package/src/components/moni-fab-menu.ts +39 -19
- package/src/components/moni-fab.ts +47 -20
- package/src/components/moni-file-field.ts +54 -13
- package/src/components/moni-icon.ts +80 -10
- package/src/components/moni-list-item.ts +56 -24
- package/src/components/moni-list.ts +37 -12
- package/src/components/moni-loading-indicator.ts +38 -10
- package/src/components/moni-menu-item.ts +31 -7
- package/src/components/moni-menu.ts +52 -26
- package/src/components/moni-morph-modal.ts +58 -24
- package/src/components/moni-nav-item.ts +49 -8
- package/src/components/moni-nav.ts +54 -18
- package/src/components/moni-progress.ts +109 -16
- package/src/components/moni-radio.ts +111 -13
- package/src/components/moni-ripple.ts +126 -9
- package/src/components/moni-segmented-button.ts +31 -10
- package/src/components/moni-select-option.ts +42 -7
- package/src/components/moni-select.ts +79 -1
- package/src/components/moni-side-sheet.ts +54 -16
- package/src/components/moni-slider.ts +56 -24
- package/src/components/moni-snackbar.ts +90 -16
- package/src/components/moni-split-button.ts +38 -8
- package/src/components/moni-step.ts +42 -8
- package/src/components/moni-stepper.ts +43 -5
- package/src/components/moni-switch.ts +106 -13
- package/src/components/moni-tab.ts +35 -7
- package/src/components/moni-tabs.ts +49 -10
- package/src/components/moni-text-field.ts +55 -9
- package/src/components/moni-textarea.ts +49 -18
- package/src/components/moni-time-picker.ts +41 -10
- package/src/components/moni-toolbar.ts +43 -14
- package/src/components/moni-tooltip.ts +55 -24
- package/src/components/moni-typography.ts +43 -17
- package/src/index.ts +67 -3
- package/src/styles/tailwind.css +67 -0
- package/src/styles/tokens.css +111 -99
- package/src/types/svelte-runes.d.ts +64 -2
- package/src/utils/color.ts +286 -5
- package/src/utils/theme.svelte.ts +411 -2
- package/src/web-components.ts +31 -2
- package/dist/assets/shapes/arch.svg +0 -1
- package/dist/assets/shapes/arrow.svg +0 -1
- package/dist/assets/shapes/boom.svg +0 -1
- package/dist/assets/shapes/burst.svg +0 -1
- package/dist/assets/shapes/circle.svg +0 -1
- package/dist/assets/shapes/clamshell.svg +0 -1
- package/dist/assets/shapes/diamond.svg +0 -1
- package/dist/assets/shapes/fan.svg +0 -1
- package/dist/assets/shapes/flower.svg +0 -1
- package/dist/assets/shapes/gem.svg +0 -1
- package/dist/assets/shapes/ghost-ish.svg +0 -1
- package/dist/assets/shapes/heart.svg +0 -1
- package/dist/assets/shapes/leaf-clover4.svg +0 -1
- package/dist/assets/shapes/leaf-clover8.svg +0 -1
- package/dist/assets/shapes/loading-indicator.svg +0 -1
- package/dist/assets/shapes/oval.svg +0 -1
- package/dist/assets/shapes/pentagon.svg +0 -1
- package/dist/assets/shapes/pill.svg +0 -1
- package/dist/assets/shapes/pixel-circle.svg +0 -1
- package/dist/assets/shapes/pixel-triangle.svg +0 -1
- package/dist/assets/shapes/puffy-diamond.svg +0 -1
- package/dist/assets/shapes/puffy.svg +0 -1
- package/dist/assets/shapes/semicircle.svg +0 -1
- package/dist/assets/shapes/sided-cookie12.svg +0 -1
- package/dist/assets/shapes/sided-cookie4.svg +0 -1
- package/dist/assets/shapes/sided-cookie6.svg +0 -1
- package/dist/assets/shapes/sided-cookie7.svg +0 -1
- package/dist/assets/shapes/sided-cookie9.svg +0 -1
- package/dist/assets/shapes/slanted.svg +0 -1
- package/dist/assets/shapes/soft-boom.svg +0 -1
- package/dist/assets/shapes/soft-burst.svg +0 -1
- package/dist/assets/shapes/square.svg +0 -1
- package/dist/assets/shapes/sunny.svg +0 -1
- package/dist/assets/shapes/triangle.svg +0 -1
- package/dist/assets/shapes/very-sunny.svg +0 -1
- package/dist/assets/shapes/wavy-circle.svg +0 -1
- package/dist/assets/shapes/wavy.svg +0 -1
- package/src/assets/shapes/arch.svg +0 -1
- package/src/assets/shapes/arrow.svg +0 -1
- package/src/assets/shapes/boom.svg +0 -1
- package/src/assets/shapes/burst.svg +0 -1
- package/src/assets/shapes/circle.svg +0 -1
- package/src/assets/shapes/clamshell.svg +0 -1
- package/src/assets/shapes/diamond.svg +0 -1
- package/src/assets/shapes/fan.svg +0 -1
- package/src/assets/shapes/flower.svg +0 -1
- package/src/assets/shapes/gem.svg +0 -1
- package/src/assets/shapes/ghost-ish.svg +0 -1
- package/src/assets/shapes/heart.svg +0 -1
- package/src/assets/shapes/leaf-clover4.svg +0 -1
- package/src/assets/shapes/leaf-clover8.svg +0 -1
- package/src/assets/shapes/loading-indicator.svg +0 -1
- package/src/assets/shapes/oval.svg +0 -1
- package/src/assets/shapes/pentagon.svg +0 -1
- package/src/assets/shapes/pill.svg +0 -1
- package/src/assets/shapes/pixel-circle.svg +0 -1
- package/src/assets/shapes/pixel-triangle.svg +0 -1
- package/src/assets/shapes/puffy-diamond.svg +0 -1
- package/src/assets/shapes/puffy.svg +0 -1
- package/src/assets/shapes/semicircle.svg +0 -1
- package/src/assets/shapes/sided-cookie12.svg +0 -1
- package/src/assets/shapes/sided-cookie4.svg +0 -1
- package/src/assets/shapes/sided-cookie6.svg +0 -1
- package/src/assets/shapes/sided-cookie7.svg +0 -1
- package/src/assets/shapes/sided-cookie9.svg +0 -1
- package/src/assets/shapes/slanted.svg +0 -1
- package/src/assets/shapes/soft-boom.svg +0 -1
- package/src/assets/shapes/soft-burst.svg +0 -1
- package/src/assets/shapes/square.svg +0 -1
- package/src/assets/shapes/sunny.svg +0 -1
- package/src/assets/shapes/triangle.svg +0 -1
- package/src/assets/shapes/very-sunny.svg +0 -1
- package/src/assets/shapes/wavy-circle.svg +0 -1
- package/src/assets/shapes/wavy.svg +0 -1
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-button.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css } from 'lit';
|
|
2
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -6,41 +13,54 @@ import './moni-icon.js';
|
|
|
6
13
|
import './moni-progress.js';
|
|
7
14
|
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
16
|
+
* Material Design 3 Button component.
|
|
17
|
+
*
|
|
18
|
+
* Buttons allow users to take actions and make choices with a single tap.
|
|
19
|
+
* This component provides all M3 button variants, sizes, and shape morphing
|
|
20
|
+
* capabilities (e.g. morphing to a pill shape on press or toggle).
|
|
21
|
+
*
|
|
22
|
+
* **M3 spec reference:** `m3-docs/components/buttons/specs.md`
|
|
23
|
+
*
|
|
24
|
+
* **Variants:**
|
|
25
|
+
* - `filled` (default) — High emphasis. Use for primary actions.
|
|
26
|
+
* - `tonal` — Medium emphasis. Secondary actions that still need to stand out.
|
|
27
|
+
* - `elevated` — Medium emphasis with shadow. Used when sitting on patterned backgrounds.
|
|
28
|
+
* - `outlined` — Medium emphasis, no fill. Secondary or tertiary actions.
|
|
29
|
+
* - `text` — Low emphasis. Tertiary actions (e.g. dialog cancel button).
|
|
30
|
+
*
|
|
31
|
+
* **Shape morphing (M3 Expressive feature):**
|
|
32
|
+
* - On press (active state): Round and square buttons morph to a slightly squarer
|
|
33
|
+
* "pressed" shape with specific M3 corner radii (e.g. XS/S 8dp, M 12dp).
|
|
34
|
+
* - On toggle (`active` attribute): The resting shape flips (e.g. round ↔ square).
|
|
35
|
+
*
|
|
36
|
+
* **Rendering as a link:**
|
|
37
|
+
* When the `href` attribute is provided, the component internally renders as
|
|
38
|
+
* an `<a>` element instead of a `<button>`, allowing native routing and
|
|
39
|
+
* middle-click (open in new tab) behaviors while maintaining button visuals.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```html
|
|
43
|
+
* <!-- Primary filled button -->
|
|
44
|
+
* <moni-button icon="add">Create new</moni-button>
|
|
45
|
+
*
|
|
46
|
+
* <!-- Outlined button -->
|
|
47
|
+
* <moni-button variant="outlined">Cancel</moni-button>
|
|
10
48
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* corner radii: XS 8dp, S 8dp, M 12dp, L 16dp, XL 16dp. The per-size rules
|
|
14
|
-
* `.button.{xsmall,small,large,xlarge,extra}:active` override the default
|
|
15
|
-
* `:active` rule by specificity (0,4,0 vs 0,3,0).
|
|
49
|
+
* <!-- Toggle button (toggles active state on click) -->
|
|
50
|
+
* <moni-button icon="favorite" active>Like</moni-button>
|
|
16
51
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
52
|
+
* <!-- Link button -->
|
|
53
|
+
* <moni-button href="/settings" icon="settings">Settings</moni-button>
|
|
54
|
+
* ```
|
|
19
55
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* (legacy `extra` alias for `xlarge`, deprecated in v0.3.0)
|
|
24
|
-
* - shape: round (default) | square | circle | no-round
|
|
25
|
-
* | left-round | right-round | top-round | bottom-round
|
|
26
|
-
* | left-round-flat | right-round-flat | top-round-flat
|
|
27
|
-
* | bottom-round-flat | inner-round
|
|
28
|
-
* (the `-flat` and `inner-round` shapes are Moni brand
|
|
29
|
-
* extensions; not part of M3 — see WEB_COMPONENT_GUIDELINES.md)
|
|
30
|
-
* - disabled: present → native disabled
|
|
31
|
-
* - loading: present → shows an indeterminate circular progress
|
|
32
|
-
* - active: present → toggle (selection) state; applies shape morph
|
|
33
|
-
* (round↔square) and variant-specific color swap
|
|
34
|
-
* - icon: Material Symbols name to prepend
|
|
35
|
-
* - icon-trailing: Material Symbols name to append
|
|
36
|
-
* - type: button (default) | submit | reset
|
|
37
|
-
* - href: present → renders as `<a>` instead of `<button>`
|
|
38
|
-
* - target: for `<a>` rendering
|
|
56
|
+
* @slot default - The button label text.
|
|
57
|
+
* @slot icon - Optional override for the leading icon.
|
|
58
|
+
* @slot icon-trailing - Optional override for the trailing icon.
|
|
39
59
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
60
|
+
* @csspart button - The inner `<button>` or `<a>` element.
|
|
61
|
+
* @csspart icon - The leading icon container.
|
|
62
|
+
* @csspart label - The label container.
|
|
63
|
+
* @csspart trailing-icon - The trailing icon container.
|
|
44
64
|
*/
|
|
45
65
|
@customElement('moni-button')
|
|
46
66
|
export class MoniButton extends MoniElement {
|
|
@@ -1,45 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-card.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css } from 'lit';
|
|
2
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
|
-
* Material 3 Card
|
|
13
|
+
* Material Design 3 Card component.
|
|
14
|
+
*
|
|
15
|
+
* Cards display content and actions about a single subject. They are
|
|
16
|
+
* container surfaces that group related information together, making it
|
|
17
|
+
* easy for users to scan and interact with collections of related data.
|
|
18
|
+
*
|
|
19
|
+
* **M3 spec reference:** `m3-docs/components/cards/specs.md`
|
|
7
20
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
21
|
+
* **Variants:**
|
|
22
|
+
* - `elevated` (default) — `surface-container-low` background + `--elevate1` shadow.
|
|
23
|
+
* Best for collections where the card needs visual separation from a
|
|
24
|
+
* patterned or colored background. Gains shadow on hover/drag.
|
|
25
|
+
* - `filled` — `surface-container-highest` background, no shadow.
|
|
26
|
+
* Lowest emphasis; use when cards sit directly on the main background surface.
|
|
27
|
+
* - `outlined` — `surface` background + 1dp `outline-variant` stroke.
|
|
28
|
+
* Highest structural emphasis without casting a shadow. Best on solid backgrounds.
|
|
16
29
|
*
|
|
17
|
-
* M3 measurements
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
30
|
+
* **M3 measurements:**
|
|
31
|
+
* - Container corner radius: 12dp.
|
|
32
|
+
* - Horizontal content padding: 16dp.
|
|
33
|
+
* - Gap between cards in a collection: max 8dp.
|
|
34
|
+
* - Headline text alignment: start.
|
|
22
35
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* - subhead: secondary title slot.
|
|
28
|
-
* - supporting: supporting text slot.
|
|
29
|
-
* - actions: action buttons row at the bottom of the card.
|
|
36
|
+
* **Interactive cards:**
|
|
37
|
+
* When `clickable=true`, the card renders M3 state layer overlays on hover,
|
|
38
|
+
* focus, and press via the `::before` pseudo-element. The consumer must handle
|
|
39
|
+
* the `click` event to implement navigation or selection logic.
|
|
30
40
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```html
|
|
43
|
+
* <moni-card variant="outlined" clickable>
|
|
44
|
+
* <img slot="media" src="photo.jpg" alt="Card image" />
|
|
45
|
+
* <h3 slot="headline">Card Title</h3>
|
|
46
|
+
* <p slot="supporting">Supporting text that describes the card topic.</p>
|
|
47
|
+
* <div slot="actions">
|
|
48
|
+
* <moni-button variant="text">Cancel</moni-button>
|
|
49
|
+
* <moni-button>Confirm</moni-button>
|
|
50
|
+
* </div>
|
|
51
|
+
* </moni-card>
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @slot media - An image, video, or icon at the top of the card.
|
|
55
|
+
* @slot default - Primary body content (replaces all named slots if used).
|
|
56
|
+
* @slot headline - H3-equivalent title text.
|
|
57
|
+
* @slot subhead - Secondary title below the headline.
|
|
58
|
+
* @slot supporting - Descriptive supporting body text.
|
|
59
|
+
* @slot actions - Action buttons row at the bottom of the card.
|
|
60
|
+
*
|
|
61
|
+
* @csspart card - The outer card container.
|
|
62
|
+
* @csspart media - The media area wrapper.
|
|
63
|
+
* @csspart content - The content wrapper.
|
|
64
|
+
* @csspart actions - The actions row wrapper.
|
|
36
65
|
*/
|
|
37
66
|
@customElement('moni-card')
|
|
38
67
|
export class MoniCard extends MoniElement {
|
|
68
|
+
/**
|
|
69
|
+
* Visual variant of the card.
|
|
70
|
+
*
|
|
71
|
+
* - `'elevated'` (default) — Surface-low background + elevation shadow.
|
|
72
|
+
* - `'filled'` — Surface-highest background, no shadow.
|
|
73
|
+
* - `'outlined'` — Surface background + outline-variant stroke.
|
|
74
|
+
*
|
|
75
|
+
* @default 'elevated'
|
|
76
|
+
*/
|
|
39
77
|
@property({ reflect: true })
|
|
40
78
|
variant: 'elevated' | 'filled' | 'outlined' = 'elevated';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* When `true`, applies M3 state layer overlays (hover, focus, pressed)
|
|
82
|
+
* to communicate interactivity. The card background shifts slightly on hover.
|
|
83
|
+
*
|
|
84
|
+
* Use when the card itself is a clickable navigation or selection target.
|
|
85
|
+
*
|
|
86
|
+
* @default false
|
|
87
|
+
*/
|
|
41
88
|
@property({ type: Boolean, reflect: true }) clickable = false;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* When `true`, applies `--elevate3` box-shadow to simulate the M3 "dragged"
|
|
92
|
+
* state as specified in the M3 card interaction spec.
|
|
93
|
+
*
|
|
94
|
+
* Consumers should toggle this attribute based on the drag state of the card
|
|
95
|
+
* (e.g. via a drag-and-drop library callback).
|
|
96
|
+
*
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
42
99
|
@property({ type: Boolean, reflect: true }) draggable = false;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* When `true`, the card renders at 50% opacity with `cursor: not-allowed`,
|
|
103
|
+
* signaling that the card and its actions are unavailable.
|
|
104
|
+
*
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
43
107
|
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
44
108
|
|
|
45
109
|
static override styles = [
|