[ProfileColor] Added profile color css

This commit is contained in:
Daniel 2020-12-19 20:52:36 +00:00 committed by Hugo Sales
parent d17582094d
commit 15454cab7f
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
4 changed files with 21 additions and 18 deletions

View File

@ -26,9 +26,7 @@ use App\Core\Form;
use function App\Core\I18n\_m; use function App\Core\I18n\_m;
use App\Entity\ProfileColor as PColor; use App\Entity\ProfileColor as PColor;
use App\Util\Common; use App\Util\Common;
use App\Util\Exception\ClientException;
use App\Util\Exception\RedirectException; use App\Util\Exception\RedirectException;
use App\Util\Exception\ServerException;
use Symfony\Component\Form\Extension\Core\Type\ColorType; use Symfony\Component\Form\Extension\Core\Type\ColorType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
@ -47,12 +45,11 @@ use Symfony\Component\HttpFoundation\Request;
class ProfileColor class ProfileColor
{ {
/** /**
* Add/change cover * Add/change profile color
* *
* @param Request $request * @param Request $request
* *
* @throws ClientException Invalid form * @throws RedirectException
* @throws ServerException Invalid file type
* *
* @return array template * @return array template
*/ */
@ -66,11 +63,8 @@ class ProfileColor
$color = $pcolor->getColor(); $color = $pcolor->getColor();
} }
//print_r("STORED: " );
//var_dump($color);
$form = Form::create([ $form = Form::create([
['color', ColorType::class, ['data' => $color, 'label' => _m('Profile Color')]], ['color', ColorType::class, ['data' => $color, 'label' => _m('Profile Color'), 'help' => _m('Choose your Profile Color')] ],
['hidden', HiddenType::class, []], ['hidden', HiddenType::class, []],
['save', SubmitType::class, ['label' => _m('Submit')]], ['save', SubmitType::class, ['label' => _m('Submit')]],
]); ]);
@ -78,9 +72,7 @@ class ProfileColor
$form->handleRequest($request); $form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) { if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData(); $data = $form->getData();
//var_dump($data['color']);
// Must get old id before inserting another one
if ($pcolor != null) { if ($pcolor != null) {
DB::remove($pcolor); DB::remove($pcolor);
DB::flush(); DB::flush();

View File

@ -67,8 +67,6 @@ class ProfileColor extends Module
$color = DB::find('profile_color', ['gsactor_id' => Common::user()->getId()]); $color = DB::find('profile_color', ['gsactor_id' => Common::user()->getId()]);
if ($color != null) { if ($color != null) {
$vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]]; $vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]];
} else {
$vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => []];
} }
} }
return Event::next; return Event::next;
@ -83,8 +81,7 @@ class ProfileColor extends Module
*/ */
public function onStartShowStyles(array &$styles): bool public function onStartShowStyles(array &$styles): bool
{ {
$styles[] = 'profilecolor/profilecolor.css';
//$styles[] = 'profilecolor/profilecolor.css';
return Event::next; return Event::next;
} }
} }

View File

@ -0,0 +1,16 @@
.pcolor{
width: 100%;
height: 100%;
position: absolute;
top:0;
left: 0;
z-index: -1;
}
.profile-color{
width: 100%;
height: 100%;
background-color: transparent;
box-sizing: border-box;
border: 5px solid;
}

View File

@ -1,8 +1,6 @@
<a class="pcolor"> <a class="pcolor">
{% if vars is not empty %} {% if vars is not empty %}
<div class="profile-color" style="background-color: {{ vars.color }}">{{ vars.color }}</div> <div class="profile-color" style="border-color: {{ vars.color }}"></div>
{% else %}
<div class="no-profile-color" ></div>
{% endif %} {% endif %}
</a> </a>