diff --git a/.editorconfig b/.editorconfig index 2ca82c5eee..daa51f26a7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,6 +7,7 @@ insert_final_newline = true indent_style = space indent_size = 2 trim_trailing_whitespace = true +quote_type = single [*.md] trim_trailing_whitespace = false diff --git a/.github/labeler.yml b/.github/labeler.yml index 557156db29..c20a60dbcc 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,21 +1,27 @@ build: -- .eslintrc.js -- .prettierrc -- .stylelintrc -- bud.config.js -- tsconfig.json - + - changed-files: + - any-glob-to-any-file: + - .eslintrc.js + - .prettierrc + - .stylelintrc + - bud.config.js + - tsconfig.json dependencies: -- yarn.lock - + - changed-files: + - any-glob-to-any-file: + - yarn.lock javascript: -- resources/scripts/**/*.js - + - changed-files: + - any-glob-to-any-file: + - resources/scripts/**/*.js php: -- functions.php -- app/**/*.php -- resources/views/**/*.php - + - changed-files: + - any-glob-to-any-file: + - functions.php + - app/**/*.php + - resources/views/**/*.php views: -- index.php -- resources/views/**/*.php + - changed-files: + - any-glob-to-any-file: + - index.php + - resources/views/**/*.php diff --git a/.github/renovate.json b/.github/renovate.json index 9864c0890d..fbbea0eaf4 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -1,17 +1,17 @@ { "baseBranches": ["main"], - "commitMessageAction": "Bump", - "commitMessageTopic": "📦 update {{depName}}", - "extends": ["config:base", "schedule:daily"], + "commitMessageAction": "⬆️ Bump", + "commitMessageTopic": "{{depName}}", + "extends": ["config:base", "schedule:weekly"], "packageRules": [ { - "automerge": true, "matchUpdateTypes": ["minor", "patch", "pin"] }, { - "groupName": "roots", - "matchPackagePrefixes": ["@roots/"] + "groupName": "Bud", + "matchPackagePrefixes": ["@roots/"], + "schedule": ["at any time"] } ], - "timezone": "America/Los_Angeles" + "timezone": "America/Chicago" } diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 31e78f82a6..80bba040d0 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -6,6 +6,6 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16206eec09..cbcbcff52e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,29 +15,20 @@ jobs: if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: - node: ['16'] + node: ['20'] steps: - name: Checkout the project - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup the Node ${{ matrix.node }} environment on ${{ runner.os }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} + cache: 'yarn' env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Restore the Yarn cache directory - id: yarncache - run: echo "::set-output name=dir::$(yarn cache dir)" - - - uses: actions/cache@v3 - with: - path: ${{ steps.yarncache.outputs.dir }} - key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: ${{ runner.os }}-${{ matrix.node }}-yarn- - - name: Install dependencies using Yarn run: yarn install --frozen-lockfile @@ -53,11 +44,11 @@ jobs: if: "!contains(github.event.head_commit.message, '[ci skip]')" strategy: matrix: - php: ['7.4', '8.0', '8.1'] + php: ['8.1', '8.2'] steps: - name: Checkout the project - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup the PHP ${{ matrix.php }} environment on ${{ runner.os }} uses: shivammathur/setup-php@v2 @@ -65,13 +56,13 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Restore the Composer cache directory id: composercache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: ${{ steps.composercache.outputs.dir }} key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} @@ -80,5 +71,5 @@ jobs: - name: Install Composer dependencies run: composer install --no-progress --prefer-dist --optimize-autoloader --no-suggest - - name: Execute the PHP lint script - run: composer run-script lint + - name: Run Pint + run: vendor/bin/pint --test diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index a27aab935e..0000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,68 +0,0 @@ -## HEAD - -* [Full changelog](https://github.com/roots/sage/compare/v10.2.0...main) - -## 10.2.0: July 19th, 2022 - -* [Full changelog](https://github.com/roots/sage/compare/v10.1.7...v10.2.0) - -## 10.1.7: May 30th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.7) -* [Full changelog](https://github.com/roots/sage/compare/v10.1.6...v10.1.7) - - -## 10.1.6: March 30th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.6) -* [Full changelog](https://github.com/roots/sage/compare/v10.1.5...v10.1.6) - -## 10.1.5: March 29th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.5) -* [Full changelog](https://github.com/roots/sage/compare/v10.1.4...v10.1.5) - -## 10.1.4: March 27th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.4) -* [Full changelog](https://github.com/roots/sage/compare/v10.1.3...v10.1.4) - -## 10.1.3: March 25th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.3) -* [Full changelog](https://github.com/roots/sage/compare/v10.1.2...v10.1.3) - -## 10.1.2: March 17th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.2) -* [Full changelog](https://github.com/roots/sage/compare/v10.1.1...v10.1.2) - -## 10.1.1: March 9th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.1) -* [Full changelog](https://github.com/roots/sage/compare/v10.0.1...v10.1.1) - -## 10.1.0: March 8th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.1.0) -* [Full changelog](https://github.com/roots/sage/compare/v10.0.0...v10.1.0) - -## 10.0.0: March 1st, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/v10.0.0) -* [Full changelog](https://github.com/roots/sage/compare/10.0.0-beta.3...v10.0.0) - -## 10.0.0-beta.3: February 14th, 2022 - -* [Release notes](https://github.com/roots/sage/releases/tag/10.0.0-beta.3) -* [Full changelog](https://github.com/roots/sage/compare/10.0.0-beta.2...10.0.0-beta.3) - -## 10.0.0-beta.2: December 21st, 2021 - -* [Release notes](https://github.com/roots/sage/releases/tag/10.0.0-beta.2) -* [Full changelog](https://github.com/roots/sage/compare/10.0.0-beta.1...10.0.0-beta.2) - -## 10.0.0-beta.1: October 21st, 2021 - -* [Release notes](https://github.com/roots/sage/releases/tag/10.0.0-beta.1) -* [Full changelog](https://github.com/roots/sage/compare/9.0.9...10.0.0-beta.1) diff --git a/README.md b/README.md index 0978fafe72..d99f229086 100644 --- a/README.md +++ b/README.md @@ -5,133 +5,50 @@

