Skip to content

Commit

Permalink
Merge pull request #401 from wintercms/wip/snowboard
Browse files Browse the repository at this point in the history
[1.1.8] Implement an opt-in improved JS framework (Snowboard). Documented by wintercms/docs#45
  • Loading branch information
LukeTowers committed Feb 15, 2022
2 parents 042ab0f + 3671f63 commit df8094c
Show file tree
Hide file tree
Showing 39 changed files with 4,416 additions and 26 deletions.
63 changes: 37 additions & 26 deletions ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use Winter\Storm\Router\Helper as RouterHelper;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Schema;
use System\Classes\MixAssets;

class ServiceProvider extends ModuleServiceProvider
{
Expand Down Expand Up @@ -251,32 +252,37 @@ protected function registerConsole()
/*
* Register console commands
*/
$this->registerConsoleCommand('winter.up', 'System\Console\WinterUp');
$this->registerConsoleCommand('winter.down', 'System\Console\WinterDown');
$this->registerConsoleCommand('winter.update', 'System\Console\WinterUpdate');
$this->registerConsoleCommand('winter.util', 'System\Console\WinterUtil');
$this->registerConsoleCommand('winter.mirror', 'System\Console\WinterMirror');
$this->registerConsoleCommand('winter.fresh', 'System\Console\WinterFresh');
$this->registerConsoleCommand('winter.env', 'System\Console\WinterEnv');
$this->registerConsoleCommand('winter.install', 'System\Console\WinterInstall');
$this->registerConsoleCommand('winter.passwd', 'System\Console\WinterPasswd');
$this->registerConsoleCommand('winter.version', 'System\Console\WinterVersion');
$this->registerConsoleCommand('winter.manifest', 'System\Console\WinterManifest');
$this->registerConsoleCommand('winter.test', 'System\Console\WinterTest');

$this->registerConsoleCommand('plugin.install', 'System\Console\PluginInstall');
$this->registerConsoleCommand('plugin.remove', 'System\Console\PluginRemove');
$this->registerConsoleCommand('plugin.disable', 'System\Console\PluginDisable');
$this->registerConsoleCommand('plugin.enable', 'System\Console\PluginEnable');
$this->registerConsoleCommand('plugin.refresh', 'System\Console\PluginRefresh');
$this->registerConsoleCommand('plugin.rollback', 'System\Console\PluginRollback');
$this->registerConsoleCommand('plugin.list', 'System\Console\PluginList');

$this->registerConsoleCommand('theme.install', 'System\Console\ThemeInstall');
$this->registerConsoleCommand('theme.remove', 'System\Console\ThemeRemove');
$this->registerConsoleCommand('theme.list', 'System\Console\ThemeList');
$this->registerConsoleCommand('theme.use', 'System\Console\ThemeUse');
$this->registerConsoleCommand('theme.sync', 'System\Console\ThemeSync');
$this->registerConsoleCommand('winter.up', \System\Console\WinterUp::class);
$this->registerConsoleCommand('winter.down', \System\Console\WinterDown::class);
$this->registerConsoleCommand('winter.update', \System\Console\WinterUpdate::class);
$this->registerConsoleCommand('winter.util', \System\Console\WinterUtil::class);
$this->registerConsoleCommand('winter.mirror', \System\Console\WinterMirror::class);
$this->registerConsoleCommand('winter.fresh', \System\Console\WinterFresh::class);
$this->registerConsoleCommand('winter.env', \System\Console\WinterEnv::class);
$this->registerConsoleCommand('winter.install', \System\Console\WinterInstall::class);
$this->registerConsoleCommand('winter.passwd', \System\Console\WinterPasswd::class);
$this->registerConsoleCommand('winter.version', \System\Console\WinterVersion::class);
$this->registerConsoleCommand('winter.manifest', \System\Console\WinterManifest::class);
$this->registerConsoleCommand('winter.test', \System\Console\WinterTest::class);

$this->registerConsoleCommand('plugin.install', \System\Console\PluginInstall::class);
$this->registerConsoleCommand('plugin.remove', \System\Console\PluginRemove::class);
$this->registerConsoleCommand('plugin.disable', \System\Console\PluginDisable::class);
$this->registerConsoleCommand('plugin.enable', \System\Console\PluginEnable::class);
$this->registerConsoleCommand('plugin.refresh', \System\Console\PluginRefresh::class);
$this->registerConsoleCommand('plugin.rollback', \System\Console\PluginRollback::class);
$this->registerConsoleCommand('plugin.list', \System\Console\PluginList::class);

$this->registerConsoleCommand('theme.install', \System\Console\ThemeInstall::class);
$this->registerConsoleCommand('theme.remove', \System\Console\ThemeRemove::class);
$this->registerConsoleCommand('theme.list', \System\Console\ThemeList::class);
$this->registerConsoleCommand('theme.use', \System\Console\ThemeUse::class);
$this->registerConsoleCommand('theme.sync', \System\Console\ThemeSync::class);

$this->registerConsoleCommand('mix.install', \System\Console\MixInstall::class);
$this->registerConsoleCommand('mix.list', \System\Console\MixList::class);
$this->registerConsoleCommand('mix.compile', \System\Console\MixCompile::class);
$this->registerConsoleCommand('mix.watch', \System\Console\MixWatch::class);
}

