Skip to content

Commit

Permalink
#2 make sure the vendor classes are also loaded on development; statu…
Browse files Browse the repository at this point in the history
…s toggle widget implemented
  • Loading branch information
1stthomas committed May 28, 2021
1 parent 3ee1f5d commit 1504635
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 0 deletions.
25 changes: 25 additions & 0 deletions controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Concrete\Package\Ht7C5Base;

use \Concrete\Core\Application\Application;
use \Concrete\Core\Asset\AssetList;
use \Concrete\Core\Foundation\Service\ProviderList;
use \Concrete\Core\Package\Package;
use \Concrete\Core\Package\PackageService;
Expand Down Expand Up @@ -64,6 +65,8 @@ public function install()

public function on_start()
{
$this->setupAutoloader();
$this->registerAssets();
$this->registerServices();
}

Expand Down Expand Up @@ -99,6 +102,19 @@ private function installUserGroups()
}
}

private function registerAssets()
{
$al = AssetList::getInstance();

$al->register(
'css',
'ht7-widgets/status-toggle',
'css/ht7.widgets.statustoggle.css',
['version' => '0.0.1', 'minify' => true, 'combine' => true],
$this
);
}

/**
* Register the package services, register the package specific ErrorHandler.
*/
Expand All @@ -108,4 +124,13 @@ private function registerServices()
$list->registerProvider(ServiceProvider::class);
}

private function setupAutoloader()
{
if (file_exists($this->getPackagePath() . '/vendor')) {
// Only for development to make sure the package dependencies are
// accessable.
require_once $this->getPackagePath() . '/vendor/autoload.php';
}
}

}
75 changes: 75 additions & 0 deletions css/ht7.widgets.statustoggle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* copyright 2021 by https://proto.io/freebies/onoff/
*/
.ht7-widget.onoffswitch {
position: relative;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
width: 90px;
}
.ht7-widget.onoffswitch .onoffswitch-checkbox {
opacity: 0;
pointer-events: none;
position: absolute;
}
.ht7-widget.onoffswitch .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
.ht7-widget.onoffswitch .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
.ht7-widget.onoffswitch .onoffswitch-label {
border: 2px solid #999999;
border-radius: 20px;
cursor: pointer;
display: block;
margin: 0;
overflow: hidden;
}
.ht7-widget.onoffswitch .onoffswitch-label .onoffswitch-inner {
display: block;
margin-left: -100%;
transition: margin 0.3s ease-in 0s;
width: 200%;
}
.ht7-widget.onoffswitch .onoffswitch-label .onoffswitch-inner:before,
.ht7-widget.onoffswitch .onoffswitch-label .onoffswitch-inner:after {
box-sizing: border-box;
color: white;
display: block;
float: left;
font-family: Trebuchet, Arial, sans-serif;
font-size: 14px;
font-weight: bold;
height: 30px;
line-height: 30px;
padding: 0;
width: 50%;
}
.ht7-widget.onoffswitch .onoffswitch-label .onoffswitch-inner:before {
background-color: #34C279;
color: #FFFFFF;
content: "ON";
padding-left: 10px;
}
.ht7-widget.onoffswitch .onoffswitch-label .onoffswitch-inner:after {
background-color: #EDA1A1;
color: #665A5A;
content: "OFF";
padding-right: 10px;
text-align: right;
}
.ht7-widget.onoffswitch .onoffswitch-label .onoffswitch-switch {
background: #FFFFFF;
border: 2px solid #999999;
border-radius: 20px;
bottom: 0;
display: block;
margin: 6px;
position: absolute;
right: 56px;
top: 0;
transition: all 0.3s ease-in 0s;
width: 18px;
}
20 changes: 20 additions & 0 deletions elements/widgets/status_toggle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
defined('C5_EXECUTE') or die('Access Denied.');
/*
* copyright 2021 by https://proto.io/freebies/onoff/
*/
$checked = $status ? ' checked="checked"' : '';
$id = empty($id) ? '' : ' id="' . $id . '"';
$name = empty($name) ? '' : ' name="' . $name . '"';
?>
<div class="ht7-widget onoffswitch">
<input <?= $checked . $id . $name; ?>
class="onoffswitch-checkbox"
tabindex="0"
type="checkbox"
/>
<label class="onoffswitch-label" for="myonoffswitch">
<span class="onoffswitch-inner"></span>
<span class="onoffswitch-switch"></span>
</label>
</div>
74 changes: 74 additions & 0 deletions less/ht7.widgets.statustoggle.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* copyright 2021 by https://proto.io/freebies/onoff/
*/
.ht7-widget.onoffswitch {
position: relative;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
width: 90px;
.onoffswitch-checkbox {
opacity: 0;
pointer-events: none;
position: absolute;
&:checked + .onoffswitch-label .onoffswitch-inner {
margin-left: 0;
}
&:checked + .onoffswitch-label .onoffswitch-switch {
right: 0px;
}
}
.onoffswitch-label {
border: 2px solid #999999;
border-radius: 20px;
cursor: pointer;
display: block;
margin: 0;
overflow: hidden;
.onoffswitch-inner {
display: block;
margin-left: -100%;
transition: margin 0.3s ease-in 0s;
width: 200%;
&:before, &:after {
box-sizing: border-box;
color: white;
display: block;
float: left;
font-family: Trebuchet, Arial, sans-serif;
font-size: 14px;
font-weight: bold;
height: 30px;
line-height: 30px;
padding: 0;
width: 50%;
}
&:before {
background-color: #34C279;
color: #FFFFFF;
content: "ON";
padding-left: 10px;
}
&:after {
background-color: #EDA1A1;
color: #665A5A;
content: "OFF";
padding-right: 10px;
text-align: right;
}
}
.onoffswitch-switch {
background: #FFFFFF;
border: 2px solid #999999;
border-radius: 20px;
bottom: 0;
display: block;
margin: 6px;
position: absolute;
right: 56px;
top: 0;
transition: all 0.3s ease-in 0s;
width: 18px;
}
}
}

0 comments on commit 1504635

Please sign in to comment.