- - MIT License - - - Packagist + Packagist Installs - - Build Status + + Build Status - Follow Roots + Follow Roots

-

- WordPress starter theme with Laravel Blade components and templates, Tailwind CSS, and a modern development workflow -

+

Advanced WordPress starter theme with Tailwind CSS and Laravel Blade

- Website    Documentation    Releases    Support + Website    Documentation    Releases    Community

## Sponsors -**Sage** is an open source project and completely free to use. - -However, the amount of effort needed to maintain and develop new features and products within the Roots ecosystem is not sustainable without proper financial backing. If you have the capability, please consider [sponsoring Roots](https://github.com/sponsors/roots). - -

Sponsor Roots

+Sage is an open source project and completely free to use. If you've benefited from our projects and would like to support our future endeavors, please consider [sponsoring Roots](https://github.com/sponsors/roots).
-KM Digital Carrot C21 Redwood Realty WordPress.com - -Icons8 Genero 40Q Pantheon +KM Digital Carrot WordPress.com Worksite Safety 40Q Itineris
+## Overview -## Features - -- Harness the power of [Laravel](https://laravel.com) and its available packages thanks to [Acorn](https://github.com/roots/acorn). -- Clean, efficient theme templating utilizing [Laravel Blade](https://laravel.com/docs/master/blade). -- Lightning fast frontend development workflow powered by [Bud](https://bud.js.org/). -- Out of the box support for [Tailwind CSS](https://tailwindcss.com/). - -## Requirements - -Make sure all dependencies have been installed before moving on: - -- [Acorn](https://docs.roots.io/acorn/2.x/installation/) v2 -- [WordPress](https://wordpress.org/) >= 5.9 -- [PHP](https://secure.php.net/manual/en/install.php) >= 7.4.0 (with [`php-mbstring`](https://secure.php.net/manual/en/book.mbstring.php) enabled) -- [Composer](https://getcomposer.org/download/) -- [Node.js](http://nodejs.org/) >= 16 -- [Yarn](https://yarnpkg.com/en/docs/install) - -## Theme installation - -Install Sage using Composer from your WordPress themes directory (replace `your-theme-name` below with the name of your theme): - -```sh -# @ app/themes/ or wp-content/themes/ -$ composer create-project roots/sage your-theme-name -``` - -To install the latest development version of Sage, add `dev-main` to the end of the command: - -```sh -$ composer create-project roots/sage your-theme-name dev-main -``` - -Make sure that you have [Acorn installed](https://docs.roots.io/acorn/2.x/installation/). - -## Theme structure - -```sh -themes/your-theme-name/ # → Root of your Sage based theme -├── app/ # → Theme PHP -│ ├── Providers/ # → Service providers -│ ├── View/ # → View models -│ ├── filters.php # → Theme filters -│ └── setup.php # → Theme setup -├── composer.json # → Autoloading for `app/` files -├── public/ # → Built theme assets (never edit) -├── functions.php # → Theme bootloader -├── index.php # → Theme template wrapper -├── node_modules/ # → Node.js packages (never edit) -├── package.json # → Node.js dependencies and scripts -├── resources/ # → Theme assets and templates -│ ├── fonts/ # → Theme fonts -│ ├── images/ # → Theme images -│ ├── scripts/ # → Theme javascript -│ ├── styles/ # → Theme stylesheets -│ └── views/ # → Theme templates -│ ├── components/ # → Component templates -│ ├── forms/ # → Form templates -│ ├── layouts/ # → Base templates -│ ├── partials/ # → Partial templates - └── sections/ # → Section templates -├── screenshot.png # → Theme screenshot for WP admin -├── style.css # → Theme meta information -├── vendor/ # → Composer packages (never edit) -└── bud.config.js # → Bud configuration -``` - -## Theme setup - -Edit `app/setup.php` to enable or disable theme features, setup navigation menus, post thumbnail sizes, and sidebars. - -## Theme development - -- Run `yarn` from the theme directory to install dependencies -- Update `bud.config.js` with your local dev URL +Sage is a WordPress starter theme with block editor support. -### Build commands +- Harness the power of [Laravel](https://laravel.com) and its available packages thanks to [Acorn](https://github.com/roots/acorn) +- Clean, efficient theme templating utilizing [Laravel Blade](https://laravel.com/docs/master/blade) +- Modern frontend development workflow powered by [Bud](https://bud.js.org/) +- Out of the box support for [Tailwind CSS](https://tailwindcss.com/) -- `yarn dev` — Compile assets when file changes are made, start Browsersync session -- `yarn build` — Compile assets for production +## Getting Started -## Community +See the [Sage installation documentation](https://roots.io/sage/docs/installation/). -Keep track of development and community news. +## Stay Connected - Join us on Discord by [sponsoring us on GitHub](https://github.com/sponsors/roots) -- Participate on the [Roots Discourse](https://discourse.roots.io/) +- Participate on [Roots Discourse](https://discourse.roots.io/) - Follow [@rootswp on Twitter](https://twitter.com/rootswp) -- Read and subscribe to the [Roots Blog](https://roots.io/blog/) -- Subscribe to the [Roots Newsletter](https://roots.io/subscribe/) +- Read the [Roots Blog](https://roots.io/blog/) +- Subscribe to the [Roots Newsletter](https://roots.io/newsletter/) diff --git a/app/Providers/ThemeServiceProvider.php b/app/Providers/ThemeServiceProvider.php index 1d50cb4e1d..cb0d25eece 100644 --- a/app/Providers/ThemeServiceProvider.php +++ b/app/Providers/ThemeServiceProvider.php @@ -2,9 +2,9 @@ namespace App\Providers; -use Roots\Acorn\ServiceProvider; +use Roots\Acorn\Sage\SageServiceProvider; -class ThemeServiceProvider extends ServiceProvider +class ThemeServiceProvider extends SageServiceProvider { /** * Register any application services. @@ -13,7 +13,7 @@ class ThemeServiceProvider extends ServiceProvider */ public function register() { - // + parent::register(); } /** @@ -23,6 +23,6 @@ public function register() */ public function boot() { - // + parent::boot(); } } diff --git a/app/View/Components/Alert.php b/app/View/Components/Alert.php deleted file mode 100644 index fa860df66b..0000000000 --- a/app/View/Components/Alert.php +++ /dev/null @@ -1,57 +0,0 @@ - 'text-indigo-50 bg-indigo-400', - 'success' => 'text-green-50 bg-green-400', - 'caution' => 'text-yellow-50 bg-yellow-400', - 'warning' => 'text-red-50 bg-red-400', - ]; - - /** - * Create the component instance. - * - * @param string $type - * @param string $message - * @return void - */ - public function __construct($type = 'default', $message = null) - { - $this->type = $this->types[$type] ?? $this->types['default']; - $this->message = $message; - } - - /** - * Get the view / contents that represent the component. - * - * @return \Illuminate\View\View|string - */ - public function render() - { - return $this->view('components.alert'); - } -} diff --git a/app/View/Composers/Comments.php b/app/View/Composers/Comments.php new file mode 100644 index 0000000000..748d3a3f8d --- /dev/null +++ b/app/View/Composers/Comments.php @@ -0,0 +1,119 @@ + $this->title(), + 'responses' => $this->responses(), + 'previous' => $this->previous(), + 'next' => $this->next(), + 'paginated' => $this->paginated(), + 'closed' => $this->closed(), + ]; + } + + /** + * The comment title. + * + * @return string + */ + public function title() + { + return sprintf( + /* translators: %1$s is replaced with the number of comments and %2$s with the post title */ + _nx('%1$s response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'sage'), + get_comments_number() === 1 ? _x('One', 'comments title', 'sage') : number_format_i18n(get_comments_number()), + get_the_title() + ); + } + + /** + * Retrieve the comments. + * + * @return string + */ + public function responses() + { + if (! have_comments()) { + return; + } + + return wp_list_comments([ + 'style' => 'ol', + 'short_ping' => true, + 'echo' => false, + ]); + } + + /** + * The previous comments link. + * + * @return string + */ + public function previous() + { + if (! get_previous_comments_link()) { + return; + } + + return get_previous_comments_link( + __('← Older comments', 'sage') + ); + } + + /** + * The next comments link. + * + * @return string + */ + public function next() + { + if (! get_next_comments_link()) { + return; + } + + return get_next_comments_link( + __('Newer comments →', 'sage') + ); + } + + /** + * Determine if the comments are paginated. + * + * @return bool + */ + public function paginated() + { + return get_comment_pages_count() > 1 && get_option('page_comments'); + } + + /** + * Determine if the comments are closed. + * + * @return bool + */ + public function closed() + { + return ! comments_open() && get_comments_number() != '0' && post_type_supports(get_post_type(), 'comments'); + } +} diff --git a/app/View/Composers/Post.php b/app/View/Composers/Post.php index 0d3987918b..3366b0d439 100644 --- a/app/View/Composers/Post.php +++ b/app/View/Composers/Post.php @@ -26,11 +26,12 @@ public function override() { return [ 'title' => $this->title(), + 'pagination' => $this->pagination(), ]; } /** - * Returns the post title. + * Retrieve the post title. * * @return string */ @@ -66,4 +67,18 @@ public function title() return get_the_title(); } + + /** + * Retrieve the pagination links. + * + * @return string + */ + public function pagination() + { + return wp_link_pages([ + 'echo' => 0, + 'before' => '

