From 625dfeb79fb55b458ceb48f207aa59af4943c2ed Mon Sep 17 00:00:00 2001 From: Brian Rogers Date: Wed, 19 Oct 2022 14:33:03 -0600 Subject: [PATCH] lots of updates --- src/app/Models/Language.php | 115 ++++++ src/composer.json | 7 + ...00_00_00_000000_create_languages_table.php | 37 ++ ... 0001_00_00_000000_create_users_table.php} | 3 +- ...02_00_00_000000_create_sessions_table.php} | 0 src/database/seeders/LanguageSeeder.php | 6 - src/helpers/functions/date_and_time.php | 76 ++++ src/helpers/functions/distances.php | 233 +++++++++++ src/helpers/functions/strings.php | 29 ++ src/helpers/functions/temperatures.php | 45 +++ src/helpers/global_functions.php | 335 +-------------- src/resources/css/app.css | 4 + src/resources/css/elements/forms.css | 38 ++ .../js/Components/DropdownSeparator.vue | 6 +- src/resources/js/Components/DropdownTitle.vue | 10 +- src/resources/js/theme-change/btn.js | 35 ++ src/resources/js/theme-change/callAll.js | 13 + src/resources/js/theme-change/callBtn.js | 9 + src/resources/js/theme-change/callSelect.js | 9 + src/resources/js/theme-change/callToggle.js | 9 + src/resources/js/theme-change/export.js | 7 + src/resources/js/theme-change/index.d.ts | 3 + src/resources/js/theme-change/select.js | 24 ++ src/resources/js/theme-change/toggle.js | 38 ++ .../views/components/country-flag.blade.php | 382 ------------------ src/tailwind.config.js | 12 + 26 files changed, 771 insertions(+), 714 deletions(-) create mode 100644 src/app/Models/Language.php create mode 100644 src/database/migrations/0000_00_00_000000_create_languages_table.php rename src/database/migrations/{0000_00_00_000000_create_users_table.php => 0001_00_00_000000_create_users_table.php} (92%) rename src/database/migrations/{0001_00_00_000000_create_sessions_table.php => 0002_00_00_000000_create_sessions_table.php} (100%) create mode 100644 src/helpers/functions/date_and_time.php create mode 100644 src/helpers/functions/distances.php create mode 100644 src/helpers/functions/strings.php create mode 100644 src/helpers/functions/temperatures.php create mode 100644 src/resources/js/theme-change/btn.js create mode 100644 src/resources/js/theme-change/callAll.js create mode 100644 src/resources/js/theme-change/callBtn.js create mode 100644 src/resources/js/theme-change/callSelect.js create mode 100644 src/resources/js/theme-change/callToggle.js create mode 100644 src/resources/js/theme-change/export.js create mode 100644 src/resources/js/theme-change/index.d.ts create mode 100644 src/resources/js/theme-change/select.js create mode 100644 src/resources/js/theme-change/toggle.js delete mode 100644 src/resources/views/components/country-flag.blade.php diff --git a/src/app/Models/Language.php b/src/app/Models/Language.php new file mode 100644 index 0000000..1f09ac3 --- /dev/null +++ b/src/app/Models/Language.php @@ -0,0 +1,115 @@ + */ + protected $fillable = [ + 'locale', + 'iso_code', + 'name', + 'localized_name', + ]; + + /** + |-------------------------------------------------------------------------- + | Class Constants + |-------------------------------------------------------------------------- + | + */ + + // + + /** + |-------------------------------------------------------------------------- + | Custom/Private Methods + |-------------------------------------------------------------------------- + | + */ + + /** + * Get the prunable model query. + * + * @package App\Models\Language + * @since 1.0.0 + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function prunable(): Builder + { + //return static::where('deleted_at', '<=', now()->subMonth()); + } + + /** + * Prepare the model for pruning. + * + * @package App\Models\Language + * @since 1.0.0 + * + * @return void + */ + protected function pruning(): void + { + // + } + + /** + |-------------------------------------------------------------------------- + | Accessors + |-------------------------------------------------------------------------- + | + */ + + // + + /** + |-------------------------------------------------------------------------- + | Mutators + |-------------------------------------------------------------------------- + | + */ + + // + + /** + |-------------------------------------------------------------------------- + | Scopes + |-------------------------------------------------------------------------- + | + */ + + // + + /** + |-------------------------------------------------------------------------- + | Relationships + |-------------------------------------------------------------------------- + | + */ + + /** + * User relationship. + * + * @package App\Models\Language + * @since 1.0.0 + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function users(): HasMany + { + return $this->hasMany(User::class); + } +} diff --git a/src/composer.json b/src/composer.json index af41885..8eb21a0 100644 --- a/src/composer.json +++ b/src/composer.json @@ -38,6 +38,9 @@ "mcamara/laravel-localization": "", // localization that also handles route translations "barryvdh/laravel-translation-manager": "", // self-evident + // PDF stuff + "creagia/laravel-sign-pad": "", // allows signatures on documents + // Geo-spatial "brick/geo": "", // GIS geometry library "stevebauman/location": "", // retrieve a user's location by their IP address @@ -58,6 +61,10 @@ "brick/math": "", // arbitrary-precision arithmetic library "brick/money": "", // money and currency library + "protonemedia/laravel-verify-new-email": "", // must verify new email address before email update will be completed + "protonemedia/inertiajs-tables-laravel-query-builder": "", // datatables for InertiaJS/Vue and Laravel + + "doctrine/dbal": "", // useful for artisan db:show }, "require-dev": { diff --git a/src/database/migrations/0000_00_00_000000_create_languages_table.php b/src/database/migrations/0000_00_00_000000_create_languages_table.php new file mode 100644 index 0000000..9c2f13d --- /dev/null +++ b/src/database/migrations/0000_00_00_000000_create_languages_table.php @@ -0,0 +1,37 @@ +id(); + $table->string('locale')->index(); + $table->string('iso_code')->unique(); + $table->string('name'); + $table->string('localized_name'); + $table->timestamp('created_at')->useCurrent(); + $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); + $table->softDeletes(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('languages'); + } +}; diff --git a/src/database/migrations/0000_00_00_000000_create_users_table.php b/src/database/migrations/0001_00_00_000000_create_users_table.php similarity index 92% rename from src/database/migrations/0000_00_00_000000_create_users_table.php rename to src/database/migrations/0001_00_00_000000_create_users_table.php index 1d1a23a..ab5f3e4 100644 --- a/src/database/migrations/0000_00_00_000000_create_users_table.php +++ b/src/database/migrations/0001_00_00_000000_create_users_table.php @@ -20,7 +20,8 @@ return new class extends Migration $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('timezone_name')->default('UTC'); - $table->string('current_team_id', 64)->nullable(); + $table->foreignId('language_id'); + $table->foreignId('current_team_id')->nullable(); $table->string('profile_photo_path', 2048)->nullable(); $table->string('password'); $table->text('two_factor_secret')->nullable(); diff --git a/src/database/migrations/0001_00_00_000000_create_sessions_table.php b/src/database/migrations/0002_00_00_000000_create_sessions_table.php similarity index 100% rename from src/database/migrations/0001_00_00_000000_create_sessions_table.php rename to src/database/migrations/0002_00_00_000000_create_sessions_table.php diff --git a/src/database/seeders/LanguageSeeder.php b/src/database/seeders/LanguageSeeder.php index ab7afc6..af8063e 100644 --- a/src/database/seeders/LanguageSeeder.php +++ b/src/database/seeders/LanguageSeeder.php @@ -20,42 +20,36 @@ class LanguageSeeder extends Seeder [ 'iso_code' => 'en_US', 'locale' => 'en', - 'country_code' => 'US', 'title' => 'English', 'title_localized' => 'English', ], [ 'iso_code' => 'de_DE', 'locale' => 'de', - 'country_code' => 'DE', 'title' => 'German', 'title_localized' => 'Deutsch', ], [ 'iso_code' => 'fr_FR', 'locale' => 'fr', - 'country_code' => 'FR', 'title' => 'French', 'title_localized' => 'Français', ], [ 'iso_code' => 'es_SP', 'locale' => 'es', - 'country_code' => 'SP', 'title' => 'Spanish', 'title_localized' => 'Español', ], [ 'iso_code' => 'jp_JP', 'locale' => 'jp', - 'country_code' => 'JP', 'title' => 'Japanese', 'title_localized' => '日本', ], [ 'iso_code' => 'zh_TW', 'locale' => 'zh', - 'country_code' => 'TW', 'title' => 'Taiwanese', 'title_localized' => '台湾', ], diff --git a/src/helpers/functions/date_and_time.php b/src/helpers/functions/date_and_time.php new file mode 100644 index 0000000..ede2104 --- /dev/null +++ b/src/helpers/functions/date_and_time.php @@ -0,0 +1,76 @@ += 3600) { + return sprintf('%02d:%02d:%02d', ($seconds / 3600), (($seconds / 60) % 60), ($seconds % 60)); + } + + return sprintf('%02d:%02d', (($seconds / 60) % 60), ($seconds % 60)); + } +} + +if (! function_exists('minutesToTime')) { + /** + * Convert minutes to HH:MM + * + * @since 1.0.0 + * + * @param datatype $minutes + * + * @return string + */ + function minutesToTime($minutes): string + { + $minutes = intval($minutes); + + return sprintf('%d:%02d', floor($minutes / 60), ($minutes % 60)); + } +} + +if (! function_exists('jddayofweek')) { + /** + * Returns the day of the week. Can return a string or an integer depending on the mode. + * + * @since 1.0.0 + * + * @param int|null $intDay + * @param int $mode + * + * @return string + */ + function jddayofweek(?int $intDay = null, int $mode = 0): string + { + if (is_null($intDay)) { + $intDay = date('l'); + } + + if ($mode === 0) { + return $intDay; + } + + return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][$intDay]; + } +} diff --git a/src/helpers/functions/distances.php b/src/helpers/functions/distances.php new file mode 100644 index 0000000..15c6f7c --- /dev/null +++ b/src/helpers/functions/distances.php @@ -0,0 +1,233 @@ + = 0.9 && $i < 4; $i++) { + $number /= $divisor; + } + return round($number, is_null($precision) ? $bytePreceision[$i] : $precision) . $units[$i]; } } @@ -50,31 +65,6 @@ if (! function_exists('carbon')) { } } -if (! function_exists('jddayofweek')) { - /** - * Returns the day of the week. Can return a string or an integer depending on the mode. - * - * @since 1.0.0 - * - * @param int|null $intDay - * @param int $mode - * - * @return string - */ - function jddayofweek(?int $intDay = null, int $mode = 0): string - { - if (is_null($intDay)) { - $intDay = date('l'); - } - - if ($mode === 0) { - return $intDay; - } - - return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][$intDay]; - } -} - if (! function_exists('is_serialized')) { /** * Check a value to find if it was serialized. @@ -174,284 +164,3 @@ if (! function_exists('maybe_unserialize')) { return $data; } } - -/** - |-------------------------------------------------------------------------- - | Metric functions - |-------------------------------------------------------------------------- - | Functions that convert from metric to imperial or from a smaller - | metric unit to a larger one. - | - */ - -if (! function_exists('centimeters2Inches')) { - /** - * Convert from centimeters to inches. - * - * @since 1.0.0 - * - * @param float|int|string $centimeters - * @param int $precision - * - * @return float - */ - function centimeters2Inches($centimeters, int $preceision = 1): float - { - return round(($centimeters / 2.54), $preceision); - } -} - -if (! function_exists('centimeters2Feet')) { - /** - * Convert from centimeters to inches. - * - * @since 1.0.0 - * - * @param float|int|string $centimeters - * @param int $precision - * - * @return float - */ - function centimeters2Feet($centimeters, int $preceision = 1): float - { - return round((($centimeters / 2.54) * 12), $preceision); - } -} - -if (! function_exists('centimeters2Meters')) { - /** - * Convert from centimeters to meters. - * - * @since 1.0.0 - * - * @param float|int|string $centimeters - * @param int $precision - * - * @return float - */ - function centimeters2Meters($centimeters, int $preceision = 1): float - { - return round(($centimeters / 100), $preceision); - } -} - -if (! function_exists('centimeters2Yards')) { - /** - * Convert from centimeters to yards. - * - * @since 1.0.0 - * - * @param float|int|string $centimeters - * @param int $precision - * - * @return float - */ - function centimeters2Yards($centimeters, int $preceision = 1): float - { - return round(($centimeters / 91.44), $preceision); - } -} - -if (! function_exists('meters2Miles')) { - /** - * Convert from meters to miles. - * - * @since 1.0.0 - * - * @param float|int|string $meters - * @param int $precision - * - * @return float - */ - function meters2Miles($meters, int $preceision = 1): float - { - return round(($meters * 0.00062137), $preceision); - } -} - -if (! function_exists('kilometers2Miles')) { - /** - * Convert from kilometers to meters. - * - * @since 1.0.0 - * - * @param float|int|string $kilometers - * @param int $precision - * - * @return float - */ - function kilometers2Miles($kilometers, int $preceision = 1): float - { - return round(($kilometers * 1.609), $preceision); - } -} - -if (! function_exists('meters2Kilometers')) { - /** - * Convert from meters to kilometers. - * - * @since 1.0.0 - * - * @param float|int|string $meters - * @param int $precision - * - * @return float - */ - function meters2Kilometers($meters, int $preceision = 1): float - { - return round(($meters / 1000), $preceision); - } -} - -if (! function_exists('celsius2Fahrenheit')) { - /** - * Convert from celsius to fahrenheit. - * - * @since 1.0.0 - * - * @param float|int|string $celsius - * @param int $precision - * - * @return float - */ - function celsius2Fahrenheit($celsius, int $preceision = 0): float - { - return round((($celsius * (9/5)) + 32), $preceision); - } -} - -if (! function_exists('millimeters2Inches')) { - /** - * Convert from millimeters to inches. - * - * @since 1.0.0 - * - * @param float|int|string $millimeters - * @param int $precision - * - * @return float - */ - function millimeters2Inches($millimeters, int $preceision = 1): float - { - return round(($millimeters / 25.4), $preceision); - } -} - -/** - |-------------------------------------------------------------------------- - | Imperial functions - |-------------------------------------------------------------------------- - | Functions that convert from imperial to metric or from a smaller - | imperial unit to a larger one. - | - */ - -if (! function_exists('inches2Millimeters')) { - /** - * Convert from inches to millimeters. - * - * @since 1.0.0 - * - * @param float|int|string $inches - * @param int $precision - * - * @return float - */ - function inches2Millimeters($inches, int $preceision = 1): float - { - return round(($inches * 2.54), $preceision); - } -} - -if (! function_exists('inches2Meters')) { - /** - * Convert from inches to meters. - * - * @since 1.0.0 - * - * @param float|int|string $inches - * @param int $precision - * - * @return float - */ - function inches2Meters($inches, int $preceision = 1): float - { - return round(($inches / 39.37), $preceision); - } -} - -if (! function_exists('inches2Yards')) { - /** - * Convert from inches to yards. - * - * @since 1.0.0 - * - * @param float|int|string $inches - * @param int $precision - * - * @return float - */ - function inches2Yards($inches, int $preceision = 1): float - { - return round(($inches / 36), $preceision); - } -} - -if (! function_exists('inches2Feet')) { - /** - * Convert from inches to feet. - * - * @since 1.0.0 - * - * @param float|int|string $inches - * @param int $precision - * - * @return float - */ - function inches2Feet($inches, int $preceision = 1): float - { - return round(($inches * 12), $preceision); - } -} - -if (! function_exists('fahrenheit2Celsius')) { - /** - * Convert from fahrenheit to celsius. - * - * @since 1.0.0 - * - * @param float|int|string $fahrenheit - * @param int $precision - * - * @return float - */ - function fahrenheit2Celsius($fahrenheit, int $preceision = 1): float - { - return round(($fahrenheit - 32 * (5/9)), $preceision); - } -} - -/** - |-------------------------------------------------------------------------- - | Miscellaneous functions - |-------------------------------------------------------------------------- - | Functions that don't really belong to the other two categories. - | - */ - -if (! function_exists('pa2Mbar')) { - /** - * Convert from pascals to milibars. - * - * @since 1.0.0 - * - * @param float|int|string $pascals - * @param int $precision - * - * @return float - */ - function pa2Mbar($pascals, int $preceision = 1): float - { - return round(($pascals / 100), $preceision); - } -} diff --git a/src/resources/css/app.css b/src/resources/css/app.css index e74be54..78c31d9 100644 --- a/src/resources/css/app.css +++ b/src/resources/css/app.css @@ -45,6 +45,10 @@ button, a { transition-property: all; } +nav { + user-select: none; +} + @media (max-width: 1023px) { .grid-container { @apply grid-cols-1; diff --git a/src/resources/css/elements/forms.css b/src/resources/css/elements/forms.css index 9ed00ac..ca6dbe2 100644 --- a/src/resources/css/elements/forms.css +++ b/src/resources/css/elements/forms.css @@ -22,6 +22,7 @@ input.form-input[type="week"], textarea.form-input, select.form-input { @apply relative px-3 py-1 border rounded focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 bg-white dark:bg-indigo-900 text-zinc-900 dark:text-zinc-100 border-stone-300 dark:border-stone-600 shadow dark:shadow-white; + transition: box-shadow 300, background 300; } .form-checkbox-label { @@ -31,3 +32,40 @@ select.form-input { .form-checkbox-label .form-checkbox { @apply rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50; } + + +input.form-input[type="date"]:active, +input.form-input[type="datetime-local"]:active, +input.form-input[type="email"]:active, +input.form-input[type="month"]:active, +input.form-input[type="number"]:active, +input.form-input[type="password"]:active, +input.form-input[type="search"]:active, +input.form-input[type="tel"]:active, +input.form-input[type="text"]:active, +input.form-input[type="textarea"]:active, +input.form-input[type="time"]:active, +input.form-input[type="url"]:active, +input.form-input[type="week"]:active, +textarea.form-input:active, +select.form-input:active { + @apply outline-none shadow; +} + +input.form-input[type="date"]:disabled, +input.form-input[type="datetime-local"]:disabled, +input.form-input[type="email"]:disabled, +input.form-input[type="month"]:disabled, +input.form-input[type="number"]:disabled, +input.form-input[type="password"]:disabled, +input.form-input[type="search"]:disabled, +input.form-input[type="tel"]:disabled, +input.form-input[type="text"]:disabled, +input.form-input[type="textarea"]:disabled, +input.form-input[type="time"]:disabled, +input.form-input[type="url"]:disabled, +input.form-input[type="week"]:disabled, +textarea.form-input:disabled, +select.form-input:disabled { + @apply bg-neutral-400 opacity-7; +} diff --git a/src/resources/js/Components/DropdownSeparator.vue b/src/resources/js/Components/DropdownSeparator.vue index fae64d6..5b7e9ca 100644 --- a/src/resources/js/Components/DropdownSeparator.vue +++ b/src/resources/js/Components/DropdownSeparator.vue @@ -1,7 +1,3 @@ - - diff --git a/src/resources/js/Components/DropdownTitle.vue b/src/resources/js/Components/DropdownTitle.vue index 09c3ec2..0b99d9c 100644 --- a/src/resources/js/Components/DropdownTitle.vue +++ b/src/resources/js/Components/DropdownTitle.vue @@ -1,9 +1,5 @@ - - diff --git a/src/resources/js/theme-change/btn.js b/src/resources/js/theme-change/btn.js new file mode 100644 index 0000000..e7a92c1 --- /dev/null +++ b/src/resources/js/theme-change/btn.js @@ -0,0 +1,35 @@ +function themeBtn() { + (function (theme = localStorage.getItem("theme")) { + if (theme != undefined && theme != '') { + if (localStorage.getItem("theme") && localStorage.getItem("theme") != '') { + document.documentElement.setAttribute("data-theme", theme); + var btnEl = document.querySelector("[data-set-theme='" + theme.toString() + "']"); + if (btnEl) { + [...document.querySelectorAll("[data-set-theme]")].forEach((el) => { + el.classList.remove(el.getAttribute('data-act-class')); + }); + if (btnEl.getAttribute('data-act-class')) { + btnEl.classList.add(btnEl.getAttribute('data-act-class')); + } + } + } else { + var btnEl = document.querySelector("[data-set-theme='']"); + if (btnEl.getAttribute('data-act-class')) { + btnEl.classList.add(btnEl.getAttribute('data-act-class')); + } + } + } + })(); + [...document.querySelectorAll("[data-set-theme]")].forEach((el) => { + el.addEventListener("click", function () { + document.documentElement.setAttribute("data-theme", this.getAttribute('data-set-theme')); + localStorage.setItem("theme", document.documentElement.getAttribute('data-theme')); + [...document.querySelectorAll("[data-set-theme]")].forEach((el) => { + el.classList.remove(el.getAttribute('data-act-class')); + }); + if (el.getAttribute('data-act-class')) { + el.classList.add(el.getAttribute('data-act-class')); + } + }); + }); +} diff --git a/src/resources/js/theme-change/callAll.js b/src/resources/js/theme-change/callAll.js new file mode 100644 index 0000000..a9097f9 --- /dev/null +++ b/src/resources/js/theme-change/callAll.js @@ -0,0 +1,13 @@ +function themeChange(attach = true) { + if (attach === true) { + document.addEventListener("DOMContentLoaded", function (event) { + themeToggle() + themeSelect() + themeBtn() + }) + }else{ + themeToggle() + themeSelect() + themeBtn() + } +} diff --git a/src/resources/js/theme-change/callBtn.js b/src/resources/js/theme-change/callBtn.js new file mode 100644 index 0000000..9c5a410 --- /dev/null +++ b/src/resources/js/theme-change/callBtn.js @@ -0,0 +1,9 @@ +function themeChange(attach = true) { + if (attach === true) { + document.addEventListener("DOMContentLoaded", function (event) { + themeBtn() + }) + }else{ + themeBtn() + } +} diff --git a/src/resources/js/theme-change/callSelect.js b/src/resources/js/theme-change/callSelect.js new file mode 100644 index 0000000..b802748 --- /dev/null +++ b/src/resources/js/theme-change/callSelect.js @@ -0,0 +1,9 @@ +function themeChange(attach = true) { + if (attach === true) { + document.addEventListener("DOMContentLoaded", function (event) { + themeSelect() + }) + }else{ + themeSelect() + } +} diff --git a/src/resources/js/theme-change/callToggle.js b/src/resources/js/theme-change/callToggle.js new file mode 100644 index 0000000..54a4e2e --- /dev/null +++ b/src/resources/js/theme-change/callToggle.js @@ -0,0 +1,9 @@ +function themeChange(attach = true) { + if (attach === true) { + document.addEventListener("DOMContentLoaded", function (event) { + themeToggle() + }) + }else{ + themeToggle() + } +} diff --git a/src/resources/js/theme-change/export.js b/src/resources/js/theme-change/export.js new file mode 100644 index 0000000..cc77b6e --- /dev/null +++ b/src/resources/js/theme-change/export.js @@ -0,0 +1,7 @@ +if (typeof exports != "undefined") { + module.exports = { + themeChange: themeChange + } +} else { + themeChange() +} diff --git a/src/resources/js/theme-change/index.d.ts b/src/resources/js/theme-change/index.d.ts new file mode 100644 index 0000000..fb834ac --- /dev/null +++ b/src/resources/js/theme-change/index.d.ts @@ -0,0 +1,3 @@ +declare module 'theme-change'{ + export function themeChange(swap:boolean = true):void +} diff --git a/src/resources/js/theme-change/select.js b/src/resources/js/theme-change/select.js new file mode 100644 index 0000000..747bbb7 --- /dev/null +++ b/src/resources/js/theme-change/select.js @@ -0,0 +1,24 @@ +function themeSelect() { + (function (theme = localStorage.getItem("theme")) { + if (localStorage.getItem("theme")) { + document.documentElement.setAttribute("data-theme", theme); + var optionToggler = document.querySelector("select[data-choose-theme] [value='" + theme.toString() + "']"); + if (optionToggler) { + [...document.querySelectorAll("select[data-choose-theme] [value='" + theme.toString() + "']")].forEach((el) => { + el.selected = true; + }); + } + } + })(); + if (document.querySelector('select[data-choose-theme]')) { + [...document.querySelectorAll("select[data-choose-theme]")].forEach((el) => { + el.addEventListener('change', function () { + document.documentElement.setAttribute("data-theme", this.value); + localStorage.setItem("theme", document.documentElement.getAttribute('data-theme')); + [...document.querySelectorAll("select[data-choose-theme] [value='" + localStorage.getItem("theme") + "']")].forEach((el) => { + el.selected = true; + }); + }); + }); + } +} diff --git a/src/resources/js/theme-change/toggle.js b/src/resources/js/theme-change/toggle.js new file mode 100644 index 0000000..97e2e22 --- /dev/null +++ b/src/resources/js/theme-change/toggle.js @@ -0,0 +1,38 @@ +function themeToggle() { + var toggleEl = document.querySelector("[data-toggle-theme]"); + (function (theme = localStorage.getItem("theme")) { + if (localStorage.getItem("theme")) { + document.documentElement.setAttribute("data-theme", theme); + if (toggleEl) { + [...document.querySelectorAll("[data-toggle-theme]")].forEach((el) => { + el.classList.add(toggleEl.getAttribute('data-act-class')); + }); + } + } + })(); + if (toggleEl) { + [...document.querySelectorAll("[data-toggle-theme]")].forEach((el) => { + el.addEventListener("click", function () { + var themesList = el.getAttribute('data-toggle-theme'); + if (themesList) { + var themesArray = themesList.split(","); + if (document.documentElement.getAttribute('data-theme') == themesArray[0]) { + if (themesArray.length == 1) { + document.documentElement.removeAttribute("data-theme"); + localStorage.removeItem("theme"); + }else{ + document.documentElement.setAttribute("data-theme", themesArray[1]); + localStorage.setItem("theme", themesArray[1]); + } + } else { + document.documentElement.setAttribute("data-theme", themesArray[0]); + localStorage.setItem("theme", themesArray[0]); + } + } + [...document.querySelectorAll("[data-toggle-theme]")].forEach((el) => { + el.classList.toggle(this.getAttribute('data-act-class')); + }); + }); + }); + } +} diff --git a/src/resources/views/components/country-flag.blade.php b/src/resources/views/components/country-flag.blade.php deleted file mode 100644 index d77346b..0000000 --- a/src/resources/views/components/country-flag.blade.php +++ /dev/null @@ -1,382 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/tailwind.config.js b/src/tailwind.config.js index e841cba..655d993 100644 --- a/src/tailwind.config.js +++ b/src/tailwind.config.js @@ -89,6 +89,18 @@ module.exports = { 900: '#782c0f', }, + 'sunshade': { + 50: '#fff8eb', + 100: '#ffecc6', + 200: '#ffd788', + 300: '#ffbc4a', + 400: '#ffa424', + 500: '#f97e07', + 600: '#dd5902', + 700: '#b73b06', + 800: '#942c0c', + 900: '#7a250d', + }, // yellows