UNPKG

@empathyco/x-components

Version:
58 lines (40 loc) 1.91 kB
--- title: BaseResultAddToCart --- # BaseResultAddToCart Renders a button with a default slot. It receives the result with the data and emits XEventsTypes.UserClickedResultAddToCart to the bus on click mouse event. ## Props | Name | Description | Type | Default | | ------------------- | ----------------------------------------------------- | ------------------- | ------------- | | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> | ## Slots | Name | Description | Bindings<br />(name - type - description) | | -------------------- | ------------------------------------------------------ | ----------------------------------------- | | <code>default</code> | (Required) Button content with a text, an icon or both | None | ## Events A list of events that the component will emit: - [`UserClickedResultAddToCart`](https://github.com/empathyco/x/blob/main/packages/x-components/src/wiring/events.types.ts): the event is emitted after the user clicks the button. The event payload is the result data. ## Examples Renders a button with a default slot. It receives the result with the data and emits an event `UserClickedResultAddToCart` to the bus on click mouse event. ### Basic example This component is a button to emit `UserClickedResultAddToCart` when clicked by the user. ```vue <template> <BaseResultAddToCart :result="result"> <img src="./add-to-cart.svg" alt="Add to cart" /> <span>Add to cart</span> </BaseResultAddToCart> </template> <script setup> import { BaseResultAddToCart } from "@empathyco/x-components"; const result = { id: "123", name: "Product name", price: 19.99, // ...other result properties }; </script> ```