'.__('Pages:', 'sage'), + 'after' => '

', + ]); + } } diff --git a/app/setup.php b/app/setup.php index fe33dc4941..695a7b37e6 100644 --- a/app/setup.php +++ b/app/setup.php @@ -32,18 +32,6 @@ * @return void */ add_action('after_setup_theme', function () { - /** - * Enable features from the Soil plugin if activated. - * - * @link https://roots.io/plugins/soil/ - */ - add_theme_support('soil', [ - 'clean-up', - 'nav-walker', - 'nice-search', - 'relative-urls', - ]); - /** * Disable full-site editing support. * @@ -84,7 +72,7 @@ /** * Enable responsive embed support. * - * @link https://wordpress.org/gutenberg/handbook/designers-developers/developers/themes/theme-support/#responsive-embedded-content + * @link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#responsive-embedded-content */ add_theme_support('responsive-embeds'); @@ -106,7 +94,7 @@ /** * Enable selective refresh for widgets in customizer. * - * @link https://developer.wordpress.org/themes/advanced-topics/customizer-api/#theme-support-in-sidebars + * @link https://developer.wordpress.org/reference/functions/add_theme_support/#customize-selective-refresh-widgets */ add_theme_support('customize-selective-refresh-widgets'); }, 20); diff --git a/bud.config.js b/bud.config.js new file mode 100644 index 0000000000..51948e7b98 --- /dev/null +++ b/bud.config.js @@ -0,0 +1,80 @@ +/** + * Compiler configuration + * + * @see {@link https://roots.io/sage/docs sage documentation} + * @see {@link https://bud.js.org/learn/config bud.js configuration guide} + * + * @type {import('@roots/bud').Config} + */ +export default async (app) => { + /** + * Application assets & entrypoints + * + * @see {@link https://bud.js.org/reference/bud.entry} + * @see {@link https://bud.js.org/reference/bud.assets} + */ + app + .entry('app', ['@scripts/app', '@styles/app']) + .entry('editor', ['@scripts/editor', '@styles/editor']) + .assets(['images']); + + /** + * Set public path + * + * @see {@link https://bud.js.org/reference/bud.setPublicPath} + */ + app.setPublicPath('/app/themes/sage/public/'); + + /** + * Development server settings + * + * @see {@link https://bud.js.org/reference/bud.setUrl} + * @see {@link https://bud.js.org/reference/bud.setProxyUrl} + * @see {@link https://bud.js.org/reference/bud.watch} + */ + app + .setUrl('http://localhost:3000') + .setProxyUrl('http://example.test') + .watch(['resources/views', 'app']); + + /** + * Generate WordPress `theme.json` + * + * @note This overwrites `theme.json` on every build. + * + * @see {@link https://bud.js.org/extensions/sage/theme.json} + * @see {@link https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json} + */ + app.wpjson + .setSettings({ + background: { + backgroundImage: true, + }, + color: { + custom: false, + customDuotone: false, + customGradient: false, + defaultDuotone: false, + defaultGradients: false, + defaultPalette: false, + duotone: [], + }, + custom: { + spacing: {}, + typography: { + 'font-size': {}, + 'line-height': {}, + }, + }, + spacing: { + padding: true, + units: ['px', '%', 'em', 'rem', 'vw', 'vh'], + }, + typography: { + customFontSize: false, + }, + }) + .useTailwindColors() + .useTailwindFontFamily() + .useTailwindFontSize(); +}; diff --git a/bud.config.mjs b/bud.config.mjs deleted file mode 100644 index 4b7f37db61..0000000000 --- a/bud.config.mjs +++ /dev/null @@ -1,43 +0,0 @@ -// @ts-check - -/** - * Build configuration - * - * @see {@link https://bud.js.org/guides/getting-started/configure} - * @param {import('@roots/bud').Bud} app - */ -export default async (app) => { - app - /** - * Application entrypoints - */ - .entry({ - app: ["@scripts/app", "@styles/app"], - editor: ["@scripts/editor", "@styles/editor"], - }) - - /** - * Directory contents to be included in the compilation - */ - .assets(["images"]) - - /** - * Matched files trigger a page reload when modified - */ - .watch(["resources/views/**/*", "app/**/*"]) - - /** - * Proxy origin (`WP_HOME`) - */ - .proxy("http://example.test") - - /** - * Development origin - */ - .serve("http://0.0.0.0:3000") - - /** - * URI of the `public` directory - */ - .setPublicPath("/app/themes/sage/public/"); -}; diff --git a/composer.json b/composer.json index e62a3a6d6a..97e64d1565 100644 --- a/composer.json +++ b/composer.json @@ -39,14 +39,13 @@ } }, "require": { - "php": "^7.4|^8.0" + "php": ">=8.1" }, "require-dev": { - "squizlabs/php_codesniffer": "3.7.1" + "laravel/pint": "^1.13" }, "suggest": { - "log1x/sage-directives": "A collection of useful Blade directives for WordPress and Sage (^1.0).", - "log1x/sage-svg": "A useful SVG directive for inlining SVG's within Blade views (^1.0)." + "log1x/sage-directives": "A collection of useful Blade directives for WordPress and Sage (^1.0)." }, "config": { "optimize-autoloader": true, @@ -55,11 +54,6 @@ }, "minimum-stability": "dev", "prefer-stable": true, - "scripts": { - "lint": [ - "phpcs --extensions=php --standard=PSR12 app" - ] - }, "extra": { "acorn": { "providers": [ diff --git a/functions.php b/functions.php index 72b371b161..9b1b0c0947 100644 --- a/functions.php +++ b/functions.php @@ -29,19 +29,19 @@ | */ -try { - \Roots\bootloader(); -} catch (Throwable $e) { +if (! function_exists('\Roots\bootloader')) { wp_die( __('You need to install Acorn to use this theme.', 'sage'), '', [ - 'link_url' => 'https://docs.roots.io/acorn/2.x/installation/', + 'link_url' => 'https://roots.io/acorn/docs/installation/', 'link_text' => __('Acorn Docs: Installation', 'sage'), ] ); } +\Roots\bootloader()->boot(); + /* |-------------------------------------------------------------------------- | Register Sage Theme Files @@ -63,17 +63,3 @@ ); } }); - -/* -|-------------------------------------------------------------------------- -| Enable Sage Theme Support -|-------------------------------------------------------------------------- -| -| Once our theme files are registered and available for use, we are almost -| ready to boot our application. But first, we need to signal to Acorn -| that we will need to initialize the necessary service providers built in -| for Sage when booting. -| -*/ - -add_theme_support('sage'); diff --git a/index.php b/index.php index 2738f4a997..edc07f1a98 100644 --- a/index.php +++ b/index.php @@ -1,20 +1,3 @@ - -> - - - - - +> - - - -
- render(); ?> -
- - - - - +echo view(app('sage.view'), app('sage.data'))->render(); diff --git a/jsconfig.json b/jsconfig.json index 65d57f29dc..f76465600e 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -1,19 +1,34 @@ { + "extends": [ + "@roots/bud/config/jsconfig.json", + "@roots/sage/config/jsconfig.json" + ], "compilerOptions": { - "allowSyntheticDefaultImports": true, "baseUrl": "resources", - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "module": "esnext", - "moduleResolution": "node", - "jsx": "preserve", + /** + * Resolve aliases + */ "paths": { "@fonts/*": ["fonts/*"], "@images/*": ["images/*"], "@scripts/*": ["scripts/*"], "@styles/*": ["styles/*"] }, - "target": "es5" + /** + * Type definitions + */ + "types": [ + "@roots/bud", + "@roots/bud-react", + "@roots/bud-postcss", + "@roots/bud-preset-recommend", + "@roots/bud-preset-wordpress", + "@roots/bud-tailwindcss", + "@roots/bud-wordpress-theme-json", + "@roots/sage" + ] }, - "include": ["bud.config.mjs", "resources"], - "exclude": ["public"] + "files": ["bud.config.js"], + "include": ["resources"], + "exclude": ["node_modules", "public"] } diff --git a/package.json b/package.json index eb56cc16de..2c0f89a0b2 100644 --- a/package.json +++ b/package.json @@ -2,24 +2,26 @@ "name": "sage", "private": true, "browserslist": [ - "extends @roots/browserslist-config/current" + "extends @roots/browserslist-config" ], "engines": { - "node": ">=16.0.0" + "node": ">=20.0.0" }, + "type": "module", "scripts": { "dev": "bud dev", "build": "bud build", - "translate": "yarn translate:pot && yarn translate:update", - "translate:pot": "wp i18n make-pot . ./resources/lang/sage.pot --include=\"app,resources\"", - "translate:update": "for filename in ./resources/lang/*.po; do msgmerge -U $filename ./resources/lang/sage.pot; done; rm -f ./resources/lang/*.po~", - "translate:compile": "yarn translate:mo && yarn translate:js", + "translate": "npm run translate:pot && npm run translate:update", + "translate:pot": "wp i18n make-pot . ./resources/lang/sage.pot --include=\"theme.json,patterns,app,resources\"", + "translate:update": "for file in ./resources/lang/*.po; do wp i18n update-po ./resources/lang/sage.pot $file; done", + "translate:compile": "npm run translate:mo && npm run translate:js", "translate:js": "wp i18n make-json ./resources/lang --pretty-print", "translate:mo": "wp i18n make-mo ./resources/lang ./resources/lang" }, "devDependencies": { - "@roots/bud": "6.3.5", - "@roots/bud-tailwindcss": "6.3.5", - "@roots/sage": "6.3.5" - } + "@roots/bud": "6.20.0", + "@roots/bud-tailwindcss": "6.20.0", + "@roots/sage": "6.20.0" + }, + "dependencies": {} } diff --git a/resources/scripts/app.js b/resources/scripts/app.js index f5d25d12f1..6711ed1e32 100644 --- a/resources/scripts/app.js +++ b/resources/scripts/app.js @@ -1,21 +1,13 @@ -import {domReady} from '@roots/sage/client'; +import domReady from '@roots/sage/client/dom-ready'; /** - * app.main + * Application entrypoint */ -const main = async (err) => { - if (err) { - // handle hmr errors - console.error(err); - } - - // application code -}; +domReady(async () => { + // ... +}); /** - * Initialize - * - * @see https://webpack.js.org/api/hot-module-replacement + * @see {@link https://webpack.js.org/api/hot-module-replacement/} */ -domReady(main); -import.meta.webpackHot?.accept(main); +if (import.meta.webpackHot) import.meta.webpackHot.accept(console.error); diff --git a/resources/scripts/editor.js b/resources/scripts/editor.js index 8b6014a78e..bea0bf995c 100644 --- a/resources/scripts/editor.js +++ b/resources/scripts/editor.js @@ -1,27 +1,9 @@ -import {domReady} from '@roots/sage/client'; -import {registerBlockStyle, unregisterBlockStyle} from '@wordpress/blocks'; - /** - * editor.main + * @see {@link https://bud.js.org/extensions/bud-preset-wordpress/editor-integration/filters} */ -const main = (err) => { - if (err) { - // handle hmr errors - console.error(err); - } - - unregisterBlockStyle('core/button', 'outline'); - - registerBlockStyle('core/button', { - name: 'outline', - label: 'Outline', - }); -}; +roots.register.filters('@scripts/filters'); /** - * Initialize - * - * @see https://webpack.js.org/api/hot-module-replacement + * @see {@link https://webpack.js.org/api/hot-module-replacement/} */ -domReady(main); -import.meta.webpackHot?.accept(main); +if (import.meta.webpackHot) import.meta.webpackHot.accept(console.error); diff --git a/resources/scripts/filters/button.filter.js b/resources/scripts/filters/button.filter.js new file mode 100644 index 0000000000..65a6a1cccb --- /dev/null +++ b/resources/scripts/filters/button.filter.js @@ -0,0 +1,25 @@ +/** + * @see {@link https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#blocks-registerblocktype} + */ +export const hook = 'blocks.registerBlockType'; + +/** + * Filter handle + */ +export const name = 'sage/button'; + +/** + * Filter callback + * + * @param {object} settings + * @param {string} name + * @returns modified settings + */ +export function callback(settings, name) { + if (name !== 'core/button') return settings; + + return { + ...settings, + styles: [{ label: 'Outline', name: 'outline' }], + }; +} diff --git a/resources/styles/app.css b/resources/styles/app.css index a31e444117..b5c61c9567 100644 --- a/resources/styles/app.css +++ b/resources/styles/app.css @@ -1,3 +1,3 @@ -@import 'tailwindcss/base'; -@import 'tailwindcss/components'; -@import 'tailwindcss/utilities'; +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/resources/views/components/alert.blade.php b/resources/views/components/alert.blade.php index a2aa5a4a9c..dbb5539a19 100644 --- a/resources/views/components/alert.blade.php +++ b/resources/views/components/alert.blade.php @@ -1,3 +1,15 @@ -
merge(['class' => $type]) }}> +@props([ + 'type' => null, + 'message' => null, +]) + +@php($class = match ($type) { + 'success' => 'text-green-50 bg-green-400', + 'caution' => 'text-yellow-50 bg-yellow-400', + 'warning' => 'text-red-50 bg-red-400', + default => 'text-indigo-50 bg-indigo-400', +}) + +
merge(['class' => "px-2 py-1 {$class}"]) }}> {!! $message ?? $slot !!}
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 3f7d3024f7..e310c479e0 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -1,17 +1,36 @@ - - {{ __('Skip to content') }} - + + + + + + @php(do_action('get_header')) + @php(wp_head()) + -@include('sections.header') + + @php(wp_body_open()) -
- @yield('content') -
+
+ + {{ __('Skip to content', 'sage') }} + - @hasSection('sidebar') - - @endif + @include('sections.header') -@include('sections.footer') +
+ @yield('content') +
+ + @hasSection('sidebar') + + @endif + + @include('sections.footer') +
+ + @php(do_action('get_footer')) + @php(wp_footer()) + + diff --git a/resources/views/partials/comments.blade.php b/resources/views/partials/comments.blade.php index 84c228f8eb..4ab83bdc52 100644 --- a/resources/views/partials/comments.blade.php +++ b/resources/views/partials/comments.blade.php @@ -1,26 +1,26 @@ @if (! post_password_required())
- @if (have_comments()) + @if ($responses)

- {!! /* translators: %1$s is replaced with the number of comments and %2$s with the post title */ sprintf(_nx('%1$s response to “%2$s”', '%1$s responses to “%2$s”', get_comments_number(), 'comments title', 'sage'), get_comments_number() === 1 ? _x('One', 'comments title', 'sage') : number_format_i18n(get_comments_number()), '' . get_the_title() . '') !!} + {!! $title !!}

    - {!! wp_list_comments(['style' => 'ol', 'short_ping' => true]) !!} + {!! $responses !!}
- @if (get_comment_pages_count() > 1 && get_option('page_comments')) -