Components
A view builds a typed element tree. Arona serializes that tree to the platform payload. The same component model works on Slack, with a different vocabulary.
Discord vocabulary
Section titled “Discord vocabulary”Top-level layout:
Container,Text,Section,SeparatorActionRow,Button,LinkButtonSelectwithOption, plusUserSelect,RoleSelect,MentionableSelect,ChannelSelectThumbnail,Media,Gallery,File,CanvasModal,Label,TextInput,Checkbox,CheckboxGroup,RadioGroup,FileUploadFragment, to group top-level elements without adding a container
A Section can carry one accessory:
Section(h, { accessory: Button(h, { onClick: Message.Clicked(), children: ["Refresh"], }), children: [Text(h, "Current status: ready")],});Composition is explicit
Section titled “Composition is explicit”Arona does not add structural components for you. A misplaced element throws a descriptive error when the message is serialized.
Button,LinkButton, and every select belong in anActionRow.MediaandCanvasbelong in aGallery.- Modal fields belong in a
Label. - A Discord
Sectionmust have an accessory. - A Slack
TextorMarkdownbelongs in aSection. - A Slack
Buttonbelongs inActions, or is theSectionaccessory. - A Slack
Actionsneeds at least oneButton.
Use Fragment when a view needs several top-level elements.
Controls that own state
Section titled “Controls that own state”Select and Modal are headless components. They own ids, defaults, and
validation. You draw their parts and receive a message:
ActionRow(h, { children: [ Select(h, { placeholder: "Pick a character", onChange: (interaction) => Message.Changed({ id: interaction.values[0] ?? "" }), children: characters.map((character) => Option(h, { value: String(character.id), label: character.name }), ), }), ],});Modal fields
Section titled “Modal fields”Discord puts modal fields inside labels. Arona requires the Label:
Modal(h, { title: "Profile", onSubmit: (payload) => Submitted({ name: payload.values.name ?? "", newsletter: payload.checkboxes.newsletter ?? false, plan: payload.radioGroups.plan ?? "", }), children: [ Label(h, { label: "Name", children: [TextInput(h, { name: "name" })], }), Label(h, { label: "Newsletter", children: [Checkbox(h, { name: "newsletter" })], }), Label(h, { label: "Plan", children: [ RadioGroup(h, { name: "plan", children: [ RadioOption(h, { value: "free", label: "Free" }), RadioOption(h, { value: "pro", label: "Pro" }), ], }), ], }), ],});onSubmit receives text, select, checkbox, radio, mentionable, and file values,
each keyed by the field name.
The working example is
examples/simple.
Slack uses Blocks, Section, Text, Markdown, Actions, Button, and
Divider. See Create a Slack bot for the app
setup and the block rules.
- Sessions for mounting and closing messages.
- API reference for every helper.