From f86385d537854c47c9c5092380d1f00ce3d2f88f Mon Sep 17 00:00:00 2001 From: Jellygnite Date: Fri, 11 Dec 2020 10:31:56 +1000 Subject: [PATCH] first commit --- _config.php | 14 ++++++++ _config/config.yml | 6 ++++ composer.json | 33 +++++++++++++++++++ css/main.css | 15 +++++++++ .../Forms/CheckboxField_holder.ss | 13 ++++++++ 5 files changed, 81 insertions(+) create mode 100644 _config.php create mode 100644 _config/config.yml create mode 100644 composer.json create mode 100644 css/main.css create mode 100644 themes/cms-forms/templates/SilverStripe/Forms/CheckboxField_holder.ss diff --git a/_config.php b/_config.php new file mode 100644 index 0000000..eaec078 --- /dev/null +++ b/_config.php @@ -0,0 +1,14 @@ +set( + 'admin_themes', + [ + 'jellygnite/silverstripe-admin-toggle-checkbox:cms-forms', + 'silverstripe/admin:cms-forms', + SSViewer::DEFAULT_THEME + ] +); diff --git a/_config/config.yml b/_config/config.yml new file mode 100644 index 0000000..ef6bd9a --- /dev/null +++ b/_config/config.yml @@ -0,0 +1,6 @@ +--- +Name: togglecheckboxconfig +--- +SilverStripe\Admin\LeftAndMain: + extra_requirements_css: + - jellygnite/silverstripe-admin-toggle-checkbox:css/main.css \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..b0443dc --- /dev/null +++ b/composer.json @@ -0,0 +1,33 @@ +{ + "name": "jellygnite/silverstripe-admin-toggle-checkbox", + "description": "CSS only toggle that re-styles checkboxes in the admin", + "type": "silverstripe-vendormodule", + "keywords": [ + "silverstripe", + "admin", + "checkbox" + ], + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Jim Chisholm", + "homepage": "http://www.jellygnite.com.au/" + } + ], + "require": { + "silverstripe/framework": "~4.0", + "silverstripe/admin": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7" + }, + "extra": { + "expose": [ + "css" + ], + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/css/main.css b/css/main.css new file mode 100644 index 0000000..20b1390 --- /dev/null +++ b/css/main.css @@ -0,0 +1,15 @@ +.field.checkbox.toggle .form__field-holder.form-check {} + +.field.checkbox.toggle{position:relative} +/*.field.checkbox.toggle .form-check{margin-left:1.585rem!important}*/ +.field.checkbox.toggle .form-check label.form-check-label{max-width:100%!important;display:block} +.field.checkbox.toggle .title{margin-left:65px;cursor:pointer} +.field.checkbox.toggle .slider{cursor:pointer;width:60px;height:24px;top:0;left:0;right:0;bottom:0;background-color:#ccc;border-radius:34px} +.field.checkbox.toggle .slider,.field.checkbox.toggle .slider:before{position:absolute;-webkit-transition:.4s;-o-transition:.4s;transition:.4s} +.field.checkbox.toggle .slider:before{content:"";height:20px;width:20px;top:2px;right:2px;bottom:2px;background-color:#fff;border-radius:50%} +.field.checkbox.toggle input{margin-left:.25rem} +.field.checkbox.toggle input:checked+.slider{background-color:#008a00} +.field.checkbox.toggle input:focus+.slider{-webkit-box-shadow:0 0 1px #004e7f;box-shadow:0 0 1px #004e7f} +.field.checkbox.toggle input:checked+.slider:before{content:"";-webkit-transform:translateX(-36px);-o-transform:translateX(-36px);transform:translateX(-36px)} +.field.checkbox.toggle input+.slider:after{content: "NO";color:#000;position:absolute;display:block;width:34px;left:4px;text-align:center;line-height:26px;font-size:0.9em;} +.field.checkbox.toggle input:checked+.slider:after{content: "YES";color:#fff;right:4px;left:auto} \ No newline at end of file diff --git a/themes/cms-forms/templates/SilverStripe/Forms/CheckboxField_holder.ss b/themes/cms-forms/templates/SilverStripe/Forms/CheckboxField_holder.ss new file mode 100644 index 0000000..3519b03 --- /dev/null +++ b/themes/cms-forms/templates/SilverStripe/Forms/CheckboxField_holder.ss @@ -0,0 +1,13 @@ +
+
+ + <%-- TODO: change $MessageType to match Bootstraps alert types, e.g. alert-info, alert-danger etc --%> + <% if $Message %><% end_if %> + <% if $Description %>

$Description

<% end_if %> +
+ <% if $RightTitle %>

$RightTitle

<% end_if %> +