GithubHelp home page GithubHelp logo

madan2056 / yapptheme Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yaapis/theme

1.0 0.0 0.0 67 KB

Laravel's theme manager

License: MIT License

JavaScript 1.71% PHP 95.69% Blade 2.19% SCSS 0.41%

yapptheme's Introduction

Theme support for Laravel

Inspired by bigecko/laravel-theme. Themes are stored inside default laravel's resources folder

Requirements

This package requires PHP 7.3 or event 8.* and Laravel 8 or 9.

Currently, supported only for webpack with laravel-mix.

Installation

You can install this package via composer using:

composer require yaap/theme

or manually add line to composer.json

{
  "require": {
    "yaap/theme": "^4.0"
  }
}

Optionally, publish config using artisan CLI (if you want to overwrite default config).

php artisan vendor:publish --provider="YAAP\Theme\ThemeServiceProvider"

Configuration

Package config

return [

    /*
    |--------------------------------------------------------------------------
    | Path to directory with themes
    |--------------------------------------------------------------------------
    |
    | The directory with your themes.
    |
    */

    'path' => base_path('themes'),

    /*
    |--------------------------------------------------------------------------
    | Path to directory with assets build
    |--------------------------------------------------------------------------
    |
    | The directory with assets build in public directory.
    |
    */

    'assets_path' => 'themes',

    /*
    |--------------------------------------------------------------------------
    | A pieces of theme collections
    |--------------------------------------------------------------------------
    |
    | Inside a theme path we need to set up directories to
    | keep "layouts", "assets" and "partials".
    |
    */

    'containerDir' => [
        'assets' => 'assets',
        'lang' => 'lang',
        'layout' => 'layouts',
        'partial' => 'partials',
        'view' => 'views',
    ],
];

Theme config

Config in theme folder

return [

    /*
    |--------------------------------------------------------------------------
    | Theme name
    |--------------------------------------------------------------------------
    |
    | Use in assets publishing etc.
    |
    */

    'name' => '%theme_name%',

    /*
    |--------------------------------------------------------------------------
    | Inherit from another theme
    |--------------------------------------------------------------------------
    |
    | Set up inherit from another if the file is not exists.
    |
    */

    'inherit' => null,

];

Usage

Create theme with artisan CLI

The first time you have to create theme default structure, using the artisan command:

php artisan theme:create default

In order to seed webpack.mix.js with custom rules add --with-mix option

php artisan theme:create default --with-mix

To delete an existing theme, use the command:

php artisan theme:destroy default

Structure

Here is an example of the folder structure of project with theme

project-root
├── app/
<...>
├── public/
|   ├── index.php
|   └── themes/
|       └── default/
|           ├── js/
|           |   └── app.js
|           ├── css/
|           |   └── styles.css
|           └── images/
|               └── icon.png
├── resources/
<...>
├── themes/
|   ├── default/
|   |   ├── assets/        
|   |   ├── lang/        
|   |   ├── layouts/
|   |   ├── partials/
|   |   ├── views/
|   |   |   └── hello.blade.php
|   |   └── config.php
|   ├── admin/
|   ├── views/
|       ├── emails/
|       |   └── notify.blade.php
|       └── hello.blade.php

Init theme

Theme::init($name)

This will add to views find path:

  • themes/{$name}
  • themes/{$name}/views

Lang files will be added as well:

  • themes/{$name}/lang

Making view

View::make('hello');
View::make('emails.notify');

Assets

Use laravel mix for assets.

In header

<link rel="stylesheet" href="{{ mix('/themes/default/css/app.min.css') }}"/>

and in footer

<script type="text/javascript" src="{{ mix('/themes/default/js/app.min.js') }}"></script>

Blade templates

@extends('layouts.master')

@include('partials.header')

@section('content')
    <section id="main">
        <h1>HOME</h1>
    </section>
@stop

@include('partials.footer')

Fallback capability

You still able to use default View::make('emails.notify') which is stored outside the themes directory.

Can I hire you guys?

Yes! Say hi: [email protected]

We will be happy to work with you! Other work we’ve done

Follow us

Stay up to date with the latest Vuestic news! Follow us on LinkedIn or Facebook

License

MIT license.

yapptheme's People

Contributors

yaapis avatar oleksandr-moik avatar sroutier avatar snipe avatar madan2056 avatar terion-name avatar

Stargazers

Prashant Malla avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.