diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a0a04f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.idea +.DS_Store +/node_modules +/resources/dist/hot diff --git a/README.md b/README.md new file mode 100644 index 0000000..395d9f4 --- /dev/null +++ b/README.md @@ -0,0 +1,114 @@ +# Supportamic + + + +![Statamic 4.0+](https://img.shields.io/badge/Statamic-4.0+-FF269E?style=for-the-badge&link=https://statamic.com) +[![Supportamic on Packagist](https://img.shields.io/packagist/v/mitydigital/supportamic?style=for-the-badge)](https://packagist.org/packages/mitydigital/supportamic/stats) + +--- + + + +> Supportamic is an very opinionated support add-on for Statamic 4 including HubSpot chat support and a Dashboard Widget. + +## Configuration + +You will need to have some `.env` variables added to take full advantage of what the addon can do. + +Make sure you have these set and ready to go: + +```dotenv +SUPPORTAMIC_CHAT=hubspot +SUPPORTAMIC_CHAT_ENDPOINT= +SUPPORTAMIC_EMAIL= +SUPPORTAMIC_WEBSITE= +SUPPORTAMIC_WIDGET_SHOW_GUIDE=true +``` + +### Advanced configuration + +The Chat component of this add-on uses identification based on the logged in Statamic user. If you need to make changes +beyond what the default configuration is doing, don't forget to publish the config file: + +```shell +php artisan vendor:publish --tag=supportamic-config +``` + +For most sites, this won't be necessary. + +## Chat + +Supportamic is configured to work with one chat engine, HubSpot's chat (conversations) widget. + +`SUPPORTAMIC_CHAT` should be "hubspot" - anything else will throw a wobbly. + +`SUPPORTAMIC_CHAT_ENDPOINT` is the endpoint URL provided by HubSpot for embedding your chat widget to your page. + +### Chat Identification + +By default, Supportamic will try to get the logged in user's Name and Email Address and pass these to the chat widget +for a smoother UX for users. + +These are set to look for the `email` and `name` fields of the User, and most likely won't need to change. + +If you have a custom User Blueprint, you can override these in the `config/supportamic.php` config file. + +## Widget + +The Dashboard Widget can be added to your site by adding `supportamic` to your `config/statamic/cp.php` widgets configuration: + +```php +'widgets' => [ + + // ... + + 'supportamic', + + // ... + +], +``` + +There are two key sections - Admin Guide and Support. + +### Admin Guide +The Admin Guide allows you to have a link to your site's support documentation. This is pulled from Statamic's +`STATAMIC_SUPPORT_URL` environment variable (`statamic.cp.support_url`). + +Setting `SUPPORTAMIC_WIDGET_SHOW_GUIDE` to `false` will always hide the Admin Guide section, even when the URL is set. + +Keeping `SUPPORTAMIC_WIDGET_SHOW_GUIDE` as `true` will show the Admin Guide section when the Support URL is not +Statamic's URL. + +### Support: Start a conversation + +If you have Chat correctly configured, the "Start a Conversation" button will appear. + +When loaded, this will be disabled, but will be enabled when the Chat widget is ready. + +### Support: Email support + +Set `SUPPORTAMIC_EMAIL` to a valid email address to enable the "Email Support" option. + +This will create a button with a `mailto:` link. + +### Support: Visit support website + +Set `SUPPORTAMIC_WEBSITE` to a valid website to enable the "Visit support website" option. + +This will open in a new window. + +## Add-on Support + +We've made this for our projects really... some may find it useful, but it's not something we're looking to support +beyond what is useful for our projects too. + +But hey, you could always ask - you may have a brilliant idea that we'd love to implement and use too. Say hello. + +## Credits + +- [Marty Friedel](https://github.com/martyf) + +## License + +This addon is licensed under the MIT license. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8bfe267 --- /dev/null +++ b/composer.json @@ -0,0 +1,35 @@ +{ + "name": "mitydigital/supportamic", + "description": "Adds Mity Digital's support features to Statamic.", + "type": "statamic-addon", + "keywords": [ + "statamic", + "support" + ], + "autoload": { + "psr-4": { + "MityDigital\\Supportamic\\": "src" + } + }, + "license": "MIT", + "authors": [ + { + "name": "Marty Friedel" + } + ], + "require": { + "php": "^8.1", + "statamic/cms": "^4.0" + }, + "extra": { + "statamic": { + "name": "Supportamic", + "description": "Adds Mity Digital's support features to Statamic." + }, + "laravel": { + "providers": [ + "MityDigital\\Supportamic\\ServiceProvider" + ] + } + } +} diff --git a/config/supportamic.php b/config/supportamic.php new file mode 100644 index 0000000..abdc51f --- /dev/null +++ b/config/supportamic.php @@ -0,0 +1,58 @@ + [ + 'type' => env('SUPPORTAMIC_CHAT', null), + + 'endpoint' => env('SUPPORTAMIC_CHAT_ENDPOINT', null), + + 'identity' => [ + 'email' => 'email', + 'name' => 'name' + ] + ], + + + /* + |-------------------------------------------------------------------------- + | Widget Settings + |-------------------------------------------------------------------------- + | + | Not all sites have a docs guide - and this is governed by Statamic's STATAMIC_LINK_TO_DOCS + | configuration option in your .env file (if you use it). If you have this set, and want to + | include the "guide" section, make sure SUPPORTAMIC_WIDGET_SHOW_GUIDE is true. + | + | The section will be hidden when false, or if your STATAMIC_SUPPORT_URL starts with "https://statamic.com". + | + | The contact options will appear/disappear automatically based on your configuration. + | + | Chat will be shown if chat is configured above. + | Email will be shown when SUPPORTAMIC_EMAIL is set + | Website will be shown when SUPPORTAMIC_WEBSITE is set + | + */ + 'widget' => [ + 'email' => env('SUPPORTAMIC_EMAIL', null), + + 'show_guide' => env('SUPPORTAMIC_WIDGET_SHOW_GUIDE', false), + + 'website' => env('SUPPORTAMIC_WEBSITE', null), + ] +]; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..8bc727e --- /dev/null +++ b/package-lock.json @@ -0,0 +1,649 @@ +{ + "name": "statamic-support", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "@vitejs/plugin-vue2": "^2.2.0", + "laravel-vite-plugin": "^0.7.2", + "vite": "^4.0.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.22.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.5.tgz", + "integrity": "sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q==", + "dev": true, + "peer": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", + "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@vitejs/plugin-vue2": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue2/-/plugin-vue2-2.2.0.tgz", + "integrity": "sha512-1km7zEuZ/9QRPvzXSjikbTYGQPG86Mq1baktpC4sXqsXlb02HQKfi+fl8qVS703JM7cgm24Ga9j+RwKmvFn90A==", + "dev": true, + "engines": { + "node": "^14.18.0 || >= 16.0.0" + }, + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0", + "vue": "^2.7.0-0" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "2.7.14", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.14.tgz", + "integrity": "sha512-aNmNHyLPsw+sVvlQFQ2/8sjNuLtK54TC6cuKnVzAY93ks4ZBrvwQSnkkIh7bsbNhum5hJBS00wSDipQ937f5DA==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/parser": "^7.18.4", + "postcss": "^8.4.14", + "source-map": "^0.6.1" + } + }, + "node_modules/csstype": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", + "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==", + "dev": true, + "peer": true + }, + "node_modules/esbuild": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", + "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.19", + "@esbuild/android-arm64": "0.17.19", + "@esbuild/android-x64": "0.17.19", + "@esbuild/darwin-arm64": "0.17.19", + "@esbuild/darwin-x64": "0.17.19", + "@esbuild/freebsd-arm64": "0.17.19", + "@esbuild/freebsd-x64": "0.17.19", + "@esbuild/linux-arm": "0.17.19", + "@esbuild/linux-arm64": "0.17.19", + "@esbuild/linux-ia32": "0.17.19", + "@esbuild/linux-loong64": "0.17.19", + "@esbuild/linux-mips64el": "0.17.19", + "@esbuild/linux-ppc64": "0.17.19", + "@esbuild/linux-riscv64": "0.17.19", + "@esbuild/linux-s390x": "0.17.19", + "@esbuild/linux-x64": "0.17.19", + "@esbuild/netbsd-x64": "0.17.19", + "@esbuild/openbsd-x64": "0.17.19", + "@esbuild/sunos-x64": "0.17.19", + "@esbuild/win32-arm64": "0.17.19", + "@esbuild/win32-ia32": "0.17.19", + "@esbuild/win32-x64": "0.17.19" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/laravel-vite-plugin": { + "version": "0.7.8", + "resolved": "https://registry.npmjs.org/laravel-vite-plugin/-/laravel-vite-plugin-0.7.8.tgz", + "integrity": "sha512-HWYqpQYHR3kEQ1LsHX7gHJoNNf0bz5z5mDaHBLzS+PGLCTmYqlU5/SZyeEgObV7z7bC/cnStYcY9H1DI1D5Udg==", + "dev": true, + "dependencies": { + "picocolors": "^1.0.0", + "vite-plugin-full-reload": "^1.0.5" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "vite": "^3.0.0 || ^4.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.4.24", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.24.tgz", + "integrity": "sha512-M0RzbcI0sO/XJNucsGjvWU9ERWxb/ytp1w6dKtxTKgixdtQDq4rmx/g8W1hnaheq9jgwL/oyEdH5Bc4WwJKMqg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "dependencies": { + "nanoid": "^3.3.6", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rollup": { + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", + "integrity": "sha512-tywOR+rwIt5m2ZAWSe5AIJcTat8vGlnPFAv15ycCrw33t6iFsXZ6mzHVFh2psSjxQPmI+xgzMZZizUAukBI4aQ==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/vite": { + "version": "4.3.9", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.3.9.tgz", + "integrity": "sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==", + "dev": true, + "dependencies": { + "esbuild": "^0.17.5", + "postcss": "^8.4.23", + "rollup": "^3.21.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@types/node": ">= 14", + "less": "*", + "sass": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-plugin-full-reload": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/vite-plugin-full-reload/-/vite-plugin-full-reload-1.0.5.tgz", + "integrity": "sha512-kVZFDFWr0DxiHn6MuDVTQf7gnWIdETGlZh0hvTiMXzRN80vgF4PKbONSq8U1d0WtHsKaFODTQgJeakLacoPZEQ==", + "dev": true, + "dependencies": { + "picocolors": "^1.0.0", + "picomatch": "^2.3.1" + }, + "peerDependencies": { + "vite": "^2 || ^3 || ^4" + } + }, + "node_modules/vue": { + "version": "2.7.14", + "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.14.tgz", + "integrity": "sha512-b2qkFyOM0kwqWFuQmgd4o+uHGU7T+2z3T+WQp8UBjADfEv2n4FEMffzBmCKNP0IGzOEEfYjvtcC62xaSKeQDrQ==", + "dev": true, + "peer": true, + "dependencies": { + "@vue/compiler-sfc": "2.7.14", + "csstype": "^3.1.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1891427 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "private": true, + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "devDependencies": { + "@vitejs/plugin-vue2": "^2.2.0", + "laravel-vite-plugin": "^0.7.2", + "vite": "^4.0.0" + } +} diff --git a/resources/css/support.css b/resources/css/support.css new file mode 100644 index 0000000..675f204 --- /dev/null +++ b/resources/css/support.css @@ -0,0 +1,12 @@ +#hubspot-conversations-iframe { + outline:none; +} + +#supportamic-widget .action { + width:20%; +} + +.supportamic-chat-trigger.disabled { + opacity:25%; + pointer-events: none; +} diff --git a/resources/dist/build/assets/support-6d43092d.js b/resources/dist/build/assets/support-6d43092d.js new file mode 100644 index 0000000..d13823f --- /dev/null +++ b/resources/dist/build/assets/support-6d43092d.js @@ -0,0 +1 @@ +function o(i){var t;i.preventDefault(),(t=window.HubSpotConversations)==null||t.widget.open()}function s(){let i=document.getElementsByClassName("supportamic-chat-trigger");for(let t=0;t [ + 'title' => 'Help and Support', + 'intro' => 'Your time with us doesn\'t end when your site is live. We are here to help you.', + + 'guide' => [ + 'title' => 'Admin guide', + 'intro' => 'Have you checked out your admin guide? Most of your day-to-day tasks are covered here.', + 'view' => 'View your admin guide' + ], + + 'support' => [ + 'title' => 'When you need some help, we\'re here for you.', + 'intro' => 'When reporting an issue, please provide as much detail as you can, including what you\'re trying to achieve, what page it can apply to, and any other information that you feel is relevant.', + 'intro_2' => 'If you have a more complicated issue, you may want to email support so you can more easily include links and attachments.', + 'intro_3' => 'What would you like to do?', + + 'action_chat' => 'Start a conversation', + 'action_email' => 'Email support', + 'action_website' => 'Visit support website', + ] + ] +]; diff --git a/resources/svg/conversation.svg b/resources/svg/conversation.svg new file mode 100644 index 0000000..aaad666 --- /dev/null +++ b/resources/svg/conversation.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/resources/svg/email.svg b/resources/svg/email.svg new file mode 100644 index 0000000..652a19b --- /dev/null +++ b/resources/svg/email.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/svg/supportamic.svg b/resources/svg/supportamic.svg new file mode 100644 index 0000000..84889e9 --- /dev/null +++ b/resources/svg/supportamic.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/resources/svg/website.svg b/resources/svg/website.svg new file mode 100644 index 0000000..ce6d6b2 --- /dev/null +++ b/resources/svg/website.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/resources/views/widgets/supportamic.blade.php b/resources/views/widgets/supportamic.blade.php new file mode 100644 index 0000000..9aac5a4 --- /dev/null +++ b/resources/views/widgets/supportamic.blade.php @@ -0,0 +1,89 @@ +
+
+
+