/*
Expand Down Expand Up @@ -560,6 +566,11 @@ protected function registerAssetBundles()
$combiner->registerBundle('~/modules/system/assets/js/framework.js');
$combiner->registerBundle('~/modules/system/assets/js/framework.combined.js');
$combiner->registerBundle('~/modules/system/assets/less/framework.extras.less');
$combiner->registerBundle('~/modules/system/assets/less/snowboard.extras.less');
});

MixAssets::registerCallback(function ($mix) {
$mix->registerPackage('snowboard', '~/modules/system/assets/js/snowboard/winter.mix.js');
});
}

Expand Down
57 changes: 57 additions & 0 deletions assets/css/snowboard.extras.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions assets/js/snowboard/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**/node_modules/**
build/*.js
22 changes: 22 additions & 0 deletions assets/js/snowboard/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"env": {
"es6": true,
"browser": true
},
"globals": {
"Snowboard": "writable"
},
"extends": "airbnb-base",
"rules": {
"class-methods-use-this": ["off"],
"indent": ["error", 4, {
"SwitchCase": 1
}],
"max-len": ["off"],
"new-cap": ["error", { "properties": false }],
"no-alert": ["off"],
"no-param-reassign": ["error", {
"props": false
}]
}
}
3 changes: 3 additions & 0 deletions assets/js/snowboard/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore packages
node_modules
package-lock.json
48 changes: 48 additions & 0 deletions assets/js/snowboard/abstracts/PluginBase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Plugin base abstract.
*
* This class provides the base functionality for all plugins.
*
* @copyright 2021 Winter.
* @author Ben Thomson <[email protected]>
*/
export default class PluginBase {
/**
* Constructor.
*
* The constructor is provided the Snowboard framework instance.
*
* @param {Snowboard} snowboard
*/
constructor(snowboard) {
this.snowboard = snowboard;
}

/**
* Defines the required plugins for this specific module to work.
*
* @returns {string[]} An array of plugins required for this module to work, as strings.
*/
dependencies() {
return [];
}

/**
* Defines the listener methods for global events.
*
* @returns {Object}
*/
listens() {
return {};
}

/**
* Destructor.
*
* Fired when this plugin is removed.
*/
destructor() {
this.detach();
delete this.snowboard;
}
}
15 changes: 15 additions & 0 deletions assets/js/snowboard/abstracts/Singleton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import PluginBase from './PluginBase';

/**
* Singleton plugin abstract.
*
* This is a special definition class that the Snowboard framework will use to interpret the current plugin as a
* "singleton". This will ensure that only one instance of the plugin class is used across the board.
*
* Singletons are initialised on the "domReady" event by default.
*
* @copyright 2021 Winter.
* @author Ben Thomson <[email protected]>
*/
export default class Singleton extends PluginBase {
}
Loading

0 comments on commit df8094c

Please sign in to comment.