Skip to content

Commit f58b258

Browse files
committed
update for initial release
1 parent 0eae690 commit f58b258

27 files changed

+266
-116
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
/.idea
12
.DS_Store

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Customizable Radio Buttons Field Changelog
2+
3+
## 1.0.0 - 2019-04-06
4+
### Added
5+
- Initial release

LICENSE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 Codemonauts
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Customizable Radio Buttons Field for Craft CMS 3.x
2+
3+
![Icon](resources/buttons.png)
4+
5+
A field type that add customizable radio buttons to Craft CMS.
6+
7+
## Background
8+
9+
Pictures say more than many words. With this plugin you can add radio buttons as fields, which can be images, icons, CSS classes, texts or a combination of them.
10+
11+
## Requirements
12+
13+
* Craft CMS >= 3.0.0
14+
15+
## Installation
16+
17+
Open your terminal and go to your Craft project:
18+
19+
``` shell
20+
cd /path/to/project
21+
composer require codemonauts/craft-customizable-radio-buttons-field
22+
```
23+
24+
In the control panel, go to Settings → Plugins and click the “install” button for *Customizable radio buttons field*.
25+
26+
## Configuration
27+
28+
Copy the ```config.php``` to your config folder as ```buttons.php```. Then add button groups like this:
29+
30+
``` php
31+
<?php
32+
33+
return [
34+
'cssFile' => '@config/path/to/my.css', // optional path to a local CSS file. This will be automatically published.
35+
'cssUrl' => 'https://example.com/awesome.css' // Optional URL to an external CSS.
36+
'buttonGroups' => [
37+
'myhandle' => [
38+
'name' => 'My awesome buttons', // The name in the field's configuration dialog.
39+
'buttons' => [
40+
'handle-button-1' => [
41+
'image' => '@buttonsAssets/myimage.jpg', // Optional Image, overwrites 'label'.
42+
'title' => 'My button 1', // Title and Alt Attributes.
43+
'value' => 'myvalue', // The value to store (string)
44+
'class' => 'myclass', // Optional class(es) to add to the button.
45+
'label' => 'abc', // The button's text, will be overwritten when an image is set.
46+
],
47+
'handle-button-2' => [
48+
// ...
49+
],
50+
// ...
51+
],
52+
// ...
53+
],
54+
],
55+
];
56+
```
57+
58+
You can have multiple button groups. They all share the same CSS file or CSS URL you can configure. See the [examples](examples/README.md).
59+
60+
With ❤ by [codemonauts](https://codemonauts.com)

composer.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
{
22
"name": "codemonauts/craft-customizable-radio-buttons-field",
3-
"description": "Radio buttons field customizable with CSS classes, icons, images and text",
3+
"description": "Craft CMS plugin to add a radio buttons field, customizable with CSS classes, icons, images and text.",
44
"version": "1.0.0",
55
"type": "craft-plugin",
6-
"minimum-stability": "dev",
76
"keywords": [
87
"craft",
98
"cms",
109
"craftcms",
11-
"craft-plugin"
10+
"craft-plugin",
11+
"field",
12+
"buttons"
1213
],
13-
"autoload": {
14-
"psr-4": {
15-
"codemonauts\\buttons\\": "src/"
16-
}
17-
},
14+
"license": "MIT",
1815
"authors": [
1916
{
2017
"name": "codemonauts",
21-
"homepage": "https://www.codemonauts.com"
18+
"homepage": "https://codemonauts.com"
2219
}
2320
],
24-
"require": {
25-
"craftcms/cms": "^3.0.0"
26-
},
2721
"support": {
22+
"source": "https://github.com/codemonauts/craft-customizable-radio-buttons-field",
2823
"docs": "https://github.com/codemonauts/craft-customizable-radio-buttons-field/blob/master/README.md",
2924
"issues": "https://github.com/codemonauts/craft-customizable-radio-buttons-field/issues"
3025
},
31-
"license": "MIT",
26+
"require": {
27+
"craftcms/cms": "^3.0.0"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"codemonauts\\buttons\\": "src/"
32+
}
33+
},
3234
"extra": {
3335
"handle": "buttons",
34-
"name": "Customizable radio buttons field",
35-
"developer": "codemonauts",
36-
"developerUrl": "https://www.codemonauts.com",
37-
"schemaVersion": "1.0.0",
36+
"class": "codemonauts\\buttons\\Buttons",
37+
"name": "Customizable Radio Buttons Field",
38+
"description": "Radio buttons field, customizable with CSS classes, icons, images and text.",
3839
"hasCpSection": false,
39-
"hasSettings": false,
40-
"class": "codemonauts\\buttons\\Buttons"
40+
"hasSettings": false
4141
}
4242
}