+
+ @supportamic_svg('supportamic') +
+
+
{{ __('supportamic::supportamic.widget.title') }}
+
+

{{ __('supportamic::supportamic.widget.intro') }}

+
+
+

+
+
+ + @if ($showGuide) +
+
+

{{ __('supportamic::supportamic.widget.guide.title') }}

+

{{ __('supportamic::supportamic.widget.guide.intro') }}

+
+ +
+ @endif + + @if ($actionChat || $actionEmail || $actionWebsite) +
+
+

{{ __('supportamic::supportamic.widget.support.title') }}

+

{{ __('supportamic::supportamic.widget.support.intro') }}

+

{{ __('supportamic::supportamic.widget.support.intro_2') }}

+

{{ __('supportamic::supportamic.widget.support.intro_3') }}

+
+ +
+ + @if ($actionChat) +
+ +
+ @endif + + @if ($actionEmail) + + @endif + + @if ($actionWebsite) + + @endif +
+ +
+ @endif +
diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php new file mode 100644 index 0000000..05d95a7 --- /dev/null +++ b/src/ServiceProvider.php @@ -0,0 +1,79 @@ + [ + 'resources/js/support.js', + 'resources/css/support.css' + ], + 'publicDirectory' => 'resources/dist', + ]; + + protected $widgets = [ + Supportamic::class + ]; + + public function bootAddon() + { + // publishable views + $this->publishes([ + __DIR__.'/../resources/views' => resource_path('views/vendor/supportamic'), + ], 'supportamic-views'); + + // boot supportamic + $this->bootSupportamic(); + } + + protected function bootSupportamic() { + // + // CONFIGURE CHAT + // Only run if we are a CP route + // + if (Statamic::isCpRoute()) { + + if (!\MityDigital\Supportamic\Support\Supportamic::hasChat()) + { + return $this; // just return + } + + // what sort of chat are we meant to use? + $engine = config('supportamic.chat.type'); + + switch ($engine) { + case 'hubspot': + /* + * Hubspot requires a chat endpoint, so let's make sure we have that. + */ + $key = 'supportamic.chat.endpoint'; + if (!config($key)) { + throw new \Exception('Missing config value for '.$key.'. HubSpot requires this.'); + } + + // pass the config options to + Statamic::provideToScript([ + 'supportamic' => [ + 'chat' => [ + 'type' => $engine, + 'endpoint' => config($key), + 'identity' => [ + 'email' => config('supportamic.chat.identity.email', null), + 'name' => config('supportamic.chat.identity.name', null) + ] + ], + ] + ]); + break; + } + } + + return $this; + } + +} diff --git a/src/Support/Supportamic.php b/src/Support/Supportamic.php new file mode 100644 index 0000000..755c20a --- /dev/null +++ b/src/Support/Supportamic.php @@ -0,0 +1,48 @@ +"; + }); + + // should we show the guide + $showGuide = config('supportamic.widget.show_guide', false); + $actionGuide = config('statamic.cp.support_url', false); + if (!$actionGuide || str_starts_with($actionGuide, 'https://statamic.com')) + { + $showGuide = false; + $actionGuide = null; + } + + // do we have chat configured? + $actionChat = \MityDigital\Supportamic\Support\Supportamic::hasChat(); + + // do we have contact options for email and website? + $actionEmail = config('supportamic.widget.email', null); + $actionWebsite = config('supportamic.widget.website', null); + + // should we show the widget? + // if there is nothing to show, return nothing + if (!$showGuide && !$actionChat && !$actionEmail && !$actionWebsite) { + return; + } + + return view('supportamic::widgets.supportamic', [ + 'showGuide' => $showGuide, + + 'actionChat' => $actionChat, + 'actionGuide' => $actionGuide, + 'actionEmail' => $actionEmail, + 'actionWebsite' => $actionWebsite + ]); + } +} diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000..438d908 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,16 @@ +import { defineConfig } from 'vite'; +import laravel from 'laravel-vite-plugin'; +import vue from '@vitejs/plugin-vue2'; + +export default defineConfig({ + plugins: [ + laravel({ + input: [ + 'resources/js/support.js', + 'resources/css/support.css' + ], + publicDirectory: 'resources/dist', + }), + vue(), + ], +});