Skip to content

Commit

Permalink
file upload icons compatible with blade-ui-icon naming
Browse files Browse the repository at this point in the history
  • Loading branch information
tanthammar committed Aug 5, 2020
1 parent 65eec39 commit dc7293c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion resources/views/fields/file.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class="inline-flex items-center px-3 rounded-l-md border border-r-0 border-gray-
<div class="flex items-center">
<div class="flex-1">
<a href="{{ Storage::url($value['file']) }}" target="_blank">
@svg(config('tall-forms.file-icon')."{$value['mime_type']}", "h-4 w-4 mr-1"){{ $value['name'] }}
@svg(config('tall-forms.file-icon').$this->fileIcon($value['mime_type']), "h-4 w-4 mr-1"){{ $value['name'] }}
{{-- <i class="fa fa-fw {{ $this->fileIcon($value['mime_type']) }} mr-1"></i> --}}
</a>
</div>
Expand Down
50 changes: 25 additions & 25 deletions src/Traits/UploadsFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,35 @@ public function fileUpdate($field_name, $uploaded_files)
public function fileIcon($mime_type)
{
$icons = [
'image' => 'fa-file-image',
'audio' => 'fa-file-audio',
'video' => 'fa-file-video',
'application/pdf' => 'fa-file-pdf',
'application/msword' => 'fa-file-word',
'application/vnd.ms-word' => 'fa-file-word',
'application/vnd.oasis.opendocument.text' => 'fa-file-word',
'application/vnd.openxmlformats-officedocument.wordprocessingml' => 'fa-file-word',
'application/vnd.ms-excel' => 'fa-file-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml' => 'fa-file-excel',
'application/vnd.oasis.opendocument.spreadsheet' => 'fa-file-excel',
'application/vnd.ms-powerpoint' => 'fa-file-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml' => 'fa-file-powerpoint',
'application/vnd.oasis.opendocument.presentation' => 'fa-file-powerpoint',
'text/plain' => 'fa-file-alt',
'text/html' => 'fa-file-code',
'application/json' => 'fa-file-code',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'fa-file-word',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'fa-file-excel',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'fa-file-powerpoint',
'application/gzip' => 'fa-file-archive',
'application/zip' => 'fa-file-archive',
'application/x-zip-compressed' => 'fa-file-archive',
'application/octet-stream' => 'fa-file-archive',
'image' => 'image',
'audio' => 'audio',
'video' => 'video',
'application/pdf' => 'pdf',
'application/msword' => 'word',
'application/vnd.ms-word' => 'word',
'application/vnd.oasis.opendocument.text' => 'word',
'application/vnd.openxmlformats-officedocument.wordprocessingml' => 'word',
'application/vnd.ms-excel' => 'excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml' => 'excel',
'application/vnd.oasis.opendocument.spreadsheet' => 'excel',
'application/vnd.ms-powerpoint' => 'powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml' => 'powerpoint',
'application/vnd.oasis.opendocument.presentation' => 'powerpoint',
'text/plain' => 'alt',
'text/html' => 'code',
'application/json' => 'code',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'word',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'excel',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'powerpoint',
'application/gzip' => 'archive',
'application/zip' => 'archive',
'application/x-zip-compressed' => 'archive',
'application/octet-stream' => 'archive',
];

if (isset($icons[$mime_type])) return $icons[$mime_type];
$mime_group = explode('/', $mime_type, 2)[0];

return (isset($icons[$mime_group])) ? $icons[$mime_group] : 'fa-file';
return (isset($icons[$mime_group])) ? $icons[$mime_group] : 'file';
}
}

0 comments on commit dc7293c

Please sign in to comment.