examples/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Examples
2+
3+
## Colorset
4+
5+
![Screenshot Colorset](../resources/colorset.png)
6+
7+
This example shows the usage of CSS classes and labels to let the user switch between preconfigured back- and foreground colors. So the user can see, how the color will look like.
8+
9+
To run this example, copy the [```colorset/buttons.php```](colorset/buttons.php) to your Craft config folder and the [```colorset/colorset.css```](colorset/colorset.css) to a subfolder called ```buttons```.
10+
11+
## Positions
12+
13+
![Screenshot Positions](../resources/positions.png)
14+
15+
This example uses images as buttons to switch between different positions.
16+
17+
To run this example, copy the [```positions/buttons.php```](positions/buttons.php) to your Craft config folder and the folder [```positions/images```](positions/images) to a subfolder called ```buttons```.
18+
19+
## Transport
20+
21+
![Screenshot Transport](../resources/transport.png)
22+
23+
In this example we use the Font Awesome Icons with our radio buttons. We add the Font Awesome CSS URL and the corresponding CSS classes to the buttons.
24+
25+
To run this example, just copy the [```transport/buttons.php```](transport/buttons.php) to your Craft config folder.
26+
27+

examples/colorset/buttons.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

33
return [
4+
'cssFile' => '@config/buttons/colorset.css',
45
'buttonGroups' => [
56
'colorset' => [
67
'name' => 'Colorset',
7-
'cssFile' => '@config/buttons/colorset.css',
88
'buttons' => [
99
'white' => [
1010
'label' => 'T',

examples/positions/buttons.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
return [
4+
'buttonGroups' => [
5+
'position' => [
6+
'name' => 'Position',
7+
'buttons' => [
8+
'left-top' => [
9+
'image' => '@config/buttons/images/left-top.svg',
10+
'title' => 'Top left',
11+
'value' => 'left-top',
12+
],
13+
'center-top' => [
14+
'image' => '@config/buttons/images/center-top.svg',
15+
'title' => 'Top center',
16+
'value' => 'center-top',
17+
],
18+
'right-top' => [
19+
'image' => '@config/buttons/images/right-top.svg',
20+
'title' => 'Top right',
21+
'value' => 'right-top',
22+
],
23+
'left-middle' => [
24+
'image' => '@config/buttons/images/left-middle.svg',
25+
'title' => 'Middle left',
26+
'value' => 'left-middle',
27+
],
28+
'center-middle' => [
29+
'image' => '@config/buttons/images/center-middle.svg',
30+
'title' => 'Middle center',
31+
'value' => 'center-middle',
32+
],
33+
'right-middle' => [
34+
'image' => '@config/buttons/images/right-middle.svg',
35+
'title' => 'Middle right',
36+
'value' => 'right-middle',
37+
],
38+
'left-bottom' => [
39+
'image' => '@config/buttons/images/left-bottom.svg',
40+
'title' => 'Bottom left',
41+
'value' => 'left-bottom',
42+
],
43+
'center-bottom' => [
44+
'image' => '@config/buttons/images/center-bottom.svg',
45+
'title' => 'Bottom center',
46+
'value' => 'center-bottom',
47+
],
48+
'right-bottom' => [
49+
'image' => '@config/buttons/images/right-bottom.svg',
50+
'title' => 'Bottom right',
51+
'value' => 'right-bottom',
52+
],
53+
],
54+
],
55+
],
56+
];

examples/icons/buttons.php renamed to examples/transport/buttons.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

33
return [
4-
'cssFile' => '@config/buttons/fontawesome.css',
4+
'cssUrl' => 'https://use.fontawesome.com/releases/v5.8.1/css/all.css',
55
'buttonGroups' => [
6-
'icons' => [
6+
'transport' => [
77
'name' => 'Transport',
88
'buttons' => [
99
'bicycle' => [

resources/colorset.png

7.48 KB
Loading

resources/positions.png

9.78 KB
Loading

resources/transport.png

9.17 KB
Loading

src/config.php

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,43 @@
11
<?php
22

33
return [
4-
'buttonGroups' => [
5-
'position' => [
6-
'name' => 'Position',
7-
'buttons' => [
8-
'left-top' => [
9-
'image' => '@codemonauts/buttons/resources/images/left-top.svg',
10-
'title' => 'Top left',
11-
'value' => 'left-top',
12-
],
13-
'center-top' => [
14-
'image' => '@codemonauts/buttons/resources/images/center-top.svg',
15-
'title' => 'Top center',
16-
'value' => 'center-top',
17-
],
18-
'right-top' => [
19-
'image' => '@codemonauts/buttons/resources/images/right-top.svg',
20-
'title' => 'Top right',
21-
'value' => 'right-top',
22-
],
23-
'left-middle' => [
24-
'image' => '@codemonauts/buttons/resources/images/left-middle.svg',
25-
'title' => 'Middle left',
26-
'value' => 'left-middle',
27-
],
28-
'center-middle' => [
29-
'image' => '@codemonauts/buttons/resources/images/center-middle.svg',
30-
'title' => 'Middle center',
31-
'value' => 'center-middle',
32-
],
33-
'right-middle' => [
34-
'image' => '@codemonauts/buttons/resources/images/right-middle.svg',
35-
'title' => 'Middle right',
36-
'value' => 'right-middle',
37-
],
38-
'left-bottom' => [
39-
'image' => '@codemonauts/buttons/resources/images/left-bottom.svg',
40-
'title' => 'Bottom left',
41-
'value' => 'left-bottom',
42-
],
43-
'center-bottom' => [
44-
'image' => '@codemonauts/buttons/resources/images/center-bottom.svg',
45-
'title' => 'Bottom center',
46-
'value' => 'center-bottom',
47-
],
48-
'right-bottom' => [
49-
'image' => '@codemonauts/buttons/resources/images/right-bottom.svg',
50-
'title' => 'Bottom right',
51-
'value' => 'right-bottom',
52-
],
53-
],
54-
],
55-
],
4+
/*
5+
* An optional CSS file, that will be bundled and published for the control panel, when a button group is used.
6+
* There can only be one CSS file for all button groups.
7+
*
8+
* You would normaly use something like '@config/buttons/style.css'.
9+
*/
10+
'cssFile' => '',
11+
12+
/*
13+
* In addition to a local file, you can set an URL for an external CSS (e.g. Fontawesome)
14+
*/
15+
'cssUrl' => '',
16+
17+
/*
18+
* This array sets the config for all button groups. The array key is the button group's handle.
19+
* See the examples in the repository.
20+
*
21+
* E.g.:
22+
*
23+
* 'buttonGroups' => [
24+
* 'myhandle' => [
25+
* 'name' => 'My awesome buttons', // The name in the field's configuration dialog
26+
* 'buttons' => [
27+
* 'handle-button-1' => [
28+
* 'image' => '@buttonsAssets/myimage.jpg', // Optional Image, overwrites 'label'
29+
* 'title' => 'My button 1', // Title and Alt Attributes
30+
* 'value' => 'myvalue', // The value to store (string)
31+
* 'class' => 'myclass', // Optional class to add to the button
32+
* 'label' => 'Abc', // The button's text, will be overwritten when an image is set
33+
* ],
34+
* 'handle-button-2' => [
35+
* ...
36+
* ],
37+
* ...
38+
* ],
39+
* ],
40+
* ],
41+
*/
42+
'buttonGroups' => [],
5643
];

0 commit comments

Comments
 (0)