定制 heureka-agency/switcheroo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

heureka-agency/switcheroo

最新稳定版本:1.2

Composer 安装命令:

composer require heureka-agency/switcheroo

包简介

TALL-stack currency switcher for LiveWire.

README 文档

README

Latest Version on Packagist Total Downloads

Under the hood, Switcheroo is a single Livewire component with some AlpineJS magic sprinkled on top. The component uses and requires TailwindCss for it's styling, but you're free to change to any other CSS framework or even native CSS if you wish.

This package does not offer any currency conversion features yet.

Installation

You can install the package via composer:

composer require heureka-agency/switcheroo

You will also need to install the flag-icons npm package to display currency flags:

npm install flag-icons

Usage

Config

First, publish the Switcheroo config with the following command:

php artisan vendor:publish --tag=switcheroo-config
return [
    /**
     * Add any currencies you would like to handle with Switcheroo.
     * You can select all currencies using \HeurekaAgency\Switcheroo\Enums\Currency::all()
     */
    'enabled_currencies' => [
        \HeurekaAgency\Switcheroo\Enums\Currency::EUR,
        \HeurekaAgency\Switcheroo\Enums\Currency::USD,
        \HeurekaAgency\Switcheroo\Enums\Currency::GBP,
    ],

    /**
     * Set the default currency of the currency switcher.
     */
    'default_currency' => \HeurekaAgency\Switcheroo\Enums\Currency::EUR
];

Including in your app

Make sure to import the Switcheroo CSS in your app.css:

@import "../../vendor/heureka-agency/switcheroo/resources/css/switcheroo.css";

Then simply include the Switcheroo component wherever you'd like:

<livewire:switcheroo::currency-switcher /> 

Events

Switcheroo sends a single Livewire event every time a currency is selected. You can freely access this event from any other Livewire component or even from Javascript.

#[On('currency-selected')]
public function yourCurrencySwitchHandler(string $currency): void
{
    $currency = Currency::from($currency);
    // any other business logic
} 

The selected currency is also stored in local storage using Alpine.$persist.

Views

You're free to publish the Switcheroo views to customize the look and feel of the currency switcher:

php artisan vendor:publish --tag=switcheroo-views 

Translations

Switcheroo is multilingual ready! Not that it has any readable strings to translate, but nonetheless, you can publish the language files using:

php artisan vendor:publish --tag=switcheroo-translations 

Future plans

  • create a helper to automatically convert currencies based on the current selection
  • add support for language and country selection
  • add support for native language display of currencies/languages/countries

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email thar.tristan@heureka-kreativ.hu instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-18