Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Money component #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alsterholm
Copy link

@alsterholm alsterholm commented Apr 10, 2024

Summary

Since version 10.33, Laravel includes a Number utility classed that, among other things, can be used to format monetary values using Number::currency. This component acts as thin wrapper around that function with some conveniences added.

Usage

The component is very straight forward to use:

<x-money>150</x-money>

Outputs:

<span>$150.00</span>

Like the Number::currency function, currency and locale can be configured.

<x-money currency="EUR" locale="de">150</x-money>

Outputs:

<span>150,00 €</span>

Please note that I opted to name the property currency, unlike in which the parameter in Number::currency is called, for clarity. I'm open to adjust that if needed.

Differences from the Number::currency function

I decided to introduce one change from how Number::currency works, outlined below.

The locale defaults to what's configured in app.locale

This just seemed like a nice default to me, rather than just defaulting to English it respects the configuration you have set for your application.


Thank you for your consideration! Let me know if there's any changes or additions you would like me to make.

PR to update documentation: blade-ui-kit/docs#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant