Skip to content

Commit

Permalink
DEP Upgrade frontend build stack
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 26, 2023
1 parent 3d1ae3d commit 59fa08f
Show file tree
Hide file tree
Showing 35 changed files with 4,589 additions and 15,516 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
18
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ This module provides the following (may not be a definitive list):
* Customise search results labels from SiteConfig
* Upload custom header and footer logos from SiteConfig
* Upload custom favicon and Apple touch logos from SiteConfig
* [FontAwesome](http://fontawesome.io) icon popup dialog to the TinyMCE content editor (Wātea theme only, by default)
* Customisable theme colours in site settings

## Installation
Expand All @@ -29,25 +28,20 @@ composer require cwp/agency-extensions

## Requirements

* `cwp/cwp` 2.0 or above
* `cwp/cwp` 3.0 or above

**Note** For use with CWP versions less than 2, please see the `1.x` [release line](https://github.com/silverstripe/cwp-agencyextensions/releases).
**Note** For use with CWP versions less than 3, please see the `2.x` [release line](https://github.com/silverstripe/cwp-agencyextensions/releases).

## Documentation

### Features

* [Theme colour picker](docs/en/01_Features/ThemeColors.md)
* [Carousel/hero image](docs/en/01_Features/Carousel.md)
* [FontAwesome icon plugin for TinyMCE](docs/en/01_Features/FontAwesomePlugin.md)
* [Customisable theme colours](docs/en/01_Features/ThemeColors.md)

## Versioning

This library follows [Semver](http://semver.org). According to Semver, you will be able to upgrade to any minor or patch version of this library without any breaking changes to the public API. Semver also requires that we clearly define the public API for this library.

All methods, with `public` visibility, are part of the public API. All other methods are not part of the public API. Where possible, we'll try to keep `protected` methods backwards-compatible in minor/patch versions, but if you're overriding methods then please test your work before upgrading.

## Notes

This library includes a version of the [TinyMCE-FontAwesome-Plugin by Josh18](https://github.com/josh18/TinyMCE-FontAwesome-Plugin) which is open and permissive via the [expat/MIT Licence](https://en.wikipedia.org/wiki/MIT_License).
21 changes: 6 additions & 15 deletions _config.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
<?php

use SilverStripe\Core\Environment;
use SilverStripe\Forms\HTMLEditor\HTMLEditorConfig;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\HTMLEditor\TinyMCEConfig;

// By default the FontAwesome plugin for TinyMCE is enabled. You can disable it by defining
// CWP_AGENCY_DISABLE_FONTAWESOME_PLUGIN = true in your environment configuration.
if (!Environment::getEnv('CWP_AGENCY_DISABLE_FONTAWESOME_PLUGIN')) {
$cwpEditor = HtmlEditorConfig::get('cwp');
$pluginPath = ModuleLoader::getModule('cwp/agency-extensions')
->getResource('thirdparty/TinyMCE-FontAwesome-Plugin/fontawesome/plugin.min.js')
->getURL();
$cwpEditor->enablePlugins(['fontawesome' => $pluginPath]);
$cwpEditor->addButtonsToLine(2, 'fontawesome');

$contentCSS = (array)$cwpEditor->getOption('editor_css');
$contentCSS[] = 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css';
$cwpEditor->setOption('editor_css', $contentCSS);
// CWP_AGENCY_DISABLE_FONTAWESOME_PLUGIN used to control whether an actual tinymce plugin was used.
// CWP_AGENCY_ENABLE_FONTAWESOME_STYLES replaces it as the inverse, since that plugin is no longer available.
// This config is here only to control whether legacy config is kept or not, to make upgrading from CMS 4 easier.
if (Environment::getEnv('CWP_AGENCY_ENABLE_FONTAWESOME_STYLES')) {
$cwpEditor = TinyMCEConfig::get('cwp');

// Allow span tags in TinyMCE to have aria-hidden attributes
$cwpEditor->setOption(
Expand Down
11 changes: 7 additions & 4 deletions _config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@ SilverStripe\SiteConfig\SiteConfig:
- CWP\AgencyExtensions\Extensions\CWPSiteConfigExtension

---
Name: agencyextensionsfontawesome
Except:
envvarset: CWP_AGENCY_DISABLE_FONTAWESOME_PLUGIN
Name: agencyextensionsresources
---
SilverStripe\Admin\LeftAndMain:
extra_requirements_css:
- "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
- "cwp/agency-extensions:client/dist/styles/bundle.css"
extra_requirements_javascript:
- "cwp/agency-extensions:client/dist/js/bundle.js"

---
Name: agencyextensionsfontawesome
Only:
envvarset: CWP_AGENCY_ENABLE_FONTAWESOME_STYLES
---
SilverStripe\Forms\HTMLEditor\TinyMCEConfig:
editor_css:
- "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
6 changes: 6 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

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

2 changes: 1 addition & 1 deletion client/src/components/ColorPickerField/ColorPickerField.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class ColorPickerField extends Component {
}
}

ColorPickerField.proptypes = {
ColorPickerField.propTypes = {
colors: PropTypes.arrayOf(PropTypes.shape({
Title: PropTypes.text,
CSSClass: PropTypes.text,
Expand Down
8 changes: 5 additions & 3 deletions client/src/components/ColorPickerField/ColorPickerField.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
}

.color-picker-field-popover {
max-width: 380px;
width: 380px;

&__option {
display: flex;
padding: 4px;
Expand All @@ -46,4 +43,9 @@
align-self: center;
margin-left: 12px;
}

.popover {
max-width: 380px;
width: 380px;
}
}
2 changes: 1 addition & 1 deletion client/src/components/FontPickerField/FontPickerField.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class FontPickerField extends Component {
}
}

FontPickerField.proptypes = {
FontPickerField.propTypes = {
fonts: PropTypes.arrayOf(PropTypes.shape({
Title: PropTypes.text,
CSSClass: PropTypes.text,
Expand Down
8 changes: 5 additions & 3 deletions client/src/components/FontPickerField/FontPickerField.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
}

.font-picker-field-popover {
max-width: 380px;
width: 380px;

&__option {
padding: 4px 8px;
max-height: 50px;
Expand All @@ -41,6 +38,11 @@
}
}
}

.popover {
max-width: 380px;
width: 380px;
}
}

.font-picker-field__selection-preview {
Expand Down
38 changes: 27 additions & 11 deletions client/src/legacy/entwine.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import jQuery from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import { loadComponent } from 'lib/Injector';

jQuery.entwine('ss', ($) => {
$('.js-injector-boot .form__field-holder .color-picker-field').entwine({
ReactRoot: null,

onmatch() {
const ColorPickerComponent = loadComponent('ColorPickerField');
const schemaData = this.data('schema');
Expand All @@ -15,18 +17,26 @@ jQuery.entwine('ss', ($) => {
name: schemaData.name,
};

ReactDOM.render(
<ColorPickerComponent {...props} />,
this[0]
);
let root = this.getReactRoot();
if (!root) {
root = createRoot(this[0]);
this.setReactRoot(root);
}
root.render(<ColorPickerComponent {...props} />,);
},

onunmatch() {
ReactDOM.unmountComponentAtNode(this[0]);
const root = this.getReactRoot();
if (root) {
root.unmount();
this.setReactRoot(null);
}
}
});

$('.js-injector-boot .form__field-holder .font-picker-field').entwine({
ReactRoot: null,

onmatch() {
const FontPickerComponent = loadComponent('FontPickerField');
const schemaData = this.data('schema');
Expand All @@ -37,14 +47,20 @@ jQuery.entwine('ss', ($) => {
name: schemaData.name,
};

ReactDOM.render(
<FontPickerComponent {...props} />,
this[0]
);
let root = this.getReactRoot();
if (!root) {
root = createRoot(this[0]);
this.setReactRoot(root);
}
root.render(<FontPickerComponent {...props} />);
},

onunmatch() {
ReactDOM.unmountComponentAtNode(this[0]);
const root = this.getReactRoot();
if (root) {
root.unmount();
this.setReactRoot(null);
}
}
});
});
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"extra": {
"expose": [
"thirdparty/TinyMCE-FontAwesome-Plugin/fontawesome",
"client/dist"
]
},
Expand Down
18 changes: 0 additions & 18 deletions docs/en/01_Features/FontAwesomePlugin.md

This file was deleted.

37 changes: 20 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "agency-extensions",
"version": "1.0.0",
"description": "Base module for the default CWP theme to add features",
"scripts": {
"build": "yarn && yarn lint && NODE_ENV=production webpack -p --bail --progress",
"build": "yarn && yarn lint && rm -rf client/dist/* && NODE_ENV=production webpack --mode production --bail --progress",
"dev": "NODE_ENV=development webpack --progress",
"watch": "yarn && NODE_ENV=development webpack --watch --progress",
"css": "WEBPACK_CHILD=css npm run build",
"lint": "eslint client/src && sass-lint --verbose client/src/**/*.scss",
Expand All @@ -17,24 +17,27 @@
},
"author": "SilverStripe",
"license": "BSD-3-Clause",
"engines": {
"node": "^18.x"
},
"dependencies": {
"classnames": "^2.2.5",
"jquery": "^3.5.0",
"classnames": "^2.3.2",
"merge": "^2.1.1",
"mime": "^1.4.1",
"prop-types": "^15.6.2",
"react": "^15.3.1",
"react-dom": "^15.3.1",
"reactstrap": "^6.5.0"
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"reactstrap": "^8.9.0"
},
"devDependencies": {
"@silverstripe/eslint-config": "^0.0.5",
"@silverstripe/webpack-config": "^1.2.0",
"babel-jest": "^20.0.3",
"bootstrap": "^4.3.1",
"jest-cli": "^19.0.2"
"@silverstripe/eslint-config": "^1.0.0-alpha6",
"@silverstripe/webpack-config": "^2.0.0-alpha5",
"webpack": "^5.74.0",
"webpack-cli": "^5.0.0"
},
"engines": {
"node": "^10.x"
}
"resolutions": {
"colors": "1.4.0"
},
"browserslist": [
"defaults"
]
}
20 changes: 0 additions & 20 deletions thirdparty/TinyMCE-FontAwesome-Plugin/LICENSE

This file was deleted.

39 changes: 0 additions & 39 deletions thirdparty/TinyMCE-FontAwesome-Plugin/README.md

This file was deleted.

Loading

0 comments on commit 59fa08f

Please sign in to comment.