UNPKG

@empathyco/x-components

Version:
88 lines (67 loc) 3.07 kB
--- title: BaseResultCurrentPrice --- # BaseResultCurrentPrice Component that renders the @empathyco/x-types#Result current price that may or may not be on sale. ## Props | Name | Description | Type | Default | | --------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ----------------------- | | <code>result</code> | (Required) The @empathyco/x-types#Result information. | <code>Result</code> | <code></code> | | <code>currency</code> | Optional value coming from https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes. | <code>string</code> | <code></code> | | <code>format</code> | The currency format possibilities from Intl.NumberFormatOptions.<br />Allows customization of decimal places, grouping, etc. | <code>Omit<Intl.NumberFormatOptions, 'currency' \| 'style'></code> | <code>() => ({})</code> | ## Slots | Name | Description | Bindings<br />(name - type - description) | | -------------------- | ------------------ | -------------------------------------------- | | <code>default</code> | Base currency item | **result** <code>result</code> - Result data | ## Examples ### Basic example This component shows the current price formatted. You can provide the `currency` and `format` properties to customize the display. ```vue <template> <BaseResultCurrentPrice :result="result" currency="USD" /> </template> <script setup> import { BaseResultCurrentPrice } from "@empathyco/x-components"; const result = { price: { value: 123.45, hasDiscount: false }, // ...other result properties }; </script> ``` ### Customizing format You can customize the number formatting using the `format` prop with `Intl.NumberFormatOptions`: ```vue <template> <BaseResultCurrentPrice :result="result" currency="EUR" :format="{ minimumFractionDigits: 2, maximumFractionDigits: 2 }" /> </template> <script setup> import { BaseResultCurrentPrice } from "@empathyco/x-components"; const result = { price: { value: 123.456, hasDiscount: false }, // ...other result properties }; </script> ``` ### Overriding default slot ```vue <template> <BaseResultCurrentPrice :result="result"> <span class="custom-base-result-current-price">{{ result.price.value }}</span> </BaseResultCurrentPrice> </template> <script setup> import { BaseResultCurrentPrice } from "@empathyco/x-components"; const result = { price: { value: 123.45, hasDiscount: false }, // ...other result properties }; </script> ```