Archived
1
0
Fork 0

initial commit

This commit is contained in:
Henrik Hautakoski 2021-06-28 17:33:29 +01:00
commit 1e1aa7d461
215 changed files with 35140 additions and 0 deletions

View file

@ -0,0 +1,10 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class ClassIcon extends Icon
{
protected $prefix = 'classes';
}

View file

@ -0,0 +1,32 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class Form extends Component
{
public string $method;
public $spoofMethod = false;
public function __construct($method = 'POST')
{
if (in_array($method, ['DELETE'])) {
$this->spoofMethod = $method;
$method = 'POST';
}
$this->method = $method;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.form.form');
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace App\View\Components\Form;
use Illuminate\View\Component;
class Input extends Component
{
public string $type;
public ?string $id;
public string $name;
public ?string $value;
public string $disabled;
public function __construct($name, ?string $id = null, string $type = 'text', ?string $value = null, bool $disabled = false)
{
$this->id = $id;
$this->type = $type;
$this->name = $name;
$this->value = old($name, $value);
$this->disabled = $disabled ? 'disabled=disabled' : '';
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.form.inputs.input');
}
}

View file

@ -0,0 +1,11 @@
<?php
namespace App\View\Components\Form;
class Password extends Input
{
public function __construct($name = 'password', ?string $id = null, ?string $value = null, bool $disabled = false)
{
parent::__construct($name, $id, 'password', $value, $disabled);
}
}

View file

@ -0,0 +1,37 @@
<?php
namespace App\View\Components\Form;
use Illuminate\View\Component;
class Select extends Component
{
public ?string $id;
public string $name;
public ?string $value;
public string $disabled;
public $options;
public function __construct($name, $options, ?string $id = null, ?string $value = null, bool $disabled = false)
{
$this->id = $id;
$this->name = $name;
$this->value = old($name, $value);
$this->disabled = $disabled ? 'disabled=disabled' : '';
$this->options = $options;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.form.inputs.select');
}
}

View file

@ -0,0 +1,34 @@
<?php
namespace App\View\Components\Form;
use Illuminate\View\Component;
class Textarea extends Component
{
public ?string $id;
public string $name;
public ?string $value;
public string $disabled;
public function __construct($name, ?string $id = null, ?string $value = null, bool $disabled = false)
{
$this->id = $id;
$this->name = $name;
$this->value = old($name, $value);
$this->disabled = $disabled ? 'disabled=disabled' : '';
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.form.inputs.textarea');
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace App\View\Components;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\View\Component;
abstract class Icon extends Component
{
protected $prefix = '';
public $url;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(string $name)
{
$file = sprintf('%s/%s.jpg', $this->prefix, Str::lower($name));
$this->url = Storage::disk('images')->url($file);
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('components.class-icon');
}
}

View file

@ -0,0 +1,33 @@
<?php
namespace App\View\Components;
use Illuminate\View\Component;
class Layout extends Component
{
/**
* Layout script
*/
protected string $name;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($name = 'default')
{
$this->name = $name;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view("layouts.{$this->name}");
}
}

View file

@ -0,0 +1,53 @@
<?php
namespace App\View\Components;
use Illuminate\Support\Facades\Session;
use Illuminate\View\Component;
class Notifications extends Component
{
/**
* Types of messages.
*
* @var array
*/
protected $types = [ 'info', 'success', 'warning', 'error' ];
/**
* Position (left,center or right)
*
* @var string
*/
public string $position = 'center';
/**
* Type and css class mapping.
*/
protected $cssClasses = [
'info' => 'info',
'success' => 'success',
'warning' => 'warning',
'error' => 'danger'
];
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
$messages = [];
foreach($this->types as $type) {
if (Session::has($type)) {
$class = $this->cssClasses[$type];
$messages[$class] = Session::get($type);
}
}
return view('components.notifications', [ 'messages' => $messages ]);
}
}

View file

@ -0,0 +1,8 @@
<?php
namespace App\View\Components;
class ProfessionIcon extends Icon
{
protected $prefix = 'professions';
}