From 35cb9d0de8fd53123a71c260517bd116f0b05a6e Mon Sep 17 00:00:00 2001 From: Ben Croker Date: Tue, 26 Mar 2024 20:48:17 -0600 Subject: [PATCH] Fix site selector dropdown --- .gitattributes | 1 - .github/ISSUE_TEMPLATE/bug-report.yaml | 42 +++++++++++ .github/ISSUE_TEMPLATE/bug_report.md | 14 ---- .github/ISSUE_TEMPLATE/config.yml | 1 + .github/ISSUE_TEMPLATE/feature-request.yaml | 25 ++++++ .github/ISSUE_TEMPLATE/feature_request.md | 12 --- .github/ISSUE_TEMPLATE/support-request.md | 10 --- .github/ISSUE_TEMPLATE/support-request.yaml | 23 ++++++ CHANGELOG-WIP.md | 21 ++++++ CHANGELOG.md | 12 +++ README.md | 4 +- composer.json | 18 ++--- src/templates/index.twig | 84 +++++++-------------- 13 files changed, 162 insertions(+), 105 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yaml delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yaml delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/ISSUE_TEMPLATE/support-request.md create mode 100644 .github/ISSUE_TEMPLATE/support-request.yaml create mode 100644 CHANGELOG-WIP.md diff --git a/.gitattributes b/.gitattributes index bc9464c..1e5c2bb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,7 +3,6 @@ /.github/ export-ignore /.gitignore export-ignore /ecs.php export-ignore -/codeception.yml export-ignore /phpstan.neon export-ignore /tests/ export-ignore diff --git a/.github/ISSUE_TEMPLATE/bug-report.yaml b/.github/ISSUE_TEMPLATE/bug-report.yaml new file mode 100644 index 0000000..fc50801 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yaml @@ -0,0 +1,42 @@ +name: Bug Report +description: Create a bug report for this plugin. +labels: + - bug +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to submit a bug report! To ensure this hasn’t already been reported, please first search existing issues. + + To rule out that this isn’t a setup or configuration issue, please read the docs. + + If you still believe you’ve found a bug, please provide a clear and concise description, including: + - What is happening and what you expected to happen. + - Steps to reproduce the issue. + - Screenshots, if applicable. + - type: textarea + id: body + attributes: + label: Bug Report + description: Please provide a clear and concise description of the bug. + validations: + required: true + - type: input + id: pluginVersion + attributes: + label: Plugin Version + description: Provide the plugin version that this relates to, ideally the latest version. + validations: + required: true + - type: input + id: craftVersion + attributes: + label: Craft CMS Version + description: Provide the version of Craft that is installed. + validations: + required: true + - type: input + id: phpVersion + attributes: + label: PHP Version + description: Provide the PHP version, if applicable. diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 2a45da2..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -name: Bug report -about: Create a bug report for this plugin. -title: '' -labels: bug -assignees: '' - ---- - -Please provide a clear and concise description of what the bug is, including: -- Steps to reproduce the issue. -- A clear and concise description of what you expected to happen. -- If applicable, add screenshots to help explain your problem. -- The plugin and Craft version numbers. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..3ba13e0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/feature-request.yaml b/.github/ISSUE_TEMPLATE/feature-request.yaml new file mode 100644 index 0000000..12c2c68 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yaml @@ -0,0 +1,25 @@ +name: Feature Request +description: Suggest a new feature for this plugin. +labels: + - enhancement +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to submit a feature request! To ensure this isn’t already on our radar, please first search existing issues. + + If you still believe you have a new suggestion, please provide a clear and concise description, including: + - What problem you believe your feature request can solve. + - Any alternative solutions or features you have already considered. + - type: textarea + id: body + attributes: + label: Feature Request + description: Please provide a clear and concise suggestion for a feature. + validations: + required: true + - type: input + id: pluginVersion + attributes: + label: Plugin Version + description: Provide the plugin version that this relates to, ideally the latest version. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index bd44c9d..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -name: Feature request -about: Suggest a feature for this plugin. -title: '' -labels: enhancement -assignees: '' - ---- - -Please provide a clear and concise description of your feature request, including: -- What the problem is and what you would like to have happen. -- Any alternative solutions or features you have considered. diff --git a/.github/ISSUE_TEMPLATE/support-request.md b/.github/ISSUE_TEMPLATE/support-request.md deleted file mode 100644 index 5a675ed..0000000 --- a/.github/ISSUE_TEMPLATE/support-request.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Support request -about: Ask a question about this plugin. -title: '' -labels: question -assignees: '' - ---- - -Please provide a clear and concise question. We are diligent about documentation, so please check whether your question is answered by the plugin docs before submitting. diff --git a/.github/ISSUE_TEMPLATE/support-request.yaml b/.github/ISSUE_TEMPLATE/support-request.yaml new file mode 100644 index 0000000..688f303 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support-request.yaml @@ -0,0 +1,23 @@ +name: Support Request +description: Ask a question about this plugin. +labels: + - question +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to submit a support request! To ensure your question hasn’t already been asked and answered, please first search existing issues. + + If your question is still unanswered, please provide a clear and concise description. Note that we are diligent about documentation, so please check whether your question is answered by the plugin docs before submitting. + - type: textarea + id: body + attributes: + label: Support Request + description: Please provide a clear and concise question. + validations: + required: true + - type: input + id: pluginVersion + attributes: + label: Plugin Version + description: Provide the plugin version that this relates to, ideally the latest version. diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md new file mode 100644 index 0000000..cdc9ab5 --- /dev/null +++ b/CHANGELOG-WIP.md @@ -0,0 +1,21 @@ +# Release Notes for Sprig + +## 3.0.0 - Unreleased + +> {warning} Template caches and static page caches should be cleared after performing this update. + +### Added + +- Added compatibility with Craft 5.0.0. + +### Changed + +- Changed how the component configuration is encoded. + +### Removed + +- Removed the `sprig.script` variable. +- Removed the `s-on` attribute. +- Removed the `success` variable. Use `sprig.isSuccess` or `sprig.isError` instead. +- Removed the `flashes` variable. Use `sprig.message` or `craft.app.session.flash()` instead. +- Removed the `id` variable. Use `sprig.modelId` instead. diff --git a/CHANGELOG.md b/CHANGELOG.md index d36ff52..482e87b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Release Notes for Sprig +## 3.0.0-beta.2 - 2024-03-26 + +### Fixed + +- Fixed the site selector dropdown. + +### Removed + +- Removed the `success` variable. Use `sprig.isSuccess` or `sprig.isError` instead. +- Removed the `flashes` variable. Use `sprig.message` or `craft.app.session.flash()` instead. +- Removed the `id` variable. Use `sprig.modelId` instead. + ## 3.0.0-beta.1 - 2024-02-14 > {warning} Template caches and static page caches should be cleared after performing this update. diff --git a/README.md b/README.md index 0726946..6e75284 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ### A reactive Twig component framework for Craft CMS. -Sprig is a free plugin for [Craft CMS](https://craftcms.com/) that allows you to create reactive components from Twig templates and/or PHP classes. These components can re-render themselves on user-triggered events (clicks, changes to input fields, form submissions, etc.) using AJAX requests, without requiring you to write a single line of JavaScript. +Sprig is a free plugin for [Craft CMS](https://craftcms.com/) that allows you to create reactive components from Twig templates and/or PHP classes. These components can re-render themselves on user-triggered events (clicks, changes to input fields, form submissions, etc.) using AJAX requests, without requiring you to write a single line of JavaScript. Sprig enables common use-cases such as the following while completely avoiding full page refreshes: @@ -31,7 +31,7 @@ This plugin is licensed for free under the MIT License. ## Requirements -This plugin requires [Craft CMS](https://craftcms.com/) 3.1.19 or later, or 4.0.0 or later. +This plugin requires [Craft CMS](https://craftcms.com/) 3.1.19 or later, or 4.0.0 or later, or 5.0.0 or later. ## Installation diff --git a/composer.json b/composer.json index d63c917..1099c28 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,29 @@ { "name": "putyourlightson/craft-sprig", "description": "A reactive Twig component framework for Craft.", - "version": "3.0.0-beta.1", + "version": "3.0.0-beta.2", "type": "craft-plugin", "license": "mit", "require": { "php": "^8.2", - "craftcms/cms": "^5.0.0-beta.1", + "craftcms/cms": "^5.0.0", "nystudio107/craft-code-editor": "^1.0.0", - "putyourlightson/craft-sprig-core": "^3.0.0-beta.1" + "putyourlightson/craft-sprig-core": "^3.0.0-beta.2" }, "require-dev": { "craftcms/ecs": "dev-main", "craftcms/phpstan": "dev-main" }, - "scripts": { - "phpstan": "phpstan --ansi --memory-limit=1G", - "check-cs": "ecs check --ansi", - "fix-cs": "ecs check --fix --ansi" - }, "autoload": { "psr-4": { "putyourlightson\\sprig\\plugin\\": "src/" } }, + "scripts": { + "phpstan": "phpstan --ansi --memory-limit=1G", + "check-cs": "ecs check --ansi", + "fix-cs": "ecs check --fix --ansi" + }, "config": { "allow-plugins": { "craftcms/plugin-installer": true, @@ -44,7 +44,7 @@ "developer": "PutYourLightsOn", "developerUrl": "https://putyourlightson.com/", "documentationUrl": "https://putyourlightson.com/plugins/sprig", - "changelogUrl": "https://raw.githubusercontent.com/putyourlightson/craft-sprig/v2/CHANGELOG.md", + "changelogUrl": "https://raw.githubusercontent.com/putyourlightson/craft-sprig/v3/CHANGELOG.md", "class": "putyourlightson\\sprig\\plugin\\Sprig" } } diff --git a/src/templates/index.twig b/src/templates/index.twig index f2ca4ff..a9c8d9f 100644 --- a/src/templates/index.twig +++ b/src/templates/index.twig @@ -7,76 +7,54 @@ {% set bundle = view.registerAssetBundle('putyourlightson\\sprig\\plugin\\assets\\PlaygroundAsset') %} {% set resourcesUrl = bundle.baseUrl %} -{% block pageTitle %} +{% set crumbs = [{ + label: playground ? playground.name : 'Components'|t('sprig'), + menu: { + items: [ + { + heading: 'Sample Components'|t('sprig'), + items: allSamples|map(sample => { + label: sample.name, + url: 'sprig/' ~ sample.slug, + selected: sample.slug == slug, + }) + }, + { + heading: 'Saved Components'|t('sprig'), + items: allSaved|map(saved => { + label: saved.name, + url: 'sprig/' ~ saved.id, + selected: saved.id == playground.id ?? null, + }) + }, + ], + }, +}] %} +{% block pageTitle %}
{{ svg(craft.app.plugins.getPluginIconSvg('sprig')) }}
- {{ parent() }} - -{% endblock %} - -{% block contextMenu %} - -
- - -
- - {% if not craft.app.config.general.devMode %} + {% if craft.app.config.general.devMode %} {{ 'Enable `devMode` to see Twig template errors.'|t('sprig')|markdown }} {% endif %} - {% endblock %} - {% block actionButton %} -
- {{ csrfInput() }} -
{{ 'Learning Resources'|t('sprig') }} - {% if playground and not slug %}
{% endif %}
- - {% endblock %} - {% block main %} -

{{ 'Component Variables'|t('sprig') }}

{% set variables = playground ? playground.variables : '' %} - +

{{ 'Component'|t('sprig') }}

@@ -137,7 +110,6 @@
-

{{ 'Output Variables'|t('sprig') }}

@@ -156,9 +128,7 @@
- {% js %} - let resourcesUrl = '{{ resourcesUrl }}'; + let resourcesUrl = '{{ resourcesUrl }}'; {% endjs %} - {% endblock %}