-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ce8066e
Showing
16 changed files
with
320 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# For more information about the properties used in this file, | ||
# please see the EditorConfig documentation: | ||
# https://editorconfig.org/ | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,js,json,css,scss}] | ||
indent_size = 2 | ||
|
||
[composer.json] | ||
indent_size = 4 |
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,5 @@ | ||
/tests export-ignore | ||
/client/src export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.github export-ignore |
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,13 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ci: | ||
name: CI | ||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 | ||
with: | ||
phpcoverage: true |
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,7 @@ | ||
node_modules/ | ||
/vendor/ | ||
.DS_Store | ||
composer.lock | ||
*.js.map | ||
*.css.map | ||
yarn-error.log |
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,15 @@ | ||
# Contributing | ||
|
||
- Maintenance on this module is a shared effort of those who use it | ||
- To contribute improvements to the code, ensure you raise a pull request and discuss with the module maintainers | ||
- Please follow the Silverstripe CMS [code contribution guidelines](https://docs.silverstripe.org/en/contributing/code/) and [Module Standard](https://docs.silverstripe.org/en/developer_guides/extending/modules/#module-standard) | ||
- Supply documentation that follows the [GitHub Flavored Markdown](https://help.github.com/articles/markdown-basics/) conventions | ||
- When having discussions about this module in issues or pull request please adhere to the [Silverstripe CMS Community Code of Conduct](https://docs.silverstripe.org/en/project_governance/code_of_conduct/) | ||
|
||
## Contributor license agreement | ||
|
||
By supplying code to this module in patches, tickets and pull requests, you agree to assign copyright | ||
of that code to MODULE_COPYRIGHT_HOLDER_HERE., on the condition that these code changes are released under the | ||
same BSD license as the original module. We ask for this so that the ownership in the license is clear | ||
and unambiguous. By releasing this code under a permissive license such as BSD, this copyright assignment | ||
won't prevent you from using the code in any way you see fit. |
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,12 @@ | ||
Copyright (c) Dynamic, Inc. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,63 @@ | ||
# Silverstripe Elemental Call to Action | ||
|
||
A call to action block for the Elemental block system | ||
|
||
[![CI](https://github.com/dynamic/silverstripe-elemental-call-to-action/actions/workflows/ci.yml/badge.svg)](https://github.com/dynamic/silverstripe-elemental-call-to-action/actions/workflows/ci.yml) | ||
[![codecov](https://codecov.io/gh/dynamic/silverstripe-elemental-call-to-action/branch/master/graph/badge.svg)](https://codecov.io/gh/dynamic/silverstripe-elemental-call-to-action) | ||
|
||
[![Latest Stable Version](https://poser.pugx.org/dynamic/silverstripe-elemental-call-to-action/v/stable)](https://packagist.org/packages/dynamic/silverstripe-elemental-call-to-action) | ||
[![Total Downloads](https://poser.pugx.org/dynamic/silverstripe-elemental-call-to-action/downloads)](https://packagist.org/packages/dynamic/silverstripe-elemental-call-to-action) | ||
[![Latest Unstable Version](https://poser.pugx.org/dynamic/silverstripe-elemental-call-to-action/v/unstable)](https://packagist.org/packages/dynamic/silverstripe-elemental-call-to-action) | ||
[![License](https://poser.pugx.org/dynamic/silverstripe-elemental-call-to-action/license)](https://packagist.org/packages/dynamic/silverstripe-elemental-call-to-action) | ||
|
||
## Requirements | ||
|
||
* dnadesign/silverstripe-elemental: ^5.0 | ||
* silverstripe/linkfield: ^3 | ||
|
||
## Installation | ||
|
||
```sh | ||
composer require dynamic/silverstripe-elemental-call-to-action | ||
``` | ||
|
||
## License | ||
|
||
See [License](LICENSE.md) | ||
|
||
## Usage | ||
|
||
A block to display a call to action - Title, Description, and Link. The UX is meant to mimic an alert in Bootstrap. | ||
|
||
### Template Notes | ||
|
||
The default templates are based off [Bootstrap 5](https://getbootstrap.com/) classes/styling | ||
|
||
## Getting more elements | ||
|
||
See [Elemental modules by Dynamic](https://github.com/orgs/dynamic/repositories?q=elemental&type=all&language=&sort=) | ||
|
||
## Configuration | ||
|
||
See [SilverStripe Elemental Configuration](https://github.com/silverstripe/silverstripe-elemental#configuration) | ||
|
||
## Maintainers | ||
|
||
* [Dynamic](https://www.dynamicagency.com) (<dev@dynamicagency.com>) | ||
|
||
## Bugtracker | ||
Bugs are tracked in the issues section of this repository. Before submitting an issue please read over | ||
existing issues to ensure yours is unique. | ||
|
||
If the issue does look like a new bug: | ||
|
||
- Create a new issue | ||
- Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots | ||
and screencasts can help here. | ||
- Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, | ||
Operating System, any installed SilverStripe modules. | ||
|
||
Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker. | ||
|
||
## Development and contribution | ||
If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers. |
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,4 @@ | ||
<?php | ||
|
||
// You need this file if you don't have anything in the _config folder. If that folder exists | ||
// and is not empty then you can delete this file. |
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 @@ | ||
# see https://docs.silverstripe.org/en/developer_guides/configuration/configuration/ |
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,44 @@ | ||
{ | ||
"name": "dynamic/silverstripe-elemental-call-to-action", | ||
"description": "A call to action block for the Elemental block system", | ||
"license": "BSD-3-Clause", | ||
"type": "silverstripe-vendormodule", | ||
"keywords": [ | ||
"silverstripe", | ||
"CMS", | ||
"Elemental", | ||
"Call To Action", | ||
"CTA" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Dynamic", | ||
"email": "dev@dynamicagency.com", | ||
"homepage": "https://www.dynamicagency.com" | ||
} | ||
], | ||
"require": { | ||
"dnadesign/silverstripe-elemental": "^5", | ||
"silverstripe/linkfield": "^3.0", | ||
"silverstripe/recipe-cms": "^5.0" | ||
}, | ||
"require-dev": { | ||
"silverstripe/recipe-testing": "^3" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"Dynamic\\Elements\\CTA\\": "src/", | ||
"Dynamic\\Elements\\CTA\\Tests\\": "tests/" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"composer/installers": true, | ||
"silverstripe/recipe-plugin": true, | ||
"silverstripe/vendor-plugin": true | ||
}, | ||
"process-timeout": 600 | ||
} | ||
} |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="Silverstripe"> | ||
<description>CodeSniffer ruleset for Silverstripe coding conventions.</description> | ||
|
||
<file>src</file> | ||
<file>tests</file> | ||
|
||
<!-- base rules are PSR-12 --> | ||
<rule ref="PSR12" > | ||
<!-- You may need to use this exclusion if you override some core methods --> | ||
<!--<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />--> | ||
</rule> | ||
</ruleset> |
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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Default"> | ||
<directory>tests/php</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,75 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\CTA\Elements; | ||
|
||
use DNADesign\Elemental\Models\ElementContent; | ||
use SilverStripe\LinkField\JsonData; | ||
use SilverStripe\LinkField\ORM\DBLink; | ||
use SilverStripe\LinkField\Type\Registry; | ||
use SilverStripe\ORM\FieldType\DBField; | ||
|
||
/** | ||
* Class \Dynamic\Elements\CTA\Elements\ElementCallToAction | ||
* | ||
* @property string $CtaLink | ||
*/ | ||
class ElementCallToAction extends ElementContent | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private static string $singular_name = 'Call to Action'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static string $plural_name = 'Call to Actions'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private static string $table_name = 'ElementCallToAction'; | ||
|
||
/** | ||
* @var array|string[] | ||
*/ | ||
private static array $db = [ | ||
'CtaLink' => DBLink::class, | ||
]; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSummary(): string | ||
{ | ||
return DBField::create_field('HTMLText', $this->HTML)->Summary(20); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType(): string | ||
{ | ||
return _t(__CLASS__ . '.BlockType', 'Call To Action'); | ||
} | ||
|
||
/** | ||
* @return JsonData|null | ||
*/ | ||
public function getLinkObject(): ?JsonData | ||
{ | ||
$link = $this->dbObject('CtaLink'); | ||
|
||
$value = $link->getValue(); | ||
|
||
if ($value) { | ||
$type = Registry::singleton()->byKey($value['typeKey']); | ||
|
||
if ($type) { | ||
return $type->loadLinkData($value); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
templates/Dynamic/Elements/CTA/Elements/ElementCallToAction.ss
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,19 @@ | ||
<div class="alert alert-primary" role="alert"> | ||
<div class="px-2 py-2 text-center element__calltoaction"> | ||
<% if $ShowTitle %><h2 class="fw-bold content-element__title">$Title</h2><% end_if %> | ||
<% if $HTML || $CtaLink %> | ||
<div class="col-lg-10 mx-auto"> | ||
<% if $HTML %> | ||
<div class="lead mb-4 content-element__html">$HTML</div> | ||
<% end_if %> | ||
<% if $CtaLink %> | ||
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center content-element_ctalink"> | ||
<% with $LinkObject %> | ||
<a href="$URL" <% if $OpenInNew %>target="_blank" rel="noopener noreferrer"<% end_if %> class="btn btn-primary">$Title</a> | ||
<% end_with %> | ||
</div> | ||
<% end_if %> | ||
</div> | ||
<% end_if %> | ||
</div> | ||
</div> |
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,18 @@ | ||
<?php | ||
|
||
namespace Dynamic\Elements\CTA\Elements\Test; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Dev\SapphireTest; | ||
use Dynamic\Elements\CTA\Elements\ElementCallToAction; | ||
|
||
class ElementCallToActionTest extends SapphireTest | ||
{ | ||
protected static $fixture_file = 'call-to-action.yml'; | ||
|
||
public function testGetCMSFields() | ||
{ | ||
$object = $this->objFromFixture(ElementCallToAction::class, 'one'); | ||
$fields = $object->getCMSFields(); | ||
$this->assertInstanceOf(FieldList::class, $fields); | ||
} | ||
} |
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,3 @@ | ||
Dynamic\Elements\CTA\Elements\ElementCallToAction: | ||
one: | ||
Title: "Call To Action Block" |