-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New overhauled loader implementation (#101)
* Added value- & nested based syncInput notification label feature * Made the loader more composable * Making labels visible again * Concept to dispatch event on elements instead of window * Label splitting + translation is now being done inside the Loader Hydrator * Loader layout and binding restructure * Notification Messenger implementation * Notification messenger design completion * Notification messenger logic improvements * Message loading status busy / done icons * Notification System Configurations * StyleCI fixes * System config field comment improvement * Message failure implementation * Loader wildcard feature * AlpineJS v2 compatibility (thanks @Vinai) * Loader plugin documentation * StyleCI fix --------- Co-authored-by: Willem Poortman <[email protected]>
- Loading branch information
Showing
19 changed files
with
764 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Copyright © Willem Poortman 2021-present. All rights reserved. | ||
* | ||
* Please read the README and LICENSE files for more | ||
* details on copyrights and license information. | ||
*/ | ||
|
||
namespace Magewirephp\Magewire\Model\Magento\System; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Framework\Serialize\Serializer\Json; | ||
use Magento\Store\Model\ScopeInterface; | ||
|
||
class ConfigMagewire | ||
{ | ||
public const GROUP_LOADER = 'loader'; | ||
public const GROUP_NOTIFICATIONS = 'loader/notifications'; | ||
|
||
protected ScopeConfigInterface $scopeConfig; | ||
protected Json $serializer; | ||
|
||
public function __construct( | ||
ScopeConfigInterface $scopeConfig, | ||
Json $serializer | ||
) { | ||
$this->scopeConfig = $scopeConfig; | ||
$this->serializer = $serializer; | ||
} | ||
|
||
public function canShowLoaderOverlay(): bool | ||
{ | ||
return $this->isGroupFlag('enable', self::GROUP_LOADER) ?? true; | ||
} | ||
|
||
public function canShowLoaderNotificationMessages(): bool | ||
{ | ||
return $this->isGroupFlag('enable', self::GROUP_NOTIFICATIONS) ?? true; | ||
} | ||
|
||
public function getNotificationMessageFadeoutTimeout(): int | ||
{ | ||
return (int) $this->getGroupValue('message_fadeout_timeout', self::GROUP_NOTIFICATIONS) ?? 2500; | ||
} | ||
|
||
public function pageRequiresLoaderPluginScript(): bool | ||
{ | ||
return $this->canShowLoaderOverlay() || $this->canShowLoaderNotificationMessages(); | ||
} | ||
|
||
/** | ||
* Retrieve grouped config value by path and scope. | ||
* | ||
* @return mixed | ||
*/ | ||
public function getGroupValue( | ||
string $path, | ||
string $group = null, | ||
string $scopeType = ScopeInterface::SCOPE_STORE, | ||
$scopeCode = null | ||
) { | ||
return $this->scopeConfig->getValue($this->createPath($path, $group), $scopeType, $scopeCode); | ||
} | ||
|
||
/** | ||
* Retrieve grouped config flag by path and scope. | ||
*/ | ||
public function isGroupFlag( | ||
string $path, | ||
string $group = null, | ||
string $scopeType = ScopeInterface::SCOPE_STORE, | ||
$scopeCode = null | ||
): bool { | ||
return $this->scopeConfig->isSetFlag($this->createPath($path, $group), $scopeType, $scopeCode); | ||
} | ||
|
||
protected function createPath(string $path, string $group = null) | ||
{ | ||
return sprintf('dev/%s/%s', $group ? 'magewire/' . $group : 'magewire', trim($path)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module.exports = { | ||
content: ['../../../../src/view/frontend/templates/**/*.phtml'] | ||
}; | ||
content: [ | ||
'../../../../src/view/frontend/templates/**/*.phtml' | ||
] | ||
}; |
Oops, something went wrong.