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

View File

@ -67,8 +67,6 @@ class ProfileColor extends Module
$color = DB::find('profile_color', ['gsactor_id' => Common::user()->getId()]);
if ($color != null) {
$vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => ['color' => $color->getColor()]];
} else {
$vars['profile_extras'][] = ['name' => 'profilecolor', 'vars' => []];
}
}
return Event::next;
@ -83,8 +81,7 @@ class ProfileColor extends Module
*/
public function onStartShowStyles(array &$styles): bool
{
//$styles[] = 'profilecolor/profilecolor.css';
$styles[] = 'profilecolor/profilecolor.css';
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">
{% if vars is not empty %}
<div class="profile-color" style="background-color: {{ vars.color }}">{{ vars.color }}</div>
{% else %}
<div class="no-profile-color" ></div>
<div class="profile-color" style="border-color: {{ vars.color }}"></div>
{% endif %}
</a>