@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,232 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: RadioGroup
|
|
3
|
+
use_when: The user picks exactly one option from a short list that should stay visible, such as a plan, density or delivery speed.
|
|
4
|
+
instead_of: Select for long lists or tight space; CheckboxGroup when several options can be chosen; SegmentedControl or Tabs to switch between views.
|
|
5
|
+
source: packages/core/src/components/radio-group.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# RadioGroup
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
RadioGroup is a set of mutually exclusive options built on Radix RadioGroup. RadioGroup renders the `role="radiogroup"` container and each RadioGroupItem renders a round `<button role="radio">` with a dot. Items have no label of their own: pair each one with a Label.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- One choice from a few options the user should compare at a glance: Default, Comfortable, Compact.
|
|
17
|
+
- Options that each need a short description.
|
|
18
|
+
- A short set of options on one line, such as sizes Small, Medium, Large, with `orientation="horizontal"`.
|
|
19
|
+
|
|
20
|
+
### When not to use
|
|
21
|
+
|
|
22
|
+
- Many options, or not enough room to show them all → use [Select](./select.md).
|
|
23
|
+
- Several options can be chosen → use [CheckboxGroup](./checkbox-group.md).
|
|
24
|
+
- A single on/off choice → use [Switch](./switch.md) or [Checkbox](./checkbox.md).
|
|
25
|
+
- Switching what's shown on the page → use [SegmentedControl](./segmented-control.md) or [Tabs](./tabs.md).
|
|
26
|
+
|
|
27
|
+
## 3. Anatomy
|
|
28
|
+
|
|
29
|
+
1. **Group**: RadioGroup, a `<div role="radiogroup">`. A grid with a `--spacing-sm` gap, or a wrapping row with a `--spacing-lg` gap when `orientation="horizontal"`.
|
|
30
|
+
2. **Item**: RadioGroupItem, a round `--size-xxs` `<button role="radio">` with a 1px `--interactive-border-alt` border.
|
|
31
|
+
3. **Dot**: always mounted and faded in when checked. Half the ring's size, in `--interactive-bg` on the `--interactive-bg-selected` fill.
|
|
32
|
+
4. **Row** (yours): a flex row with a `--spacing-sm` gap holding the item and its Label. With a description, align to the top and wrap the Label in a box with a `--size-xxs` minimum height so it stays centred on the radio.
|
|
33
|
+
5. **Label** (yours): a Label with `htmlFor` matching the item's `id`, plus an optional description under it.
|
|
34
|
+
|
|
35
|
+
## 4. Variants
|
|
36
|
+
|
|
37
|
+
RadioGroup has no variants. `orientation` sets the layout and the arrow keys:
|
|
38
|
+
|
|
39
|
+
| Orientation | Use for |
|
|
40
|
+
| --- | --- |
|
|
41
|
+
| unset or `vertical` | Most lists, and any list with descriptions. |
|
|
42
|
+
| `horizontal` | A few short options that fit on one line. |
|
|
43
|
+
|
|
44
|
+
## 5. Sizes
|
|
45
|
+
|
|
46
|
+
RadioGroup has no `size` prop. Items are `--size-xxs` and follow density.
|
|
47
|
+
|
|
48
|
+
## 6. States
|
|
49
|
+
|
|
50
|
+
| State | Looks like | Notes |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| Unchecked | Transparent circle, `--interactive-border-alt` border | |
|
|
53
|
+
| Hover | `--interactive-bg-hover` fill | |
|
|
54
|
+
| Focus | 1px outline in `--focus-ring`, 1px offset, on keyboard focus only | Never remove or restyle the focus ring. |
|
|
55
|
+
| Checked | `--interactive-bg-selected` fill and border, `--interactive-bg` dot | |
|
|
56
|
+
| Disabled | `--interactive-bg-disabled` fill, not-allowed cursor | `disabled` on RadioGroup disables every item; on an item, only that one. Disable its Label too. |
|
|
57
|
+
| Checked and disabled | Reads as empty: the fill turns pale and the light dot disappears into it | Don't rely on it to show a fixed choice; say it in the label or show the value as text. |
|
|
58
|
+
| Error | No error style | Show a FormMessage under the group and point the RadioGroup's `aria-describedby` at it. |
|
|
59
|
+
|
|
60
|
+
## 7. Content guidelines
|
|
61
|
+
|
|
62
|
+
- Name the group with a visible heading that asks or states the choice: "Delivery speed", "Interface density".
|
|
63
|
+
- Label each option with a short, parallel phrase: "Default", "Comfortable", "Compact".
|
|
64
|
+
- Use a description for one short sentence on the difference: "More spacing for readability."
|
|
65
|
+
- Order options logically (by size, speed or price) and preselect a sensible default when one exists.
|
|
66
|
+
|
|
67
|
+
| Do | Don't |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| Standard · Express · Overnight | Standard · Faster option · OVERNIGHT!! |
|
|
70
|
+
| More spacing for readability. | This option gives you more spacing, which some people find easier to read. |
|
|
71
|
+
|
|
72
|
+
## 8. Rules
|
|
73
|
+
|
|
74
|
+
1. Put every RadioGroupItem inside a RadioGroup.
|
|
75
|
+
2. Give each item an `id` and a Label with a matching `htmlFor`, or an `aria-label`.
|
|
76
|
+
3. Name the group with `aria-labelledby` pointing at a visible heading, or `aria-label`.
|
|
77
|
+
4. Read changes with `onValueChange`, which receives the selected `value` string. Control it with `value`, or leave it uncontrolled with `defaultValue`.
|
|
78
|
+
5. Use `orientation="horizontal"` for a row instead of your own flex wrapper. The layout keys off it, and it limits arrow keys to Left and Right.
|
|
79
|
+
6. Give every item a unique `value`, and set `name` on RadioGroup when the form submits natively.
|
|
80
|
+
7. Never pass `className` or `style`; they're dropped.
|
|
81
|
+
|
|
82
|
+
## 9. Dos and don'ts
|
|
83
|
+
|
|
84
|
+
**Do:** pair each item with a Label in a row.
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<RadioGroup aria-labelledby="density-heading" defaultValue="comfortable">
|
|
88
|
+
<div style={{ display: "flex", alignItems: "center", gap: "var(--spacing-sm)" }}>
|
|
89
|
+
<RadioGroupItem id="density-default" value="default" />
|
|
90
|
+
<Label htmlFor="density-default">Default</Label>
|
|
91
|
+
</div>
|
|
92
|
+
<div style={{ display: "flex", alignItems: "center", gap: "var(--spacing-sm)" }}>
|
|
93
|
+
<RadioGroupItem id="density-comfortable" value="comfortable" />
|
|
94
|
+
<Label htmlFor="density-comfortable">Comfortable</Label>
|
|
95
|
+
</div>
|
|
96
|
+
</RadioGroup>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Don't:** leave items unlabelled or the group unnamed.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
<RadioGroup>
|
|
103
|
+
<RadioGroupItem value="default" /> Default
|
|
104
|
+
<RadioGroupItem value="comfortable" /> Comfortable
|
|
105
|
+
</RadioGroup>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Do:** set the orientation on the group.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<RadioGroup aria-label="Size" orientation="horizontal" defaultValue="medium">
|
|
112
|
+
{/* rows */}
|
|
113
|
+
</RadioGroup>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Don't:** wrap the group in your own row layout.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<div style={{ display: "flex", gap: 24 }}>
|
|
120
|
+
<RadioGroup aria-label="Size">{/* rows */}</RadioGroup>
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## 10. Accessibility
|
|
125
|
+
|
|
126
|
+
- Role: `radiogroup` on RadioGroup (with `aria-orientation` when set) and `radio` with `aria-checked` on each item.
|
|
127
|
+
- Label: each item through a Label with `htmlFor`, or `aria-label`; the group through `aria-labelledby` or `aria-label`.
|
|
128
|
+
- Keyboard: Tab moves into the group, onto the checked item (or the first), and Tab again leaves it. Arrow keys move focus and select, wrapping at the ends; with `orientation` set, only that axis's arrows work. Space selects the focused item. Enter does nothing.
|
|
129
|
+
- Focus: visible outline on `:focus-visible` only. Disabled items use the native `disabled` attribute and are skipped.
|
|
130
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
131
|
+
|
|
132
|
+
## 11. Behaviour
|
|
133
|
+
|
|
134
|
+
- Responsive: the vertical layout stacks rows; the horizontal layout wraps them when they don't fit.
|
|
135
|
+
- Overflow and truncation: labels and descriptions wrap. Items don't shrink.
|
|
136
|
+
- Motion: colours change and the dot fades over 150ms. Don't add your own.
|
|
137
|
+
- Forms: inside a `<form>`, Radix adds hidden native radio inputs so the selected `value` submits under `name`.
|
|
138
|
+
|
|
139
|
+
## 12. API
|
|
140
|
+
|
|
141
|
+
<!-- api:start -->
|
|
142
|
+
### RadioGroup
|
|
143
|
+
|
|
144
|
+
| Prop | Type | Default | Description |
|
|
145
|
+
| --- | --- | --- | --- |
|
|
146
|
+
| `value` | `string` | | Controlled selection. Pair with `onValueChange`. |
|
|
147
|
+
| `defaultValue` | `string` | | Uncontrolled starting selection. |
|
|
148
|
+
| `onValueChange` | `(value: string) => void` | | Called with the newly selected value. |
|
|
149
|
+
| `disabled` | `boolean` | `false` | Disables every item. |
|
|
150
|
+
| `orientation` | `"horizontal" \| "vertical"` | unset (vertical layout, all arrow keys) | Layout and arrow-key axis. |
|
|
151
|
+
| `name` | `string` | | Field name for form submission. |
|
|
152
|
+
| `required` | `boolean` | `false` | Marks the group required. |
|
|
153
|
+
| `loop` | `boolean` | `true` | Arrow keys wrap from last to first. |
|
|
154
|
+
| `...props` | Radix `RadioGroup.Root` props without `className`, `style` | | `aria-labelledby`, `aria-label`, `aria-describedby`, `dir`, `id`. `ref` goes to the group `<div>`. |
|
|
155
|
+
|
|
156
|
+
### RadioGroupItem
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
| --- | --- | --- | --- |
|
|
160
|
+
| `value` | `string` | required | The value this item selects. |
|
|
161
|
+
| `id` | `string` | | Match it with the Label's `htmlFor`. |
|
|
162
|
+
| `disabled` | `boolean` | `false` | Disables this item. |
|
|
163
|
+
| `...props` | Radix `RadioGroup.Item` props without `className`, `style` | | `aria-label`, `aria-describedby`. `ref` goes to the `<button>`. |
|
|
164
|
+
<!-- api:end -->
|
|
165
|
+
|
|
166
|
+
## 13. Examples
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import { Label, RadioGroup, RadioGroupItem, Typography } from "@eluan/core";
|
|
170
|
+
import * as React from "react";
|
|
171
|
+
|
|
172
|
+
const options = [
|
|
173
|
+
{ value: "standard", label: "Standard", description: "Arrives in 3 to 5 working days. Free." },
|
|
174
|
+
{ value: "express", label: "Express", description: "Arrives in 1 to 2 working days. $9.00." },
|
|
175
|
+
{ value: "overnight", label: "Overnight", description: "Arrives the next working day. $24.00." },
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
const row = { display: "flex", alignItems: "flex-start", gap: "var(--spacing-sm)" } as const;
|
|
179
|
+
const copy = { display: "flex", flexDirection: "column", gap: "var(--spacing-xxs)" } as const;
|
|
180
|
+
const labelLine = { display: "flex", alignItems: "center", minHeight: "var(--size-xxs)" } as const;
|
|
181
|
+
|
|
182
|
+
export function DeliverySpeed({ onChange }: { onChange: (speed: string) => void }) {
|
|
183
|
+
const [speed, setSpeed] = React.useState("standard");
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-md)" }}>
|
|
187
|
+
<Typography id="delivery-heading" variant="label" weight="medium">
|
|
188
|
+
Delivery speed
|
|
189
|
+
</Typography>
|
|
190
|
+
<RadioGroup
|
|
191
|
+
aria-labelledby="delivery-heading"
|
|
192
|
+
name="deliverySpeed"
|
|
193
|
+
value={speed}
|
|
194
|
+
onValueChange={(next) => {
|
|
195
|
+
setSpeed(next);
|
|
196
|
+
onChange(next);
|
|
197
|
+
}}
|
|
198
|
+
>
|
|
199
|
+
{options.map((option) => (
|
|
200
|
+
<div key={option.value} style={row}>
|
|
201
|
+
<RadioGroupItem
|
|
202
|
+
id={`delivery-${option.value}`}
|
|
203
|
+
value={option.value}
|
|
204
|
+
aria-describedby={`delivery-${option.value}-description`}
|
|
205
|
+
/>
|
|
206
|
+
<div style={copy}>
|
|
207
|
+
<span style={labelLine}>
|
|
208
|
+
<Label htmlFor={`delivery-${option.value}`}>{option.label}</Label>
|
|
209
|
+
</span>
|
|
210
|
+
<Typography id={`delivery-${option.value}-description`} variant="caption" tone="muted">
|
|
211
|
+
{option.description}
|
|
212
|
+
</Typography>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
))}
|
|
216
|
+
</RadioGroup>
|
|
217
|
+
</div>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 14. Related components
|
|
223
|
+
|
|
224
|
+
- [CheckboxGroup](./checkbox-group.md): the multiple-choice equivalent.
|
|
225
|
+
- [Select](./select.md): one choice from a longer list, in less space.
|
|
226
|
+
- [SegmentedControl](./segmented-control.md): one choice that switches a view.
|
|
227
|
+
- [Label](./form-label.md): the Label for each item.
|
|
228
|
+
- See [../patterns/forms.md](../patterns/forms.md) for choosing between option controls.
|
|
229
|
+
|
|
230
|
+
## 15. Common agent mistakes
|
|
231
|
+
|
|
232
|
+
_Filled from evals._
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: RichText
|
|
3
|
+
use_when: The user writes formatted long-form content (headings, lists, emphasis) that you store as HTML.
|
|
4
|
+
instead_of: Textarea for plain multi-line text; Input for a single line; CodeBlock for showing code.
|
|
5
|
+
source: packages/core/src/components/rich-text.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# RichText
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
RichText is a WYSIWYG editor built on TipTap, with a fixed toolbar: bold, italic, strikethrough, inline code, headings 1 to 3, bulleted and numbered lists, quote, horizontal rule, undo and redo. It emits the document as an HTML string. RichTextToolbar is the same toolbar on its own, for a TipTap editor you create yourself.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- Formatted content the user writes and you store as HTML: project descriptions, release notes, announcements, knowledge-base articles.
|
|
17
|
+
- Comments or notes where headings, lists or emphasis matter.
|
|
18
|
+
|
|
19
|
+
### When not to use
|
|
20
|
+
|
|
21
|
+
- Plain multi-line text → use [Textarea](./textarea.md).
|
|
22
|
+
- A single line of text → use [Input](./input.md).
|
|
23
|
+
- Showing code → use [CodeBlock](./code-block.md).
|
|
24
|
+
- Showing stored rich content read-only → render the sanitised HTML in your own element, with [Typography](./typography.md) around it. A disabled RichText still renders the toolbar.
|
|
25
|
+
|
|
26
|
+
RichText earns its place only when users need formatting and you want HTML out. It isn't built on Input and doesn't submit with a native form.
|
|
27
|
+
|
|
28
|
+
## 3. Anatomy
|
|
29
|
+
|
|
30
|
+
1. **Container**: `--interactive-bg` surface with an `--interactive-border-alt` border and `--curves-md` corners.
|
|
31
|
+
2. **Toolbar**: on `--container-bg-alt` with a bottom border; [Toggle](./toggle.md) buttons (`size="iconSm"`) in four groups split by toolbar [Separators](./separator.md): text marks, headings, blocks, history.
|
|
32
|
+
3. **Editing area**: the TipTap content region; its minimum height comes from `minHeight`.
|
|
33
|
+
4. **Placeholder**: `placeholder` text in `--interactive-fg-alt` while the document is empty.
|
|
34
|
+
|
|
35
|
+
## 4. Variants
|
|
36
|
+
|
|
37
|
+
No variant prop. The toolbar's buttons are fixed.
|
|
38
|
+
|
|
39
|
+
## 5. Sizes
|
|
40
|
+
|
|
41
|
+
No size prop. `minHeight` sets the editing area's minimum height (default `"150px"`); the area grows with content. Pass a `--size-*` token for a shorter area (`"var(--size-4xl)"`) or keep the default; don't pass raw px.
|
|
42
|
+
|
|
43
|
+
## 6. States
|
|
44
|
+
|
|
45
|
+
| State | Looks like | Notes |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Default | Bordered container, toolbar above the editing area | |
|
|
48
|
+
| Focus (toolbar) | Toggle's focus outline on the focused button | Never remove or restyle the focus ring. |
|
|
49
|
+
| Focus (editing area) | No visible change | The content area removes its outline and the container has no focus style, so keyboard users can't see when the editor has focus. Don't patch it with your own CSS. |
|
|
50
|
+
| Pressed (toolbar) | Toggle's pressed style | When the selection already has that mark or block. |
|
|
51
|
+
| Empty | Placeholder text | |
|
|
52
|
+
| Disabled | `--interactive-bg-disabled` surface, `--interactive-fg-disabled` text; editor read-only, every toolbar button disabled | |
|
|
53
|
+
|
|
54
|
+
There's no error state. Show a FormMessage below the editor.
|
|
55
|
+
|
|
56
|
+
## 7. Content guidelines
|
|
57
|
+
|
|
58
|
+
- Use the placeholder for a prompt about what to write: "Describe what changed and why".
|
|
59
|
+
- Put the field's name in visible text above the editor, not in the placeholder.
|
|
60
|
+
- Toolbar labels are fixed by the component.
|
|
61
|
+
|
|
62
|
+
| Do | Don't |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| Describe what changed and why | Start typing... |
|
|
65
|
+
| Release notes (label above) | Release notes (placeholder only) |
|
|
66
|
+
|
|
67
|
+
## 8. Rules
|
|
68
|
+
|
|
69
|
+
1. Sanitise the HTML before you store it or render it (for example with DOMPurify), and only pass trusted HTML to `value`. `onValueChange` emits raw, unsanitised HTML.
|
|
70
|
+
2. Store the HTML exactly as emitted. Don't transform it inside `onValueChange`: a `value` that differs from the editor's HTML resets the content and moves the caret. Sanitise on save or on render.
|
|
71
|
+
3. Put a visible label above the editor. RichText takes no `id` or `aria-*` props, so a Label `htmlFor` can't target it.
|
|
72
|
+
4. Don't restyle the content through internal class names such as `.eluan-rich-text-content` or `.ProseMirror`. Its typography comes from a raw CSS string the component injects.
|
|
73
|
+
5. Use RichText. Reach for RichTextToolbar only when you already create your own TipTap editor; RichText doesn't expose its editor, so you can't move its toolbar elsewhere.
|
|
74
|
+
6. Check emptiness on the text, not the string: an empty editor emits `<p></p>`, not `""`.
|
|
75
|
+
7. Never pass `className` or `style`; RichText doesn't accept them. Put width on a wrapper.
|
|
76
|
+
|
|
77
|
+
## 9. Dos and don'ts
|
|
78
|
+
|
|
79
|
+
**Do:** keep the emitted HTML and sanitise when saving.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
<RichText value={html} onValueChange={setHtml} placeholder="Describe what changed and why" />
|
|
83
|
+
<Button type="button" onClick={() => onSave(sanitize(html))}>Save notes</Button>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Don't:** sanitise on every keystroke, or render the raw output.
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<RichText value={html} onValueChange={(next) => setHtml(sanitize(next))} />
|
|
90
|
+
<div dangerouslySetInnerHTML={{ __html: html }} />
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Do:** label the editor with visible text above it.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<Typography variant="label" as="p">Release notes</Typography>
|
|
97
|
+
<RichText value={html} onValueChange={setHtml} />
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Don't:** restyle the content from app CSS.
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<style>{`.eluan-rich-text-content h1 { font-size: 40px; }`}</style>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 10. Accessibility
|
|
107
|
+
|
|
108
|
+
- Roles: the editing area is a contenteditable `textbox` (role added by TipTap). Toolbar buttons are Toggles: `button` with `aria-pressed`.
|
|
109
|
+
- Labels: toolbar buttons are named "Bold", "Italic", "Strikethrough", "Code", "Heading 1" to "Heading 3", "Bullet List", "Ordered List", "Quote", "Horizontal Rule", "Undo" and "Redo". The editing area has no accessible name and RichText can't give it one (see Rules).
|
|
110
|
+
- Keyboard: Tab moves through each toolbar button, then into the editor; the toolbar has no `toolbar` role or arrow-key navigation. Enter or Space runs a button, and focus moves into the editor. In the editor: ⌘/Ctrl+B bold, ⌘/Ctrl+I italic, ⌘/Ctrl+Shift+S strikethrough, ⌘/Ctrl+E inline code, ⌘/Ctrl+Shift+B quote, ⌘/Ctrl+Z undo, ⌘/Ctrl+Shift+Z or ⌘/Ctrl+Y redo. Inside a list, Tab and Shift+Tab indent and outdent instead of leaving the editor.
|
|
111
|
+
- Focus: every toolbar command returns focus to the editor. The editing area shows no focus indicator (see States).
|
|
112
|
+
- Contrast: handled by the theme. Don't override colours.
|
|
113
|
+
|
|
114
|
+
## 11. Behaviour
|
|
115
|
+
|
|
116
|
+
- Responsive: fills its container's width; the toolbar wraps onto more lines when narrow.
|
|
117
|
+
- Overflow: the editing area grows with its content and has no maximum height.
|
|
118
|
+
- The toolbar renders nothing until TipTap has created the editor, which can shift layout on first render.
|
|
119
|
+
- `value` is synced in: when it differs from the editor's HTML, the content is replaced. `disabled` switches editing on and off live.
|
|
120
|
+
- Content styles: headings use `--font-size-3xl`, `--font-size-2xl` and `--font-size-xl`; lists, quotes, inline code and rules have their own spacing and borders. These come from a CSS string injected once per page.
|
|
121
|
+
- StarterKit also enables underline (⌘/Ctrl+U), links, code blocks and markdown-style shortcuts (for example `# ` for a heading), none of which have toolbar buttons. Expect `<u>`, `<a>` and `<pre>` in the output and allow for them when sanitising and rendering.
|
|
122
|
+
- Motion: Toggle's own transitions only. Don't add your own.
|
|
123
|
+
|
|
124
|
+
## 12. API
|
|
125
|
+
|
|
126
|
+
<!-- api:start -->
|
|
127
|
+
### RichText
|
|
128
|
+
|
|
129
|
+
| Prop | Type | Default | Description |
|
|
130
|
+
| --- | --- | --- | --- |
|
|
131
|
+
| `value` | `string` | | Controlled HTML. Pass only trusted or sanitised HTML. |
|
|
132
|
+
| `onValueChange` | `(value: string) => void` | | Fires on every edit with the editor's raw, unsanitised HTML. |
|
|
133
|
+
| `placeholder` | `string` | `"Start typing..."` | Shown while the document is empty. |
|
|
134
|
+
| `disabled` | `boolean` | `false` | Makes the editor read-only and disables the toolbar. |
|
|
135
|
+
| `minHeight` | `string` | `"150px"` | CSS length for the editing area's minimum height. |
|
|
136
|
+
|
|
137
|
+
Takes no other props: no `id`, `name`, `aria-*`, `className` or `style`. `ref` reaches the container `<div>`.
|
|
138
|
+
|
|
139
|
+
### RichTextToolbar
|
|
140
|
+
|
|
141
|
+
| Prop | Type | Default | Description |
|
|
142
|
+
| --- | --- | --- | --- |
|
|
143
|
+
| `editor` | `Editor \| null` | | A TipTap editor instance; renders nothing while `null`. |
|
|
144
|
+
| `disabled` | `boolean` | `false` | Disables every button. Buttons also disable when the editor isn't editable. |
|
|
145
|
+
<!-- api:end -->
|
|
146
|
+
|
|
147
|
+
## 13. Examples
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
import { useState } from "react";
|
|
151
|
+
import { Button, FormMessage, RichText, Typography } from "@eluan/core";
|
|
152
|
+
|
|
153
|
+
export function ReleaseNotesEditor({
|
|
154
|
+
initialHtml,
|
|
155
|
+
sanitize,
|
|
156
|
+
onSave,
|
|
157
|
+
}: {
|
|
158
|
+
initialHtml: string;
|
|
159
|
+
sanitize: (html: string) => string;
|
|
160
|
+
onSave: (html: string) => void;
|
|
161
|
+
}) {
|
|
162
|
+
const [html, setHtml] = useState(initialHtml);
|
|
163
|
+
const [showError, setShowError] = useState(false);
|
|
164
|
+
const isEmpty = html.replace(/<[^>]*>/g, "").trim() === "";
|
|
165
|
+
|
|
166
|
+
function handleSave() {
|
|
167
|
+
if (isEmpty) return setShowError(true);
|
|
168
|
+
setShowError(false);
|
|
169
|
+
onSave(sanitize(html));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div style={{ display: "flex", flexDirection: "column", gap: "var(--spacing-sm)" }}>
|
|
174
|
+
<Typography variant="label" as="p">Release notes</Typography>
|
|
175
|
+
<RichText value={html} onValueChange={setHtml} placeholder="Describe what changed and why" />
|
|
176
|
+
{showError && <FormMessage>Add release notes before publishing.</FormMessage>}
|
|
177
|
+
<div style={{ display: "flex", justifyContent: "flex-end" }}>
|
|
178
|
+
<Button type="button" onClick={handleSave}>Save notes</Button>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## 14. Related components
|
|
186
|
+
|
|
187
|
+
- [Textarea](./textarea.md): plain multi-line text without formatting.
|
|
188
|
+
- [Toggle](./toggle.md): the toolbar buttons.
|
|
189
|
+
- [Typography](./typography.md): visible label text, and around rendered output.
|
|
190
|
+
- [CodeBlock](./code-block.md): showing code rather than editing prose.
|
|
191
|
+
- [Forms pattern](../patterns/forms.md): errors and submit.
|
|
192
|
+
|
|
193
|
+
## 15. Common agent mistakes
|
|
194
|
+
|
|
195
|
+
_Filled from evals._
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Row
|
|
3
|
+
use_when: Items sit side by side in a line, such as a title with its actions, a group of buttons, an icon with its label, or tags that wrap.
|
|
4
|
+
instead_of: Stack for items one above another; Grid when items must line up in columns across rows; ToggleGroup or SegmentedControl for a set of choices.
|
|
5
|
+
source: packages/core/src/components/row.tsx
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Row
|
|
9
|
+
|
|
10
|
+
## 1. Overview
|
|
11
|
+
|
|
12
|
+
Row is horizontal flow: a flex row with a `--spacing-*` gap, children vertically centred by default. It draws nothing and only places what's inside it. `justify="between"` pushes the first and last child apart, `wrap` lets children flow onto further lines, and `inline` sits the row inside running text. It takes `Box`'s props (padding, `grow`, `shrink`, `height`, `minHeight`, `position`, `inset`, `overflow`), `as` and `asChild`, and drops `className` and `style`.
|
|
13
|
+
|
|
14
|
+
## 2. When to use
|
|
15
|
+
|
|
16
|
+
- A page or section header: title at the start, actions at the end (`justify="between"`).
|
|
17
|
+
- A group of buttons, such as Cancel and Save at the end of a form.
|
|
18
|
+
- An input that takes the remaining width next to a button (with a `Box grow` around the input).
|
|
19
|
+
- Tags, Badges or chips that wrap onto further lines.
|
|
20
|
+
- A label and value on one line in a list row.
|
|
21
|
+
|
|
22
|
+
### When not to use
|
|
23
|
+
|
|
24
|
+
- Items one above another → [Stack](./stack.md).
|
|
25
|
+
- Cards or tiles that must line up in columns, or change column count with the viewport → [Grid](./grid.md).
|
|
26
|
+
- A set of choices the user picks from → [ToggleGroup](./toggle-group.md) or [SegmentedControl](./segmented-control.md).
|
|
27
|
+
- An icon beside a label inside a Button → just put both in the Button; it lays them out.
|
|
28
|
+
|
|
29
|
+
## 3. Anatomy
|
|
30
|
+
|
|
31
|
+
1. **Container**: one element (`div` by default) laid out as a flex row with `min-width: 0`. Children sit directly inside it.
|
|
32
|
+
|
|
33
|
+
## 4. Variants
|
|
34
|
+
|
|
35
|
+
Row has no `variant`. These props change how children sit:
|
|
36
|
+
|
|
37
|
+
| Prop | Values | Default |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| `align` (cross axis) | `start`, `center`, `end`, `stretch`, `baseline` | `center` |
|
|
40
|
+
| `justify` (main axis) | `start`, `center`, `end`, `between` | unset: children pack at the start |
|
|
41
|
+
| `wrap` | `boolean` | `false`: one line |
|
|
42
|
+
| `inline` | `boolean` | `false`: a block-level row |
|
|
43
|
+
|
|
44
|
+
Use `align="baseline"` when items of different text sizes should share a baseline, and `align="start"` when one child is much taller.
|
|
45
|
+
|
|
46
|
+
## 5. Sizes
|
|
47
|
+
|
|
48
|
+
Row has no size prop. `gap` sets the space between children (and between lines when it wraps) and `pad`, `padX`, `padY` set padding, each a `--spacing-*` step from `"none"` to `"4xl"`. `gap` defaults to `"md"`.
|
|
49
|
+
|
|
50
|
+
## 6. States
|
|
51
|
+
|
|
52
|
+
| State | Looks like | Notes |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| Default | Children in a line with the gap | Static. Row has no interactive states. |
|
|
55
|
+
|
|
56
|
+
## 7. Content guidelines
|
|
57
|
+
|
|
58
|
+
- Keep a Row to items that read as one line. If it holds more than one or two groups, consider Stack plus smaller Rows.
|
|
59
|
+
- Put the primary action last in a row of buttons, at the end of the line.
|
|
60
|
+
- Use `wrap` for content of unknown length (tags); without it, a long Row overflows its parent.
|
|
61
|
+
|
|
62
|
+
## 8. Rules
|
|
63
|
+
|
|
64
|
+
1. Space children with `gap`, never margins. For a gap after one child only, nest Rows or use [Icon](./icon.md)'s `after`.
|
|
65
|
+
2. Use `--spacing-*` steps only, through `gap` and `pad*`. Never write px.
|
|
66
|
+
3. Give the child that should absorb leftover space `grow`: wrap it in `<Box grow>` (or pass `grow` to a Stack or Row child). Give a child that must stay on one line, such as a date or a badge group, `shrink={false}`.
|
|
67
|
+
4. Use `wrap` whenever the number or width of children isn't fixed.
|
|
68
|
+
5. Don't pass `className` or `style`; they're dropped.
|
|
69
|
+
6. Don't use Row for a grid of cards. Rows don't align across lines; use Grid.
|
|
70
|
+
|
|
71
|
+
## 9. Dos and don'ts
|
|
72
|
+
|
|
73
|
+
**Do:** put a title and its actions at either end.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
<Row justify="between" gap="lg" wrap>
|
|
77
|
+
<Typography variant="heading" as="h2">Members</Typography>
|
|
78
|
+
<Button>Invite</Button>
|
|
79
|
+
</Row>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**Don't:** fake it with a spacer or margins.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
<div style={{ display: "flex" }}>
|
|
86
|
+
<h2>Members</h2>
|
|
87
|
+
<div style={{ flex: 1 }} />
|
|
88
|
+
<Button style={{ marginLeft: 16 }}>Invite</Button>
|
|
89
|
+
</div>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 10. Accessibility
|
|
93
|
+
|
|
94
|
+
- Role: none by default. Use `as` for meaning (`nav`, `header`, `li`), or `role="toolbar"` with an `aria-label` for a group of controls that acts as a toolbar.
|
|
95
|
+
- Keyboard: none of its own. Tab order follows the DOM.
|
|
96
|
+
- Order: `justify` doesn't reorder children, so reading order matches the visual order. Don't reverse it with CSS.
|
|
97
|
+
- `as="label"` makes the whole row a click target for the control inside it.
|
|
98
|
+
|
|
99
|
+
## 11. Behaviour
|
|
100
|
+
|
|
101
|
+
- Responsive: Row stays one line unless `wrap` is set. For a row that becomes a column on small screens, use Grid with `cols={{ base: 1, m: 2 }}`, or Stack at small widths.
|
|
102
|
+
- Density: `gap` and padding follow `data-spacing`.
|
|
103
|
+
- Shrinking: Row has `min-width: 0`, and its children shrink by default: when the row runs out of room, their text wraps. A `grow` child with `truncate` text gives up its space first; a `shrink={false}` child keeps its content size.
|
|
104
|
+
- Motion: none.
|
|
105
|
+
|
|
106
|
+
## 12. API
|
|
107
|
+
|
|
108
|
+
<!-- api:start -->
|
|
109
|
+
| Prop | Type | Default | Description |
|
|
110
|
+
| --- | --- | --- | --- |
|
|
111
|
+
| `gap` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | `"md"` | Space between children, as a `--spacing-*` step. |
|
|
112
|
+
| `align` | `"start" \| "center" \| "end" \| "stretch" \| "baseline"` | `"center"` | Cross-axis alignment. Rows centre their children by default. |
|
|
113
|
+
| `justify` | `"start" \| "center" \| "end" \| "between"` | | Main-axis distribution. `between` pushes the first and last child apart. |
|
|
114
|
+
| `wrap` | `boolean` | `false` | Let children wrap onto further lines (the gap applies between lines too). |
|
|
115
|
+
| `inline` | `boolean` | `false` | Render as `inline-flex`, so the row sits in a line of text. |
|
|
116
|
+
| `pad` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Padding on every side. `padX` / `padY` override it per axis. |
|
|
117
|
+
| `padX` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Inline padding (left and right in LTR). |
|
|
118
|
+
| `padY` | `"none" \| "xxs" \| "xs" \| "sm" \| "md" \| "lg" \| "xl" \| "2xl" \| "3xl" \| "4xl"` | | Block padding (top and bottom). |
|
|
119
|
+
| `grow` | `boolean` | | Take the remaining space in a flex parent: `flex: 1 1 0` with `min-width: 0`. |
|
|
120
|
+
| `shrink` | `boolean` | | `false` keeps the element at its content size in a flex parent (`flex-shrink: 0`). |
|
|
121
|
+
| `height` | `"full" \| "screen"` | | `full` fills the parent's height; `screen` fills the viewport (`100dvh`, so mobile browser bars don't cover the bottom). |
|
|
122
|
+
| `minHeight` | `"full" \| "screen"` | | At least the parent's height (`full`) or the viewport's (`screen`). |
|
|
123
|
+
| `position` | `"relative" \| "absolute"` | | `relative` makes this the anchor for `inset` children; `absolute` takes it out of flow. |
|
|
124
|
+
| `inset` | `"fill" \| "top" \| "bottom"` | | Pin to the nearest positioned ancestor: `fill` covers it, `top` and `bottom` run along that edge at full width. Sets `position: absolute`. |
|
|
125
|
+
| `overflow` | `"hidden" \| "auto"` | | `hidden` clips the content; `auto` scrolls it when it doesn't fit. |
|
|
126
|
+
| `as` | `"div" \| "span" \| "section" \| "article" \| "aside" \| "header" \| "footer" \| "main" \| "nav" \| "form" \| "fieldset" \| "label" \| "p" \| "ul" \| "ol" \| "li" \| "dl" \| "dt" \| "dd"` | | Element override. Defaults to `div`. |
|
|
127
|
+
| `asChild` | `boolean` | `false` | Render the child element instead (Radix Slot); the layout styles move onto it. |
|
|
128
|
+
| `...props` | `HTMLAttributes<HTMLElement>` without `className`, `style` | | Native attributes: `id`, `role`, `aria-*`, `data-*`, event handlers. |
|
|
129
|
+
<!-- api:end -->
|
|
130
|
+
|
|
131
|
+
## 13. Examples
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { Badge, Box, Button, Input, Row, Stack, Typography } from "@eluan/core";
|
|
135
|
+
|
|
136
|
+
export function MembersHeader() {
|
|
137
|
+
return (
|
|
138
|
+
<Stack gap="lg">
|
|
139
|
+
<Row justify="between" gap="lg" wrap>
|
|
140
|
+
<Typography variant="title" as="h1">Members</Typography>
|
|
141
|
+
<Row gap="sm">
|
|
142
|
+
<Button variant="outline">Export</Button>
|
|
143
|
+
<Button>Invite</Button>
|
|
144
|
+
</Row>
|
|
145
|
+
</Row>
|
|
146
|
+
|
|
147
|
+
<Row gap="sm">
|
|
148
|
+
<Box grow>
|
|
149
|
+
<Input type="search" placeholder="Search members" aria-label="Search members" />
|
|
150
|
+
</Box>
|
|
151
|
+
<Button variant="outline">Filters</Button>
|
|
152
|
+
</Row>
|
|
153
|
+
|
|
154
|
+
<Row wrap gap="xs">
|
|
155
|
+
<Badge variant="secondary">Active</Badge>
|
|
156
|
+
<Badge variant="secondary">Admins</Badge>
|
|
157
|
+
<Badge variant="secondary">Invited</Badge>
|
|
158
|
+
</Row>
|
|
159
|
+
</Stack>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## 14. Related components
|
|
165
|
+
|
|
166
|
+
- [Stack](./stack.md): the vertical counterpart.
|
|
167
|
+
- [Box](./box.md): `grow` for the child that takes the remaining width.
|
|
168
|
+
- [Grid](./grid.md): columns that line up across rows.
|
|
169
|
+
- [Icon](./icon.md): sizes icons inside a Row; `after` for a gap after one icon.
|
|
170
|
+
- [ToggleGroup](./toggle-group.md): a row of choices, not of layout.
|
|
171
|
+
|
|
172
|
+
## 15. Common agent mistakes
|
|
173
|
+
|
|
174
|
+
_Filled from evals._
|