Skip to content

Commit

Permalink
Merge pull request #7 from salahhusa9/component/textarea
Browse files Browse the repository at this point in the history
Component Textarea
  • Loading branch information
salahhusa9 authored Aug 6, 2023
2 parents fe1fa9a + d079935 commit e4ca7b1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ php artisan laravel-template-components:install

## Usage

### Input component
### Input Component
```html
<x-template-components::input />
```
Expand All @@ -32,7 +32,7 @@ He accept all normal attributes of input tag and add some new attributes:
- label-class: add class to label tag
- other attributes will be added to input tag

### Button component
### Button Component
```html
<x-template-components::button />
```
Expand All @@ -49,7 +49,7 @@ we support livewire loading state, so if you use livewire you can use loading st
<x-template-components::button wire:target="save" />
```

### Select component
### Select Component
```html
<x-template-components::select />
```
Expand All @@ -58,6 +58,15 @@ He accept all normal attributes of select tag and add some new attributes:
- label-class: add class to label tag
- other attributes will be added to select tag

### Textarea Component
```html
<x-template-components::textarea />
```
He accept all normal attributes of textarea tag and add some new attributes:
- div-class: add class to div tag
- label-class: add class to label tag
- other attributes will be added to textarea tag

## Supported Templates

- [Vuexy](https://pixinvent.com/demo/vuexy-html-bootstrap-admin-template/html/ltr/vertical-menu-template/dashboard-ecommerce.html)
Expand Down
20 changes: 20 additions & 0 deletions resources/views/components/textarea.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="{{ config('template-components.defult_classes.input.div') }} {{ $attributes->get('div-class') }}">

<label class="{{ config('template-components.defult_classes.input.label') }} {{ $attributes->get('label-class') }}">
{{ $attributes->get('label') }}
</label>

<textarea class="{{ config('template-components.defult_classes.input.input') }} {{ $attributes->get('class') }}
@error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first())
{{ config('template-components.defult_classes.input.input-error') }}
@enderror"
{{ $attributes }}>
{{ $slot }}
</textarea>

@error($attributes->get('name') ?? $attributes->whereStartsWith('wire:model')->first())
<div class="{{ config('template-components.defult_classes.input.error-div') }}">
{{ $message }}
</div>
@enderror
</div>
9 changes: 9 additions & 0 deletions tests/components/TextareaComponentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

// test textarea component

use Illuminate\Support\Facades\View;

it('can render textarea component', function () {
$this->assertTrue(View::exists('template-components::textarea'));
});

0 comments on commit e4ca7b1

Please sign in to comment.