Simplify layout and component management in your HydePHP projects.
HydePHP Layouts Manager is a powerful package designed to simplify the management of layouts and reusable components in your HydePHP projects. It provides an intuitive way to organize and customize themes, layouts, and components with centralized presets and easy override, enhancing your workflow while keeping your codebase clean and maintainable.
Check it out in action: HydePHP Layouts Manager
-
Dynamic Layout Management: Seamlessly switch and manage layouts across your HydePHP site for a consistent and adaptable design.
-
Reusable Components: Craft modular, customizable components with intuitive default attributes, enabling flexibility and reuse.
-
Font Manager: Typography is more than textβit's the voice of your design. With access to 1,790 font families from Google Fonts, you can shape the personality of your site to reflect your identity. Let every word speak volumes, with fonts tailored to inspire, inform, or captivate.
-
CLI Tools: Streamline your workflow with powerful commands for listing layouts, merging configurations, and automating essential tasks.
-
Built-in Flowbite Support: Enhance your site with beautiful, pre-designed components from the Flowbite library, perfectly integrated for ease of use.
-
Customizable Themes: Transform and extend your layouts with fully customizable themes, tailored to your vision.
Before installing this package, make sure your project meets the following prerequisites:
- HydePHP Framework: This package is specifically designed for projects built with HydePHP. Ensure you are using version
^1.7
or higher. - PHP Version: Your project must be running PHP 8.1 or newer to guarantee compatibility with both HydePHP and this package.
- Composer: Ensure that Composer is installed and configured in your development environment for dependency management.
- Internet Connection: An active internet connection is essential for the Font Manager to dynamically fetch font families from Google Fonts.
- Environment Configuration: Set the
DEFAULT_LAYOUT
variable in your.env
file to ensure the correct fonts are applied and mapped based on your selected layout. This allows centralized and dynamic typography management.
These prerequisites ensure that the package functions as intended, especially for dynamic font management, layout switching, and integration with HydePHP. Proper setup guarantees a seamless and feature-rich experience.
Use Composer to add the package to your project:
composer require melasistema/hyde-layouts-manager
To ensure the package works as intended, add the DEFAULT_LAYOUT
variable to your project's .env
file.
This value is critical for enabling dynamic typography management.
DEFAULT_LAYOUT=melasistema
You can change this value to hyde
or any custom layout defined in HydePHP Layouts Manager. Refer to the README Usage Section for more details.
Publish the package's configuration file to your app's config
directory for customization:
php hyde vendor:publish --provider="Melasistema\HydeLayoutsManager\HydeLayoutsManagerServiceProvider" --tag="hyde-layouts-manager-config"
Manually include the Layouts Manager configuration in your tailwind.config.js
file:
const defaultTheme = require('tailwindcss/defaultTheme');
const HydeLayoutsManagerConfig = require('./tailwind-layouts-manager.config.js');
module.exports = {
darkMode: 'class',
content: [
'./_pages/**/*.blade.php',
'./resources/views/**/*.blade.php',
'./vendor/hyde/framework/resources/views/**/*.blade.php',
...HydeLayoutsManagerConfig.content,
],
safelist: [
...HydeLayoutsManagerConfig.safelist
],
theme: {
extend: {
typography: {},
colors: {},
...HydeLayoutsManagerConfig.theme.extend,
},
},
plugins: [
require('@tailwindcss/typography'),
...HydeLayoutsManagerConfig.plugins
],
};
Automate the process with the tailwind:merge
command. This replaces your existing tailwind.config.js
file with the default configuration from HydeLayoutsManager.
Run the command:
php hyde tailwind:merge
The default theme and components shipped with HydeLayoutsManager use Flowbite. You can add these dependencies manually or by using the package-json:merge
command.
Add the following Flowbite dependencies to your package.json
file:
"devDependencies": {
"flowbite": "^2.5.2"
}
Then, install the dependencies:
npm install
Use the package-json:merge
command to automatically merge the Flowbite dependencies into your existing package.json
.
package.json
. Ensure to back it up if you have custom dependencies.
Run the command:
php hyde package-json:merge
Afterward, run:
npm install
Add Flowbite styles and scripts in you webpack.mix.js
file:
let mix = require('laravel-mix');
mix.css('node_modules/flowbite/dist/flowbite.css', 'app.css')
.js('node_modules/flowbite/dist/flowbite.js', 'app.js')
.js('resources/assets/app.js', 'app.js')
.postCss('resources/assets/app.css', 'app.css', [
require('tailwindcss'),
require('autoprefixer'),
])
.setPublicPath('_site/media')
.copyDirectory('_site/media', '_media')
Run the Laravel Mix build:
npm run dev
Add dynamic @extends() directive to your pages for the "Layout Switching" es. index.blade.php
:
@php($title = 'Home')
@extends(config('hyde-layouts-manager.layouts.' . config('hyde-layouts-manager.default_layout') . '.app', 'hyde::layouts.app'))
@section('content')
// page content
@endsection
If you are using a post page, you can use the active layout blog post feed:
@include('hyde-layouts-manager::layouts.'.config('hyde-layouts-manager.default_layout').'.posts.blog-post-feed')
If you want to customize the default views, publish them to your application:
php hyde vendor:publish --provider="Melasistema\HydeLayoutsManager\HydeLayoutsManagerServiceProvider" --tag="hyde-layouts-manager-views"
After completing the installation, youβre ready to build dynamic layouts and reusable components with HydePHP Layouts Manager! π
The default layout for your site is determined by the DEFAULT_LAYOUT
value in the .env
file. This ensures centralized and dynamic configuration across all functionality, including the "HydePHP Layouts Manager" and "Typo Manager."
To set or switch the default layout, update your .env
file:
DEFAULT_LAYOUT=melasistema # Use 'hyde' for the default Hyde layout or any custom layout like defined in the configuration file.
Note: Setting this value in the
.env
file is crucial for proper functionality, as the Tailwind JavaScript configuration usesprocess.env
to dynamically apply styles and fonts.
Layouts are defined in the layouts
section of the configuration file. Each layout can include unique views, styles, scripts, and navigation settings:
'layouts' => [
'melasistema' => [
'app' => 'hyde-layouts-manager::layouts.melasistema.app',
'page' => 'hyde-layouts-manager::layouts.melasistema.page',
'post' => 'hyde-layouts-manager::layouts.melasistema.post',
'styles' => 'vendor/hyde-layouts-manager/css/melasistema/app.css',
'scripts' => 'vendor/hyde-layouts-manager/js/melasistema/app.js',
],
],
Tip: Define multiple layouts (Themes) in the configuration file to suit different pages or sections of your site, and switch them easily via the
.env
file.
Below is an example of how your project could be structured after installing the package:
my-hyde-project/
βββ config/
β βββ hyde-layouts-manager.php
| βββ hyde-layouts-manager-fonts.json
βββ resources/
β βββ views/
β βββ vendor/
β βββ hyde-layouts-manager/
β βββ components/
β β βββ flowbite/
β β βββ hero-sections/
β β βββ jumbotron.blade.php
β β
β βββ layouts/
β βββ melasistema/
β βββ app.blade.php
βββ tailwind-layouts-manager.config.js`
Typography is a crucial aspect of design, shaping the visual identity and readability of your site. The Font Manager in HydePHP Layouts Manager provides access to 1,790 Google Fonts, enabling you to customize and manage fonts dynamically. Each Layout (Theme) can have its own font settings and mapping, allowing you to tailor typography to match your design vision.
file: config/hyde-layouts-manager-fonts.json
{
"layouts": {
"melasistema": {
"use_google_fonts": true,
"families": {
"primary": "Nunito Sans:wght@400;600;700",
"secondary": "Poppins:wght@500;600;700",
"display": "Fredoka:wght@400;600",
"heading": "Nunito:wght@600;700",
"subheading": "Karla:wght@400;600",
"accent": "Pacifico:wght@400",
"code": "Fira Code:wght@400;500",
"small": "Raleway:wght@400;600",
"special": "Indie Flower:wght@400"
},
"typography_mapping": {
"h1": "display",
"h2": "heading",
"h3": "subheading",
"h4": "subheading",
"h5": "secondary",
"h6": "secondary",
"p": "primary",
"small": "small",
"code": "code",
"blockquote": "accent",
"label": "secondary",
"button": "heading",
"special": "special"
},
"custom_css": {}
}
}
}
Note: If you want to use a layout without Typo Manager (Google Fonts CDN) you can set
use_google_fonts
tofalse
and empty thefamilies
andtypography_mapping
arrays to fall back tosystem-ui
fonts.npm run dev
to compile the assets it's required after those changes.
Components are reusable UI elements with configurable defaults. The package provides a method to dynamically render components in your Blade templates.
The renderComponent()
method, provided by the HydePHP Layouts Manager
, dynamically renders components with the ability to override default configurations. Keep in mind that all preset groups are merged into the settings
.
Here's an example of how to override the Jumbotron
component's default
presets using the styleKey
:
{!! app('layout.manager')->renderComponent('flowbite.hero-sections.jumbotron', [
'styleKey' => 'default',
'settings' => [
'applyContentMaxWidth' => true,
'showPrimaryButton' => false,
'showSecondaryButton' => false,
'padding' => 'py-8 md:py-32 px-0 md:px-16',
'bgImageUrl' => asset('hyde-hat-jumbotron.png'),
'darkBgImageUrl' => asset('hyde-hat-jumbotron.png'),
'bgImageAdditionalClasses' => 'bg-contain bg-no-repeat',
'headingType' => 'h2',
'headingTextFontFamily' => 'secondary',
'headingText' => 'Whatever it is your\'re
<span class="text-purple-500 text-8xl">style</span>,
<br>we\'ve got you covered!' ,
'headingTextAlign' => 'right',
'subHeadingText' => 'Save <span class="text-purple-500">presets</span>,
<span class="text-purple-500">override</span> with ease, and design
<span class="text-purple-500">without limits</span>.',
'subHeadingTextFontFamily' => 'subheading',
'subHeadingTextAlign' => 'right',
'subHeadingTextExtraClasses' => 'pt-8',
]
]) !!}
This method fetches the component configuration from the hyde-layouts-manager.php
configuration file using the presets
that can be defined with the styleKey
, allowing you to:
- Define multiple
presets
for each component. - Override settings dynamically at runtime.
You can customize or create multiple presets settings for components in the hyde-layouts-manager.php
configuration file within the styles
array. For example:
'components' => [
'flowbite' => [
'carousel' => [
'default-slider' => [ // Preset identifier for the component
'view' => 'hyde-layouts-manager::components.flowbite.carousel.default-slider', // Blade view path
'styles' => [ // Define different style presets
'default' => [ // Default style preset
'config' => [
'layout' => [ // Layout options for the component
'showIndicators' => true, // Show slide indicators
'showControls' => true, // Show next/previous controls
'rounded' => false, // Enable/disable rounded corners
],
'settings' => [], // Additional settings for customization
'images' => [ // Default images for the carousel
'hyde-layouts-manager/carousel/example/carousel-1.svg',
'hyde-layouts-manager/carousel/example/carousel-2.svg',
'hyde-layouts-manager/carousel/example/carousel-3.svg',
'hyde-layouts-manager/carousel/example/carousel-4.svg',
'hyde-layouts-manager/carousel/example/carousel-5.svg',
],
]
],
]
],
],
],
],
components
: The top-level key for all components.flowbite
: The namespace or grouping for Flowbite-based components.carousel
: The specific component being configured.default-slider
: The identifier for this specific preset of the carousel.view
: Specifies the Blade template used to render this preset.styles
: Contains all available style presets for this component.default
: The name of the style preset (you can define multiple presets here).
config
: Holds the customizable settings for the component:layout
: Layout options like showing indicators or controls.settings
: Additional configuration options that can be extended.images
: Default images to be used in the carousel.
- Dynamic Overrides: Easily override defaults for individual component instances.
- Centralized Configuration: Maintain consistent default values in the configuration file.
- Flexibility: Simplifies re-usability for components across projects.
By leveraging these methods, you can build scalable and easily customizable layouts with HydeLayoutsManager. π
The package includes several Artisan commands to streamline your workflow:
-
List Layouts: Display available layouts:
php hyde layouts:list
-
Merge Package JSON: Merge dependencies into your
package.json
:php hyde package-json:merge
-
Merge Tailwind Config: Merge Tailwind configurations into your
tailwind.config.js
file:php hyde tailwind:merge
You can add custom layouts by defining them in the layouts
section of the configuration file and placing the corresponding Blade templates in resources/views/vendor/hyde-layouts-manager
.
To customize components, publish the views and edit the files in resources/views/vendor/hyde-layouts-manager/components
.
The navigation brand (logo) can be customized through the navigation.brand
configuration. You can use a text-based logo, an image logo, or a custom HTML logo. You can also configure the logo's behavior in light and dark themes. Below is an example configuration:
'navigation' => [
'brand' => [
'type' => 'custom', // Accepted values: 'text', 'image', 'custom'
'url' => '/',
'lightLogo' => 'media/hyde-layouts-manager/logo/logo-navigation-light.png', // Path to the light logo
'darkLogo' => 'media/hyde-layouts-manager/logo/logo-navigation-dark.png', // Path to the dark logo
'logoHeight' => 'h-10', // Adjust the logo height (e.g., 'h-10' for height 2.5rem)
],
'navbarLink' => [
'color' => 'text-gray-700', // Normal state link color
'darkColor' => 'text-gray-400', // Dark theme link color
'hoverColor' => 'text-purple-500', // Hover state link color
'darkHoverColor' => 'text-purple-500', // Dark theme hover color
],
],`
You can configure a CTA button in the navigation to link to an external URL or trigger actions. Below is an example configuration for the CTA button:
'navigation' => [
'cta' => [
'enabled' => true, // Set to false to disable the CTA button
'text' => 'Get Started', // Button text
'textColor' => 'text-white', // Text color for the CTA button
'url' => 'https://github.com/melasistema/hydephp-layouts-manager', // URL to redirect
'urlTarget' => '_blank', // Define the link's target (_blank for a new tab)
'bgColor' => 'bg-purple-500', // Background color for the CTA button
'darkBgColor' => 'bg-purple-500', // Dark theme background color
'hoverBgColor' => 'bg-purple-800', // Hover state background color
'darkHoverBgColor' => 'bg-purple-800', // Dark theme hover color
'focusRingColor' => 'ring-purple-800', // Focus ring color
'darkFocusRingColor' => 'ring-purple-800', // Dark theme focus ring color
'extraClasses' => 'focus:ring-4 focus:outline-none font-medium rounded-lg text-sm px-4 py-2 text-center', // Extra classes for styling
],
],
Social media links can be customized to include icons that link to your social platforms. The configuration allows you to toggle the visibility of each platform (e.g., GitHub, LinkedIn) and adjust the icon colors for light and dark themes. Below is an example configuration:
'navigation' => [
'social' => [
'enabled' => true, // Enable or disable the social media icons section
'platforms' => [
'github' => [
'enabled' => true, // Enable GitHub link
'url' => 'https://github.com/melasistema', // Link to your GitHub profile
'icon' => '<svg class="fill-current" xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 32 32"><path d="M16,2.345c7.735,0,14,6.265,14,14-.002,6.015-3.839,11.359-9.537,13.282..."></path></svg>',
'iconColor' => 'text-gray-700', // Light theme icon color
'darkIconColor' => 'text-white', // Dark theme icon color
],
'linkedin' => [
'enabled' => true, // Enable LinkedIn link
'url' => 'https://www.linkedin.com/in/luca-visciola/', // Link to your LinkedIn profile
'icon' => '<svg class="fill-current" xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 32 32"><path d="M26.111,3H5.889c-1.595,0-2.889,1.293-2.889,2.889..."></path></svg>',
'iconColor' => 'text-gray-700', // Light theme icon color
'darkIconColor' => 'text-white', // Dark theme icon color
],
'facebook' => [
'enabled' => false, // Disable Facebook link
'url' => 'https://facebook.com', // Facebook URL
'icon' => '<svg class="fill-current" xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 32 32"><path d="M16,2c-7.732,0-14,6.268-14,14..."></path></svg>',
'iconColor' => 'text-gray-700',
'darkIconColor' => 'text-white',
],
],
],
],
The footer can be customized to match your branding, colors, and content. You can set background and text colors for both light and dark themes, as well as modify the footer links and description. Below is an example configuration:
'footer' => [
'view' => 'vendor.hyde-layouts-manager.layouts.melasistema.footer', // Path to the Blade view for the footer
'default' => [
'bgColor' => 'bg-white', // Light theme background color for the footer
'darkBgColor' => 'dark:bg-gray-800', // Dark theme background color
'textColor' => 'text-gray-900', // Light theme text color
'darkTextColor' => 'dark:text-white', // Dark theme text color
'description' => 'Manage your layouts and reusable components with ease.', // Footer description text
'links' => [
[
'title' => 'GitHub', // Footer link title
'url' => 'https://github.com/melasistema/hydephp-layouts-manager', // Link URL
],
[
'title' => 'About Me',
'url' => 'https://github.com/melasistema',
],
],
],
],
With these options, you have full control over the navigation brand, CTA button, social media links, and footer content, ensuring your site is fully customizable and reflects your brandβs identity.
This project is made possible by the inspiration, contributions, and tools of an incredible community. A heartfelt thank you to:
-
π¨βπ» Author: Luca Visciola β Passionate developer and creator of Hyde Layouts Manager. Reach out at [email protected] for inquiries or feedback.
-
π Inspired by HydePHP: The foundation of this project stems from the brilliance of Caen De Silva. Discover the magic of static site generation at HydePHP GitHub.
-
π¨ Boosted by Flowbite: This package features beautiful UI components and layouts, made even better with tools from Flowbite.
To the open-source community and all contributorsβyour dedication and collaboration inspire innovation and make projects like this possible. π
This package is licensed under the MIT License. See the LICENSE file for details.
All notable changes to this project are documented in CHANGELOG.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
We welcome contributions! Feel free to open an issue or submit a pull request on GitHub.
If you encounter any issues or have questions, please open an issue on GitHub.