named emotions
an emotion is an app-owned artwork definition addressed by a string name. the name lets Emoticon and small dialogs reuse the same image or Svelte visual without repeating its source everywhere.
import { registerEmotion, getEmotion, listEmotions, unregisterEmotion } from '@ciabi/loafkit-ui';
import artwork from '$lib/assets/emotions/happy.png';
registerEmotion({
name: 'docs-example-artwork',
src: artwork,
alt: 'example artwork'
});
const definition = getEmotion('docs-example-artwork');
const available = listEmotions();
// Later, if the app no longer offers this artwork:
unregisterEmotion('docs-example-artwork');import an image from your app, then register it before rendering the name. registration requires a nonempty name and a source or Component. registering the same name replaces the previous definition. getEmotion returns undefined for an unknown name; lookup and listing return shallow copies.
registerEmotions registers a list in order. a failure doesn’t undo earlier registrations. unregistering returns a boolean and removes the definition from the reactive collection.
render and reuse
after registration, use <Emoticon emotion="docs-example-artwork" /> or a small dialog configuration with emoticon: 'docs-example-artwork'. explicit alternative text can override the registered text for a particular use.
the registry doesn’t bundle image files, select a flavor or persist anything. keep shared definitions separate from user-specific state. the app artwork guide is the main guide for direct visuals, accessible text and component artwork; this URL preserves the named-emotion reference.