@eluan/core 0.5.0 → 0.6.0
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 +33 -1
- package/dist/{action-popover-D6K9aVFk.cjs → action-popover-DrHKPGqw.cjs} +1 -1
- package/dist/{action-popover-BVJQBuky.js → action-popover-NkXDAHJT.js} +1 -1
- package/dist/action-popover.cjs +1 -1
- package/dist/action-popover.js +1 -1
- package/dist/{avatar-Co-k8KqV.cjs → avatar-B-t3ctR4.cjs} +1 -1
- package/dist/{avatar-CS5f1irF.js → avatar-kDEa0rjF.js} +1 -1
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.js +1 -1
- package/dist/{badge-D9NYZFWH.js → badge-BLZ8V-KC.js} +10 -10
- package/dist/{badge-DXKWztL-.cjs → badge-D1A0Tc79.cjs} +1 -1
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +1 -1
- package/dist/{banner-COlEFRuK.cjs → banner-CNdwDPqA.cjs} +1 -1
- package/dist/{banner-CyYFLZXw.js → banner-DzSp5WfQ.js} +9 -9
- package/dist/banner.cjs +1 -1
- package/dist/banner.js +1 -1
- package/dist/box-DG-tkaYi.cjs +1 -0
- package/dist/box-DKbNgGGG.js +17 -0
- package/dist/box.cjs +1 -0
- package/dist/box.d.ts +1 -0
- package/dist/box.js +5 -0
- package/dist/{breadcrumb-NWXeCH5q.cjs → breadcrumb-BuxXkm6O.cjs} +1 -1
- package/dist/{breadcrumb-Cm1nb9Xj.js → breadcrumb-C6qj-tDx.js} +1 -1
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button--_WI-fM6.cjs +1 -0
- package/dist/{button-ANAPDrvs.js → button-DNSNShUc.js} +28 -26
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/{calendar-BpBsomy5.js → calendar-BA2tSwZD.js} +6 -6
- package/dist/{calendar-7LX5YGGT.cjs → calendar-DS5821-k.cjs} +3 -3
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.js +1 -1
- package/dist/{card-C88--zB4.cjs → card-BNdR5aDa.cjs} +1 -1
- package/dist/{card-BC_4C3ns.js → card-BSgN7WSe.js} +1 -1
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/{carousel-BfL7oy_q.cjs → carousel-4AERgboz.cjs} +1 -1
- package/dist/{carousel-DuP0hvF-.js → carousel-Bb7jpzep.js} +1 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.js +1 -1
- package/dist/{checkbox-Bi0Kmuut.js → checkbox-CGUTGery.js} +1 -1
- package/dist/{checkbox-M8DmWKiC.cjs → checkbox-Cq9sHU_S.cjs} +1 -1
- package/dist/{checkbox-group-KBwPhjmW.cjs → checkbox-group-DGXZ4o2-.cjs} +1 -1
- package/dist/{checkbox-group-CQMEJnhD.js → checkbox-group-Tkio3IhK.js} +1 -1
- package/dist/checkbox-group.cjs +1 -1
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/{command-BCl0seLL.cjs → command-D02vvta9.cjs} +1 -1
- package/dist/{command-Chs5VlBL.js → command-sUMAxm8S.js} +1 -1
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/components/box.d.ts +12 -0
- package/dist/components/grid.d.ts +35 -0
- package/dist/components/hover-card.d.ts +14 -2
- package/dist/components/icon.d.ts +26 -0
- package/dist/components/layout-shared.d.ts +307 -0
- package/dist/components/multi-select.d.ts +1 -1
- package/dist/components/navigation-drawer.d.ts +25 -5
- package/dist/components/row.d.ts +18 -0
- package/dist/components/stack.d.ts +14 -0
- package/dist/components/tone-shared.d.ts +39 -0
- package/dist/components/tooltip.d.ts +14 -2
- package/dist/components/typography.d.ts +22 -2
- package/dist/components/visually-hidden.d.ts +11 -0
- package/dist/{credit-card-input-DN-8vaFj.js → credit-card-input-9VPlzvDm.js} +1 -1
- package/dist/{credit-card-input-CUqA9CX3.cjs → credit-card-input-DppPJBne.cjs} +1 -1
- package/dist/credit-card-input.cjs +1 -1
- package/dist/credit-card-input.js +1 -1
- package/dist/{date-picker-ni8td8Ru.js → date-picker-M5hLx_1s.js} +2 -2
- package/dist/{date-picker-DGBsfZXx.cjs → date-picker-hE7cDg2B.cjs} +1 -1
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/{datetime-picker-C1d63MaA.cjs → datetime-picker-BeRUPJ7s.cjs} +1 -1
- package/dist/{datetime-picker-DsnHYRK-.js → datetime-picker-CIqBZYMH.js} +3 -3
- package/dist/datetime-picker.cjs +1 -1
- package/dist/datetime-picker.js +1 -1
- package/dist/{decimal-input-yTk35W_5.js → decimal-input-Bg2BPKIr.js} +38 -38
- package/dist/decimal-input-CkTEjo2J.cjs +1 -0
- package/dist/decimal-input.cjs +1 -1
- package/dist/decimal-input.js +1 -1
- package/dist/{dialog-B8eWKqzS.js → dialog-Bsfviqvy.js} +2 -2
- package/dist/dialog-DRAoumvB.cjs +1 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/{email-input-DFI4h_KN.cjs → email-input-CehmtNUq.cjs} +1 -1
- package/dist/{email-input-pX0hlYV3.js → email-input-DIiY9Q3S.js} +1 -1
- package/dist/email-input.cjs +1 -1
- package/dist/email-input.js +1 -1
- package/dist/{footer-DB0_-IwN.cjs → footer-fovIsy-0.cjs} +1 -1
- package/dist/{footer-B3KUIwXW.js → footer-jWaFq3qk.js} +9 -9
- package/dist/footer.cjs +1 -1
- package/dist/footer.js +1 -1
- package/dist/grid-BDz4Xs6M.cjs +1 -0
- package/dist/grid-BX5vZjDo.js +612 -0
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +1 -0
- package/dist/grid.js +5 -0
- package/dist/{header-CDOWlOAR.js → header-Dnf8AnIx.js} +2 -2
- package/dist/{header-CiZQY_7S.cjs → header-DzItWqW4.cjs} +1 -1
- package/dist/header.cjs +1 -1
- package/dist/header.js +1 -1
- package/dist/hover-card-C5KsTSZR.cjs +1 -0
- package/dist/hover-card-C_FCzE41.js +21 -0
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.js +1 -1
- package/dist/icon-BmLOodCQ.cjs +1 -0
- package/dist/icon-BwDfkIdR.js +153 -0
- package/dist/icon.cjs +1 -0
- package/dist/icon.d.ts +1 -0
- package/dist/icon.js +5 -0
- package/dist/index.cjs +10 -5
- package/dist/index.d.ts +6 -0
- package/dist/index.js +612 -541
- package/dist/{input-BrGJn-D9.cjs → input-BcjL2oxv.cjs} +1 -1
- package/dist/{input-Cccufiqn.js → input-CPb9yVU5.js} +8 -8
- package/dist/input-otp-BhJ3ERrY.cjs +1 -0
- package/dist/{input-otp-DmEGB1nu.js → input-otp-CTvJztkH.js} +32 -32
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/layout-shared-B_1iX4Hj.js +319 -0
- package/dist/layout-shared-CsBZcT4V.cjs +1 -0
- package/dist/multi-select-CVxkWW29.js +85 -0
- package/dist/multi-select-DBFINH3F.cjs +1 -0
- package/dist/multi-select.cjs +1 -1
- package/dist/multi-select.js +1 -1
- package/dist/navigation-drawer-BCBFtLEq.cjs +1 -0
- package/dist/navigation-drawer-BMyHXhhX.js +198 -0
- package/dist/navigation-drawer.cjs +1 -1
- package/dist/navigation-drawer.js +1 -1
- package/dist/{number-input-vICbRc2y.js → number-input-Cm9YPBOX.js} +1 -1
- package/dist/{number-input-Bc7jUsu-.cjs → number-input-Dr9MbuRV.cjs} +1 -1
- package/dist/number-input.cjs +1 -1
- package/dist/number-input.js +1 -1
- package/dist/{pagination-DTWRjiOm.js → pagination-D2tjMpVU.js} +2 -2
- package/dist/{pagination-4IuE_APs.cjs → pagination-yKmFlFMR.cjs} +1 -1
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.js +1 -1
- package/dist/{password-input-BwnlHPbX.cjs → password-input-CmHubHuU.cjs} +1 -1
- package/dist/{password-input-B9V45d3Q.js → password-input-ljwdGCO6.js} +2 -2
- package/dist/password-input.cjs +1 -1
- package/dist/password-input.js +1 -1
- package/dist/{phone-input-BQjZj5jI.cjs → phone-input-B8VksCer.cjs} +1 -1
- package/dist/{phone-input-CSBpGHvI.js → phone-input-qTL6K8rT.js} +2 -2
- package/dist/phone-input.cjs +1 -1
- package/dist/phone-input.js +1 -1
- package/dist/progress-BpdmBGaX.cjs +1 -0
- package/dist/{progress-Dz_it5I-.js → progress-ChFf9bIq.js} +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.js +1 -1
- package/dist/providers/create-theme.d.ts +10 -1
- package/dist/providers/eluan-provider.d.ts +2 -1
- package/dist/providers/portal-container.d.ts +1 -1
- package/dist/{radio-group-C--1neiq.cjs → radio-group-9gozRouT.cjs} +1 -1
- package/dist/{radio-group-CNMPZx_2.js → radio-group-Bs9933bk.js} +6 -6
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +1 -1
- package/dist/{rich-text-BZSyuYSo.js → rich-text-DImwK9hN.js} +1 -1
- package/dist/{rich-text-DerWxzdn.cjs → rich-text-DzHLeG7W.cjs} +1 -1
- package/dist/rich-text.cjs +1 -1
- package/dist/rich-text.js +1 -1
- package/dist/row-BYAk7G5d.js +37 -0
- package/dist/row-Bjn-GQAC.cjs +1 -0
- package/dist/row.cjs +1 -0
- package/dist/row.d.ts +1 -0
- package/dist/row.js +5 -0
- package/dist/{search-input-Dmmo-BEL.cjs → search-input-BKTjebg7.cjs} +1 -1
- package/dist/{search-input-bFNW6oiE.js → search-input-Dgr9kT1a.js} +1 -1
- package/dist/search-input.cjs +1 -1
- package/dist/search-input.js +1 -1
- package/dist/select-Cdh991T-.cjs +1 -0
- package/dist/{select-DDSYjKtj.js → select-Dp5AJ6I-.js} +15 -15
- package/dist/select.cjs +1 -1
- package/dist/select.js +1 -1
- package/dist/sheet-CkXjinUG.cjs +1 -0
- package/dist/{sheet-D5HWF66e.js → sheet-uiyHNKEw.js} +6 -6
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.js +1 -1
- package/dist/{slider-CZQBAXup.js → slider-BQmbh0Nl.js} +1 -1
- package/dist/{slider-DdEOapYP.cjs → slider-DK2yk-YK.cjs} +1 -1
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +1 -1
- package/dist/stack-Ck1w2iJu.cjs +1 -0
- package/dist/stack-D2btWM1t.js +27 -0
- package/dist/stack.cjs +1 -0
- package/dist/stack.d.ts +1 -0
- package/dist/stack.js +5 -0
- package/dist/{stepper-D5nDwJUz.cjs → stepper-ByYKX7qw.cjs} +1 -1
- package/dist/{stepper-BtlKiHtd.js → stepper-Copsj87A.js} +4 -4
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +1 -1
- package/dist/styles.css +935 -59
- package/dist/{switch-KzBijHMJ.cjs → switch-C2OPCq5Z.cjs} +1 -1
- package/dist/{switch-C7EBLT5H.js → switch-CXBWUZcq.js} +3 -3
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +1 -1
- package/dist/{tabs-DztJ2iVc.cjs → tabs-D8p6Tr5i.cjs} +1 -1
- package/dist/{tabs-C9NKBmH0.js → tabs-TV4_2wi1.js} +9 -9
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/{textarea-Dl-daLHR.cjs → textarea-BnpQmE74.cjs} +1 -1
- package/dist/{textarea-DXUk1b_-.js → textarea-CJRmnazN.js} +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +1 -1
- package/dist/{time-input-BPoFvoeM.js → time-input-A603mEFQ.js} +38 -38
- package/dist/time-input-qxljhdEb.cjs +1 -0
- package/dist/time-input.cjs +1 -1
- package/dist/time-input.js +1 -1
- package/dist/{toggle-Dv1VZ5Le.js → toggle-Bx3q15Pu.js} +6 -6
- package/dist/{toggle-Bvh1v32T.cjs → toggle-Z3t4jPdv.cjs} +1 -1
- package/dist/{toggle-group-SyHMwO90.cjs → toggle-group-BZIW4wJp.cjs} +1 -1
- package/dist/{toggle-group-DE8BPZih.js → toggle-group-LaZmOMx_.js} +7 -7
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.js +1 -1
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +1 -1
- package/dist/tooltip-DZqn4wKl.js +23 -0
- package/dist/tooltip-faf1dIXp.cjs +1 -0
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/{tree-view-CyeJR7cW.js → tree-view-DRmm6oL6.js} +23 -23
- package/dist/tree-view-DVQyRQDg.cjs +1 -0
- package/dist/tree-view.cjs +1 -1
- package/dist/tree-view.js +1 -1
- package/dist/visually-hidden-BQMRYGxP.js +14 -0
- package/dist/visually-hidden-DzxxOswl.cjs +1 -0
- package/dist/visually-hidden.cjs +1 -0
- package/dist/visually-hidden.d.ts +1 -0
- package/dist/visually-hidden.js +5 -0
- package/package.json +8 -8
- package/skills/eluan/DESIGN.md +409 -0
- package/skills/eluan/SKILL.md +166 -0
- package/skills/eluan/components/accordion.md +212 -0
- package/skills/eluan/components/action-popover.md +266 -0
- package/skills/eluan/components/aspect-ratio.md +169 -0
- package/skills/eluan/components/avatar.md +277 -0
- package/skills/eluan/components/badge.md +190 -0
- package/skills/eluan/components/banner.md +247 -0
- package/skills/eluan/components/box.md +166 -0
- package/skills/eluan/components/breadcrumb.md +240 -0
- package/skills/eluan/components/button.md +214 -0
- package/skills/eluan/components/calendar.md +192 -0
- package/skills/eluan/components/card.md +270 -0
- package/skills/eluan/components/carousel.md +274 -0
- package/skills/eluan/components/checkbox-group.md +228 -0
- package/skills/eluan/components/checkbox.md +226 -0
- package/skills/eluan/components/code-block.md +193 -0
- package/skills/eluan/components/collapsible.md +240 -0
- package/skills/eluan/components/command.md +359 -0
- package/skills/eluan/components/context-menu.md +296 -0
- package/skills/eluan/components/credit-card-input.md +217 -0
- package/skills/eluan/components/date-picker.md +255 -0
- package/skills/eluan/components/date-time-picker.md +196 -0
- package/skills/eluan/components/decimal-input.md +232 -0
- package/skills/eluan/components/dialog.md +322 -0
- package/skills/eluan/components/drawer.md +292 -0
- package/skills/eluan/components/dropdown-menu.md +450 -0
- package/skills/eluan/components/email-input.md +200 -0
- package/skills/eluan/components/fieldset.md +219 -0
- package/skills/eluan/components/file-input.md +249 -0
- package/skills/eluan/components/footer.md +290 -0
- package/skills/eluan/components/form-label.md +254 -0
- package/skills/eluan/components/grid.md +192 -0
- package/skills/eluan/components/header.md +242 -0
- package/skills/eluan/components/hover-card.md +215 -0
- package/skills/eluan/components/icon.md +161 -0
- package/skills/eluan/components/input-otp.md +227 -0
- package/skills/eluan/components/input.md +249 -0
- package/skills/eluan/components/kbd.md +216 -0
- package/skills/eluan/components/media.md +244 -0
- package/skills/eluan/components/menubar.md +300 -0
- package/skills/eluan/components/multi-select.md +221 -0
- package/skills/eluan/components/navigation-drawer.md +297 -0
- package/skills/eluan/components/navigation-menu.md +291 -0
- package/skills/eluan/components/number-input.md +190 -0
- package/skills/eluan/components/pagination.md +262 -0
- package/skills/eluan/components/password-input.md +218 -0
- package/skills/eluan/components/phone-input.md +205 -0
- package/skills/eluan/components/popover.md +250 -0
- package/skills/eluan/components/progress.md +185 -0
- package/skills/eluan/components/radio-group.md +232 -0
- package/skills/eluan/components/rich-text.md +195 -0
- package/skills/eluan/components/row.md +174 -0
- package/skills/eluan/components/scroll-area.md +203 -0
- package/skills/eluan/components/search-input.md +281 -0
- package/skills/eluan/components/segmented-control.md +201 -0
- package/skills/eluan/components/select.md +296 -0
- package/skills/eluan/components/separator.md +179 -0
- package/skills/eluan/components/sheet.md +326 -0
- package/skills/eluan/components/skeleton.md +202 -0
- package/skills/eluan/components/slider.md +195 -0
- package/skills/eluan/components/spinner.md +187 -0
- package/skills/eluan/components/stack.md +158 -0
- package/skills/eluan/components/stepper.md +236 -0
- package/skills/eluan/components/switch.md +218 -0
- package/skills/eluan/components/table.md +348 -0
- package/skills/eluan/components/tabs.md +277 -0
- package/skills/eluan/components/textarea.md +202 -0
- package/skills/eluan/components/time-input.md +181 -0
- package/skills/eluan/components/toast.md +251 -0
- package/skills/eluan/components/toggle-group.md +241 -0
- package/skills/eluan/components/toggle.md +198 -0
- package/skills/eluan/components/tooltip.md +222 -0
- package/skills/eluan/components/tree-view.md +213 -0
- package/skills/eluan/components/typography.md +207 -0
- package/skills/eluan/components/visually-hidden.md +132 -0
- package/skills/eluan/foundations/colour.md +252 -0
- package/skills/eluan/foundations/elevation.md +57 -0
- package/skills/eluan/foundations/iconography.md +70 -0
- package/skills/eluan/foundations/motion.md +60 -0
- package/skills/eluan/foundations/radius.md +61 -0
- package/skills/eluan/foundations/spacing.md +98 -0
- package/skills/eluan/foundations/theming.md +197 -0
- package/skills/eluan/foundations/typography.md +163 -0
- package/skills/eluan/patterns/empty-states.md +84 -0
- package/skills/eluan/patterns/feedback.md +95 -0
- package/skills/eluan/patterns/forms.md +138 -0
- package/skills/eluan/patterns/navigation.md +95 -0
- package/skills/eluan/patterns/page-layout.md +101 -0
- package/dist/button-Ny6OF8Un.cjs +0 -1
- package/dist/decimal-input-BLmifKF2.cjs +0 -1
- package/dist/dialog-DWYtFhZl.cjs +0 -1
- package/dist/hover-card-BN7Ew2Y1.js +0 -16
- package/dist/hover-card-Dft-08Ha.cjs +0 -1
- package/dist/input-otp-DcZ7wyjs.cjs +0 -1
- package/dist/multi-select-DPoOHWSC.js +0 -74
- package/dist/multi-select-fX5FXYEY.cjs +0 -1
- package/dist/navigation-drawer-BbeDYPhu.js +0 -171
- package/dist/navigation-drawer-DOOHfbY3.cjs +0 -1
- package/dist/progress-DpQjGEyn.cjs +0 -1
- package/dist/select-1Eb3NSrR.cjs +0 -1
- package/dist/sheet-7NP1LuHy.cjs +0 -1
- package/dist/time-input-DR2snTgB.cjs +0 -1
- package/dist/tooltip-BlCQKhUE.js +0 -18
- package/dist/tooltip-Cyu7fWYZ.cjs +0 -1
- package/dist/tree-view-CNvEc1TT.cjs +0 -1
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Kbd
|
|
3
|
+
use_when: Show a keyboard key or shortcut as a keycap in help text, a tooltip, a shortcuts list or next to a trigger's label.
|
|
4
|
+
instead_of: CommandShortcut, DropdownMenuShortcut, ContextMenuShortcut or MenubarShortcut inside those menus' rows; CodeBlock for code; plain text like Ctrl-K.
|
|
5
|
+
source: packages/core/src/components/kbd.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Kbd
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Kbd renders a keyboard key as a keycap in a native `<kbd>` element. Pass `keys` and it maps key names to symbols ("cmd+k" becomes ⌘ + K). The module also exports `KbdGroup` for several keycaps side by side, `Shortcut` for sixteen common shortcuts with a macOS check, and the helpers `KEY_SYMBOLS` and `formatKey`.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A shortcuts list or help panel: "Save changes ⌘ + S".
|
|
17
|
+
- A hint next to the label of the control a shortcut triggers, such as Cmd+K on a command menu Button.
|
|
18
|
+
- A key named in instructions: "Press Esc to close".
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- A shortcut hint in a Command row → use `CommandShortcut` in [Command](./command.md).
|
|
23
|
+
- A shortcut hint in a menu item → use `DropdownMenuShortcut` in [DropdownMenu](./dropdown-menu.md), `ContextMenuShortcut` in [ContextMenu](./context-menu.md) or `MenubarShortcut` in [Menubar](./menubar.md).
|
|
24
|
+
- Code or a command to type → use [CodeBlock](./code-block.md).
|
|
25
|
+
- A status or count label → use [Badge](./badge.md).
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Keycap**: the `<kbd>` box, `--font-mono` at weight 500, `--curves-sm` corners, at least as wide as it is tall.
|
|
30
|
+
2. **Key labels**: one per key. Known names become symbols; anything else is uppercased.
|
|
31
|
+
3. **Plus signs**: between keys when `keys` holds more than one, in `--interactive-fg-disabled`.
|
|
32
|
+
|
|
33
|
+
`KbdGroup` is an inline row of separate keycaps with a `--spacing-xxs` gap and no plus signs.
|
|
34
|
+
|
|
35
|
+
## 4. Variants
|
|
36
|
+
|
|
37
|
+
| Variant | Use for |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `default` | A raised keycap (`--container-bg-alt` fill, `--container-border-alt` border and bottom edge, `--container-fg-alt` text). Shortcut lists and standalone hints. |
|
|
40
|
+
| `outline` | A flat keycap (`--container-bg` fill, `--container-border-alt` border, `--container-fg` text). Where the raised edge is too heavy, such as dense tables or tooltips. |
|
|
41
|
+
| `ghost` | Text only (no fill or border, `--container-fg-alt`). Inside buttons and running text. |
|
|
42
|
+
|
|
43
|
+
## 5. Sizes
|
|
44
|
+
|
|
45
|
+
| Size | Use in |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `sm` | Inside buttons and next to small text (`--size-xs` tall, `--font-size-xs`). |
|
|
48
|
+
| `default` | Body text and shortcut lists (`--size-sm`, `--font-size-sm`). |
|
|
49
|
+
| `lg` | Large instructional layouts, such as onboarding (`--size-md`, `--font-size-base`). |
|
|
50
|
+
|
|
51
|
+
## 6. States
|
|
52
|
+
|
|
53
|
+
| State | Looks like | Notes |
|
|
54
|
+
| --- | --- | --- |
|
|
55
|
+
| Default | Variant colours | Kbd isn't interactive: no hover, focus or disabled states. |
|
|
56
|
+
|
|
57
|
+
## 7. Content guidelines
|
|
58
|
+
|
|
59
|
+
- Name keys in `keys`, joined with `+` or as an array: `"cmd+k"`, `["shift", "enter"]`.
|
|
60
|
+
- Known names become symbols: cmd, command, meta and super → ⌘; ctrl and control → ⌃; alt, option and opt → ⌥; shift → ⇧; enter and return → ↵; tab → ⇥; esc and escape → ⎋; backspace → ⌫; delete and del → ⌦; space → ␣; up, down, left and right → arrows; win → ⊞. Any other key is uppercased.
|
|
61
|
+
- Write the word as children for keys whose symbol many people don't know: `<Kbd>Esc</Kbd>`, `<Kbd>Tab</Kbd>`.
|
|
62
|
+
- To show the plus key itself, use the array form: `keys={["cmd", "+"]}`. A string is split on `+`.
|
|
63
|
+
- Show the shortcut the app really binds, for the user's platform.
|
|
64
|
+
|
|
65
|
+
| Do | Don't |
|
|
66
|
+
| --- | --- |
|
|
67
|
+
| `keys="cmd+k"` | `<Kbd>Cmd-K</Kbd>` |
|
|
68
|
+
| `<Kbd>Esc</Kbd>` | `<Kbd>ESCAPE KEY</Kbd>` |
|
|
69
|
+
|
|
70
|
+
## 8. Rules
|
|
71
|
+
|
|
72
|
+
1. Use `keys` for a chord, keys pressed together: one keycap with plus signs. Use `KbdGroup` for a sequence, keys pressed one after another, such as G then I.
|
|
73
|
+
2. Use `Shortcut` for its sixteen named actions. Off macOS it swaps ⌘ for ⌃, the Control symbol, not the word "Ctrl"; where your audience expects the word, write it as children (`<Kbd>Ctrl</Kbd>`), because `keys` turns "ctrl" into ⌃ too.
|
|
74
|
+
3. When Kbd repeats a shortcut its control already announces, hide it from assistive tech: `aria-hidden="true"` on Kbd and `aria-keyshortcuts` on the control.
|
|
75
|
+
4. Put `KbdGroup` in a flex or block container, never inside a `<p>`: it renders a `div`. Kbd itself is inline and can sit in a sentence.
|
|
76
|
+
5. Use `variant` and `size`. `kbdVariants` is a no-op kept for compatibility.
|
|
77
|
+
6. Never pass `className` or `style`; they're omitted.
|
|
78
|
+
|
|
79
|
+
## 9. Dos and don'ts
|
|
80
|
+
|
|
81
|
+
**Do:** pass key names and let Kbd map them.
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
<Kbd keys={["cmd", "shift", "p"]} />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Don't:** type symbols and separators by hand.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
<Kbd>⌘ + ⇧ + P</Kbd>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Do:** hide the keycap on a control that exposes the shortcut.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<Button type="button" variant="outline" aria-keyshortcuts="Meta+K Control+K" onClick={openMenu}>
|
|
97
|
+
Search
|
|
98
|
+
<Kbd keys="cmd+k" size="sm" variant="ghost" aria-hidden="true" />
|
|
99
|
+
</Button>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Don't:** let the symbols become part of the button's name.
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<Button onClick={openMenu}>
|
|
106
|
+
Search <Kbd keys="cmd+k" />
|
|
107
|
+
</Button>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 10. Accessibility
|
|
111
|
+
|
|
112
|
+
- Role: native `<kbd>`, no ARIA role. `KbdGroup` is a plain `div`.
|
|
113
|
+
- Label: its text content. Screen readers read symbols such as ⌘ and ⇧ inconsistently, so where the shortcut matters, say it in words nearby or put `aria-keyshortcuts` on the control it triggers.
|
|
114
|
+
- Keyboard: not focusable; no interaction.
|
|
115
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
116
|
+
|
|
117
|
+
## 11. Behaviour
|
|
118
|
+
|
|
119
|
+
- Platform: `Shortcut` checks `navigator.platform` while rendering. On the server it assumes macOS, so on Windows and Linux the server HTML (⌘) and the client render (⌃) differ. In server-rendered apps, render `Shortcut` only after mount.
|
|
120
|
+
- Sizing: keycaps grow with their content and are never narrower than they are tall, so single keys stay square.
|
|
121
|
+
- Motion: none.
|
|
122
|
+
|
|
123
|
+
## 12. API
|
|
124
|
+
|
|
125
|
+
<!-- api:start -->
|
|
126
|
+
### Kbd
|
|
127
|
+
|
|
128
|
+
| Prop | Type | Default | Description |
|
|
129
|
+
| --- | --- | --- | --- |
|
|
130
|
+
| `keys` | `string \| string[]` | | Key names; a string is split on `+`. Replaces `children` when set. |
|
|
131
|
+
| `variant` | `"default" \| "outline" \| "ghost"` | `"default"` | Keycap style. |
|
|
132
|
+
| `size` | `"sm" \| "default" \| "lg"` | `"default"` | Height, font size and padding. |
|
|
133
|
+
| `children` | `ReactNode` | | Shown as written when `keys` isn't set. |
|
|
134
|
+
| `ref` | `Ref<HTMLElement>` | | Forwarded to the `<kbd>`. |
|
|
135
|
+
| `...props` | `HTMLAttributes<HTMLElement>` without `className`, `style` | | For example `aria-hidden`, `title`. |
|
|
136
|
+
|
|
137
|
+
### KbdGroup
|
|
138
|
+
|
|
139
|
+
| Prop | Type | Default | Description |
|
|
140
|
+
| --- | --- | --- | --- |
|
|
141
|
+
| `...props` | `HTMLAttributes<HTMLDivElement>` without `className`, `style` | | Kbd children. |
|
|
142
|
+
|
|
143
|
+
### Shortcut
|
|
144
|
+
|
|
145
|
+
| Prop | Type | Default | Description |
|
|
146
|
+
| --- | --- | --- | --- |
|
|
147
|
+
| `shortcut` | `"copy" \| "paste" \| "cut" \| "undo" \| "redo" \| "save" \| "selectAll" \| "find" \| "new" \| "open" \| "close" \| "refresh" \| "print" \| "bold" \| "italic" \| "underline"` | | The action. Each is ⌘ plus a letter; `redo` adds ⇧. |
|
|
148
|
+
| `forceCtrl` | `boolean` | `false` | Shows ⌃ instead of ⌘ on macOS too. |
|
|
149
|
+
| `variant`, `size` | as Kbd | | |
|
|
150
|
+
| `...props` | Kbd props without `keys` | | |
|
|
151
|
+
|
|
152
|
+
### Helpers
|
|
153
|
+
|
|
154
|
+
| Prop | Type | Default | Description |
|
|
155
|
+
| --- | --- | --- | --- |
|
|
156
|
+
| `KEY_SYMBOLS` | `Record<string, string>` | | Map from lowercase key name to symbol. |
|
|
157
|
+
| `formatKey` | `(key: string) => string` | | The symbol for a known name, otherwise the key uppercased. |
|
|
158
|
+
| `kbdVariants` | `() => string` | | Returns `""`. Kept for compatibility. |
|
|
159
|
+
<!-- api:end -->
|
|
160
|
+
|
|
161
|
+
## 13. Examples
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { Kbd, KbdGroup, Shortcut, Typography } from "@eluan/core";
|
|
165
|
+
|
|
166
|
+
const row = { display: "contents" } as const;
|
|
167
|
+
|
|
168
|
+
export function ShortcutList() {
|
|
169
|
+
return (
|
|
170
|
+
<dl
|
|
171
|
+
style={{
|
|
172
|
+
display: "grid",
|
|
173
|
+
gridTemplateColumns: "1fr auto",
|
|
174
|
+
alignItems: "center",
|
|
175
|
+
columnGap: "var(--spacing-xl)",
|
|
176
|
+
rowGap: "var(--spacing-sm)",
|
|
177
|
+
margin: 0,
|
|
178
|
+
}}
|
|
179
|
+
>
|
|
180
|
+
<div style={row}>
|
|
181
|
+
<dt><Typography variant="body" as="span">Open the command menu</Typography></dt>
|
|
182
|
+
<dd style={{ margin: 0 }}><Kbd keys="cmd+k" /></dd>
|
|
183
|
+
</div>
|
|
184
|
+
<div style={row}>
|
|
185
|
+
<dt><Typography variant="body" as="span">Save changes</Typography></dt>
|
|
186
|
+
<dd style={{ margin: 0 }}><Shortcut shortcut="save" /></dd>
|
|
187
|
+
</div>
|
|
188
|
+
<div style={row}>
|
|
189
|
+
<dt><Typography variant="body" as="span">Go to inbox</Typography></dt>
|
|
190
|
+
<dd style={{ margin: 0 }}>
|
|
191
|
+
<KbdGroup>
|
|
192
|
+
<Kbd keys="g" />
|
|
193
|
+
<Kbd keys="i" />
|
|
194
|
+
</KbdGroup>
|
|
195
|
+
</dd>
|
|
196
|
+
</div>
|
|
197
|
+
<div style={row}>
|
|
198
|
+
<dt><Typography variant="body" as="span">Close the panel</Typography></dt>
|
|
199
|
+
<dd style={{ margin: 0 }}><Kbd>Esc</Kbd></dd>
|
|
200
|
+
</div>
|
|
201
|
+
</dl>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 14. Related components
|
|
207
|
+
|
|
208
|
+
- [Command](./command.md): uses `CommandShortcut` for hints inside rows; Kbd goes on its trigger.
|
|
209
|
+
- [Tooltip](./tooltip.md): a common place to show a control's shortcut.
|
|
210
|
+
- [Button](./button.md): a trigger can carry a Kbd hint after its label.
|
|
211
|
+
- [CodeBlock](./code-block.md): for code, not keys.
|
|
212
|
+
- [Typography](./typography.md): the text around a keycap.
|
|
213
|
+
|
|
214
|
+
## 15. Common agent mistakes
|
|
215
|
+
|
|
216
|
+
_Filled from evals._
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Media
|
|
3
|
+
use_when: You show a content image or a video and want a ratio preset, token-rounded corners, a loading state or simple playback controls.
|
|
4
|
+
instead_of: Avatar for profile pictures; AspectRatio for embeds and custom ratios; Carousel for a slideshow; Skeleton before you have a source.
|
|
5
|
+
source: packages/core/src/components/media.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Media
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
The media module ships two components, `Image` and `Video`. There is no `Media` export: import `Image` and `Video` from `"@eluan/core"`. Both render a clipped frame with a ratio preset and a `--curves-*` radius, and fill their container's width. Image adds a loading spinner and an optional fallback for failed loads. Video adds an overlay with play/pause, mute and fullscreen buttons.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Content images: article and case-study images, product shots, screenshots, card thumbnails.
|
|
17
|
+
- Images that should crop to one shape across a grid (`ratio="square"` or `"video"`).
|
|
18
|
+
- A product demo or tutorial video that needs simple playback controls.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Profile pictures or initials → use [Avatar](./avatar.md).
|
|
23
|
+
- Icons → use `lucide-react`; see [iconography](../foundations/iconography.md).
|
|
24
|
+
- A map, iframe embed, or a ratio outside the presets → use [AspectRatio](./aspect-ratio.md).
|
|
25
|
+
- Several images to step through → use [Carousel](./carousel.md).
|
|
26
|
+
- A placeholder before you have a source → use [Skeleton](./skeleton.md).
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
**Image**
|
|
31
|
+
|
|
32
|
+
1. **Frame**: a `<div>` that clips its content and applies `ratio` and `rounded`.
|
|
33
|
+
2. **Loading overlay**: covers the frame in `--container-bg-alt` with a spinning icon until the image loads. It's a `role="status"` element labelled "Loading image".
|
|
34
|
+
3. **Image element**: the native `<img>`. It fills the frame with `object-fit: cover`. `ref` points here.
|
|
35
|
+
4. **Fallback** (optional): your node, centred on `--container-bg-alt`, shown in place of the image when it fails to load.
|
|
36
|
+
|
|
37
|
+
**Video**
|
|
38
|
+
|
|
39
|
+
1. **Frame**: the same clipping frame, `ratio="video"` (16:9) by default.
|
|
40
|
+
2. **Video element**: the native `<video>`, filling the frame with `object-fit: cover`. `ref` points here; children (`<source>`, `<track>`) render inside it.
|
|
41
|
+
3. **Controls overlay** (when `showControls`): a dark gradient along the bottom holding a progress bar (display only) and a row of buttons: Play/Pause, Mute/Unmute and, at the far end, Toggle fullscreen.
|
|
42
|
+
|
|
43
|
+
## 4. Variants
|
|
44
|
+
|
|
45
|
+
Media has no `variant` prop. `ratio` and `rounded` set the look.
|
|
46
|
+
|
|
47
|
+
| `ratio` | Use for |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| `auto` | Image's default. The frame follows the image's own proportions, so nothing is cropped. Use for charts and screenshots with text. |
|
|
50
|
+
| `square` | 1:1. Thumbnail grids and product tiles. |
|
|
51
|
+
| `video` | 16:9. Video's default; hero images and wide screenshots. |
|
|
52
|
+
| `portrait` | 3:4. Photos of people, posters, covers. |
|
|
53
|
+
| `wide` | 21:9. Banners. |
|
|
54
|
+
|
|
55
|
+
| `rounded` | Radius |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `none` | Square corners. |
|
|
58
|
+
| `sm` | `--curves-sm` |
|
|
59
|
+
| `md` | `--curves-md` (default) |
|
|
60
|
+
| `lg` | `--curves-lg` |
|
|
61
|
+
| `xl` | `--curves-xl` |
|
|
62
|
+
| `full` | `--radius-radius-full`: a circle with `ratio="square"`, a pill otherwise. |
|
|
63
|
+
|
|
64
|
+
## 5. Sizes
|
|
65
|
+
|
|
66
|
+
Media has no size prop. Image and Video fill their container's width; height comes from `ratio` (or from the image itself with `auto`). Constrain width with a wrapper you own. The `width` and `height` attributes don't change the rendered size, because the media element is styled to fill its frame.
|
|
67
|
+
|
|
68
|
+
## 6. States
|
|
69
|
+
|
|
70
|
+
| State | Looks like | Notes |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| Loading (Image) | Frame filled with `--container-bg-alt` and a spinning icon | Clears on the image's `load` event. |
|
|
73
|
+
| Loaded (Image) | The image, cropped to the frame by `object-fit: cover` | |
|
|
74
|
+
| Error, with `fallback` (Image) | Your fallback, centred on `--container-bg-alt`, in the same frame | |
|
|
75
|
+
| Error, no `fallback` (Image) | The loading spinner never clears | Always pass `fallback`. |
|
|
76
|
+
| Controls hidden (Video) | Overlay at zero opacity | Shows while the pointer is over the frame or focus is inside it. |
|
|
77
|
+
| Hover (Video buttons) | Translucent white circle behind the icon | |
|
|
78
|
+
| Focus (Video buttons) | 1px ring in `--container-fg-inverse` | Never remove or restyle the focus ring. |
|
|
79
|
+
| Playing / paused (Video) | Pause or Play icon; the label switches to match | |
|
|
80
|
+
| Muted (Video) | Crossed-out speaker icon, label "Unmute" | Starts as "Mute" even when you pass `muted`. |
|
|
81
|
+
|
|
82
|
+
## 7. Content guidelines
|
|
83
|
+
|
|
84
|
+
- Write alt text that says what the image shows and why it's there, in one sentence.
|
|
85
|
+
- Don't start with "Image of" or "Photo of", and never use the file name.
|
|
86
|
+
- Use `alt=""` for decorative images and for images the adjacent text already describes.
|
|
87
|
+
- Keep fallback text short and plain: "Image unavailable".
|
|
88
|
+
- Give any video with speech a captions track (`<track kind="captions">`) and a `poster` frame.
|
|
89
|
+
|
|
90
|
+
| Do | Don't |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| Weekly revenue chart, up 12% since June | Chart |
|
|
93
|
+
| Priya Raman presenting the Q3 roadmap | IMG_2041.jpg |
|
|
94
|
+
| `alt=""` on a background texture | Decorative swirly pattern image |
|
|
95
|
+
|
|
96
|
+
## 8. Rules
|
|
97
|
+
|
|
98
|
+
1. Always pass `alt` to Image. The types make it optional and nothing enforces it.
|
|
99
|
+
2. Always pass `fallback` to Image; without it a failed load shows a spinner forever.
|
|
100
|
+
3. Use `ratio="auto"` when the whole image must stay visible. Every other preset crops with `object-fit: cover`.
|
|
101
|
+
4. Size Image and Video with a wrapper you own. They drop `className` and `style`.
|
|
102
|
+
5. Nest radii: inside a Card (`--curves-lg`) use `rounded="md"` or smaller.
|
|
103
|
+
6. Don't pass the native `controls` attribute while `showControls` is on; you'd get two sets of controls. Pick one.
|
|
104
|
+
7. If a Video autoplays and loops, keep a pause control: leave `showControls` on. See [motion](../foundations/motion.md).
|
|
105
|
+
8. `Image` shadows the browser's global `Image` constructor and clashes with framework image components. Alias it when that matters: `import { Image as MediaImage } from "@eluan/core"`.
|
|
106
|
+
9. Don't call `mediaVariants`. It always returns an empty string.
|
|
107
|
+
|
|
108
|
+
## 9. Dos and don'ts
|
|
109
|
+
|
|
110
|
+
**Do:** pass alt text, a fallback and a ratio.
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<Image
|
|
114
|
+
src="/screens/orders-dashboard.png"
|
|
115
|
+
alt="Orders dashboard showing 12 open orders and one late shipment"
|
|
116
|
+
ratio="video"
|
|
117
|
+
fallback={<Typography variant="caption" tone="muted">Image unavailable</Typography>}
|
|
118
|
+
/>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Don't:** leave out alt text, rely on the spinner, or style the component.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
<Image src="/screens/orders-dashboard.png" style={{ borderRadius: 12, height: 240 }} />
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Do:** give a video captions and a poster, and keep Video's controls.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<Video src="/media/onboarding-tour.mp4" poster="/media/onboarding-tour.jpg" preload="metadata">
|
|
131
|
+
<track kind="captions" src="/media/onboarding-tour.en.vtt" srcLang="en" label="English" default />
|
|
132
|
+
</Video>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Don't:** stack native controls on top, or loop motion with no way to pause it.
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
<Video src="/media/onboarding-tour.mp4" controls />
|
|
139
|
+
<Video src="/media/hero-loop.mp4" autoPlay muted loop showControls={false} />
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 10. Accessibility
|
|
143
|
+
|
|
144
|
+
- Role: Image renders a native `<img>` (role `img`; `alt=""` makes it presentational). Its loading overlay is `role="status"`, labelled "Loading image". Video renders a native `<video>`; its controls are native `<button type="button">` elements.
|
|
145
|
+
- Label: Image gets its name from `alt`. Video's buttons have built-in English labels: "Play" or "Pause", "Mute" or "Unmute", and "Toggle fullscreen". Name the video itself with a visible heading or caption nearby.
|
|
146
|
+
- Keyboard: Tab reaches the three control buttons, even while the overlay is hidden; focusing one shows the overlay. Enter and Space activate. There are no seek or volume keys, and the progress bar is display-only.
|
|
147
|
+
- Focus: focus inside the frame shows the controls; nothing is trapped.
|
|
148
|
+
- Captions: Video has no captions button. A `<track kind="captions" default>` child shows captions through the browser.
|
|
149
|
+
- Contrast: handled by the theme. Don't override colours. Video's icons, progress fill and focus ring use `--container-fg-inverse` over a fixed dark gradient; in dark mode that token is dark, so the controls nearly disappear. Where dark mode matters, use `showControls={false}` with the native `controls` attribute.
|
|
150
|
+
|
|
151
|
+
## 11. Behaviour
|
|
152
|
+
|
|
153
|
+
- Responsive: both fill their container's width. Ratio presets keep their shape at any width; `auto` follows the image.
|
|
154
|
+
- Overflow and truncation: presets crop the image's edges (`object-fit: cover`). There's no setting for `contain`; use `ratio="auto"` instead.
|
|
155
|
+
- Motion: Image's spinner turns once a second and stops under reduced motion. Video's overlay fades over 150ms, and the progress bar eases its width. Don't add your own.
|
|
156
|
+
- Fullscreen: the fullscreen button toggles the browser's fullscreen mode on the `<video>` element.
|
|
157
|
+
- Native attributes pass through: `loading="lazy"`, `srcSet` and `sizes` on Image; `autoPlay`, `muted`, `loop`, `playsInline` and `preload` on Video.
|
|
158
|
+
|
|
159
|
+
## 12. API
|
|
160
|
+
|
|
161
|
+
<!-- api:start -->
|
|
162
|
+
### Image
|
|
163
|
+
|
|
164
|
+
| Prop | Type | Default | Description |
|
|
165
|
+
| --- | --- | --- | --- |
|
|
166
|
+
| `src` | `string` | | Image URL. |
|
|
167
|
+
| `alt` | `string` | | Accessible name. Optional in the types; always pass it (`""` for decorative). |
|
|
168
|
+
| `ratio` | `"auto" \| "square" \| "video" \| "portrait" \| "wide" \| null` | `"auto"` | Frame aspect ratio. Presets crop with `object-fit: cover`. |
|
|
169
|
+
| `rounded` | `"none" \| "sm" \| "md" \| "lg" \| "xl" \| "full" \| null` | `"md"` | Corner radius from `--curves-*`. |
|
|
170
|
+
| `fallback` | `ReactNode` | | Shown in place of the image when it fails to load. |
|
|
171
|
+
| `onLoad` | `ReactEventHandler<HTMLImageElement>` | | Called when the image loads; Image also clears its loading overlay. |
|
|
172
|
+
| `onError` | `ReactEventHandler<HTMLImageElement>` | | Called when the image fails; Image also switches to `fallback` if you passed one. |
|
|
173
|
+
| `...props` | `ImgHTMLAttributes` without `className`, `style` | | Native img attributes: `loading`, `decoding`, `srcSet`, `sizes`. `ref` points to the `<img>`. |
|
|
174
|
+
|
|
175
|
+
### Video
|
|
176
|
+
|
|
177
|
+
| Prop | Type | Default | Description |
|
|
178
|
+
| --- | --- | --- | --- |
|
|
179
|
+
| `src` | `string` | | Video URL, or use `<source>` children. |
|
|
180
|
+
| `ratio` | `"auto" \| "square" \| "video" \| "portrait" \| "wide" \| null` | `"video"` | Frame aspect ratio. |
|
|
181
|
+
| `rounded` | `"none" \| "sm" \| "md" \| "lg" \| "xl" \| "full" \| null` | `"md"` | Corner radius from `--curves-*`. |
|
|
182
|
+
| `showControls` | `boolean` | `true` | Shows the play/pause, mute and fullscreen overlay. |
|
|
183
|
+
| `poster` | `string` | | Frame shown before playback. |
|
|
184
|
+
| `children` | `ReactNode` | | `<source>` and `<track>` elements. |
|
|
185
|
+
| `onPlay`, `onPause`, `onTimeUpdate` | `ReactEventHandler<HTMLVideoElement>` | | Your handlers; Video also updates its own play state and progress bar. |
|
|
186
|
+
| `...props` | `VideoHTMLAttributes` without `className`, `style` | | Native video attributes: `autoPlay`, `muted`, `loop`, `playsInline`, `preload`. `ref` points to the `<video>`. |
|
|
187
|
+
|
|
188
|
+
### mediaVariants
|
|
189
|
+
|
|
190
|
+
| Prop | Type | Default | Description |
|
|
191
|
+
| --- | --- | --- | --- |
|
|
192
|
+
| `mediaVariants(options?)` | `(options?: { ratio?, rounded? }) => string` | | Always returns `""`. Kept for compatibility; don't use it. |
|
|
193
|
+
<!-- api:end -->
|
|
194
|
+
|
|
195
|
+
## 13. Examples
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { Image, Typography, Video } from "@eluan/core";
|
|
199
|
+
|
|
200
|
+
export function CaseStudyMedia() {
|
|
201
|
+
return (
|
|
202
|
+
<article style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-2xl)" }}>
|
|
203
|
+
<figure style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)", margin: 0 }}>
|
|
204
|
+
<Image
|
|
205
|
+
src="/case-studies/northwind/dock-board.jpg"
|
|
206
|
+
alt="Dock board grouping today's 38 outbound orders by loading bay"
|
|
207
|
+
ratio="video"
|
|
208
|
+
rounded="lg"
|
|
209
|
+
loading="lazy"
|
|
210
|
+
fallback={<Typography variant="caption" tone="muted">Image unavailable</Typography>}
|
|
211
|
+
/>
|
|
212
|
+
<Typography as="figcaption" variant="caption" tone="muted">
|
|
213
|
+
Northwind's dock board after the redesign.
|
|
214
|
+
</Typography>
|
|
215
|
+
</figure>
|
|
216
|
+
|
|
217
|
+
<section style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
218
|
+
<Typography variant="subheading" as="h2">Two-minute walkthrough</Typography>
|
|
219
|
+
<Video
|
|
220
|
+
src="/case-studies/northwind/walkthrough.mp4"
|
|
221
|
+
poster="/case-studies/northwind/walkthrough.jpg"
|
|
222
|
+
preload="metadata"
|
|
223
|
+
rounded="lg"
|
|
224
|
+
>
|
|
225
|
+
<track kind="captions" src="/case-studies/northwind/walkthrough.en.vtt" srcLang="en" label="English" default />
|
|
226
|
+
</Video>
|
|
227
|
+
</section>
|
|
228
|
+
</article>
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## 14. Related components
|
|
234
|
+
|
|
235
|
+
- [AspectRatio](./aspect-ratio.md): locks any content you own, including iframes, to a custom ratio.
|
|
236
|
+
- [Avatar](./avatar.md): profile pictures, with `AvatarFallback` for initials.
|
|
237
|
+
- [Card](./card.md): pairs a thumbnail with text.
|
|
238
|
+
- [Carousel](./carousel.md): a row of slides.
|
|
239
|
+
- [Skeleton](./skeleton.md): a placeholder while you fetch the source.
|
|
240
|
+
- [Spinner](./spinner.md): the loading indicator for other content.
|
|
241
|
+
|
|
242
|
+
## 15. Common agent mistakes
|
|
243
|
+
|
|
244
|
+
_Filled from evals._
|