Giter Site home page Giter Site logo

blade-laravel's Introduction

Blade component

1. Layout component

views/components/layout.blade.php views/components/section.blade.php

<section class="bg-gray-300 p-4 mb-6">
    <div class="container">
        {{$slot}}
    </div>
</section>

to use it :

<x-layout>
    <x-section> Hello There</x-section>
    <x-section> Hello 2</x-section>
</x-layout>

2. Flash component

<x-layout>
    <x-flash type="error">
        You are now logged out
    </x-flash>

    <x-flash class="mt-10">
        You are now logged out
    </x-flash>
</x-layout>
  • use attributes merge feature to add styles
@props([
    'type' => 'success',
    'colors' => [
        'success' => 'bg-green-400 border-green-500',
        'error' => 'bg-red-400 border-red-500',
        'warning' => 'bg-orange-400 border-orange-500'
    ]


])

<section {{$attributes->merge(['class' => "{$colors[$type]} border-b p-4"])}} >
    <div class="flex justify-between">
        {{$slot}}
        <button>&times;</button>
    </div>
</section>

3. Form component

@props([
    'method' => 'POST',
    'action' => ''
])

<form
    method="{{$method === "GET" ?  'GET' : 'POST'}}"
    action="{{$action}}" {{$attributes}}>

    @csrf

    @if(! in_array($method, ['GET', 'POST']))
        @method($method)
    @endif
    {{$slot}}

edit file :

<x-layout>
    <x-section>
        <x-form
            method="GET"
            action="/comments/"
        >
            <div class="mb-6">
                <label class="block mb-2 uppercase font-bold text-xs text-gray-700"
                       for="body"
                >
                    Body
                </label>

                <textarea class="border border-gray-400 p-2 w-full"
                          name="body"
                          id="body"
                          required
                >Text to edit</textarea>
        </x-form>
    </x-section>
</x-layout>

4. Delete button component :

'

<x-form method="{{ $method }}" action="{{ $action }}">
    <div>
        <button type="submit" {{ $attributes }}>
            {{ $slot }}
        </button>
    </div>
</x-form>

5. Modal

  • alpine (Based on simple click and x-data)
  • set up trigger - param name element - new thing\
    <x-modal
        title="Deactivate Your Account?"
        submit-label="Deactivate"
    >
        <x-slot name="trigger">
            <button @click="on = true">Show Modal</button>
        </x-slot>

blade-laravel's People

Contributors

programatorseu avatar

Watchers

 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.