@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>로고</h2>
    <hr/>
    @include('admin.messages')
    @include('admin.config.layout.navTabs')

    <form name="f_admin_write" id="fAdminWrite" action="{{ route('admin.config.layout.logo.store') }}" method="post" enctype="multipart/form-data">
        @csrf
        <div class="row mb-3">
            <label for="siteFavicon" class="col-sm-2 col-form-label">사이트 파비콘</label>
            <div class="col-sm-10">
                @if($siteFavicon = config('site_favicon'))
                    <img src="{{ asset($siteFavicon) }}" alt="site favicon" width="16" height="16"/>
                    <div class="form-check mt-2">
                        <input type="checkbox" name="site_favicon_del" id="faviconLogoDel" class="form-check-input" value="1" />
                        <input type="hidden" name="site_favicon_url" value="{{ $siteFavicon }}" />
                        <label for="faviconLogoDel" class="form-check-label">삭제</label>
                    </div>
                @else
                    <input type="file" name="site_favicon" id="siteFavicon" value="{{ $siteFavicon }}" accept="image/x-icon" />
                    <div class="form-text text-muted">
                         파비콘은 16*16px, 1MB 크기의 이미지 ico 확장자로 등록해 주십시요.
                         파비콘은 즐겨찾기(favorites) 와 아이콘(icon)의 합성어로 주소창 좌측에 조그만 아이콘으로 표시됩니다.
                    </div>
                @endif
            </div>
        </div>
        <div class="row mb-3">
            <label for="siteLogo" class="col-sm-2 col-form-label">사이트 로고</label>
            <div class="col-sm-10">
                @if($siteLogo = config('site_logo'))
                    <img src="{{ asset($siteLogo) }}" alt="site favicon"/>
                    <div class="form-check mt-2">
                        <input type="checkbox" name="site_logo_del" id="siteLogoDel" class="form-check-input" value="1" />
                        <input type="hidden" name="site_logo_url" value="{{ $siteLogo }}" />
                        <label for="siteLogoDel" class="form-check-label">삭제</label>
                    </div>
                @else
                    <input type="file" name="site_logo" id="siteLogo" value="{{ $siteLogo }}" accept="image/gif,image/jpeg,image/png" />
                    <div class="form-text text-muted">
                         로고는 사용자 화면에 노출될 브랜드 대표 이미지 입니다.
                         크기 상관없이 2MB ( gif, jpeg, png ) 확장자로 등록해 주십시요.
                    </div>
                @endif
            </div>
        </div>
        <hr/>
        <div class="text-end">
            <button type="submit" class="btn btn-success">저장하기</button>
        </div>
    </form>
</div>

<script type="module">
$("#fAdminWrite").validate({
    rules: {
        site_favicon: {accept: "image/x-icon"},
        site_logo: {accept: "image/gif,image/jpeg,image/png"}
    }
});
</script>

@endsection
