removed unsed class Color

pull/84/head
Maël DAIM 1 year ago
parent 59e9cf6503
commit 1ac81d7349

@ -2,12 +2,8 @@ export interface TeamInfo {
id: number id: number
name: string name: string
picture: string picture: string
mainColor: Color mainColor: string
secondColor: Color secondColor: string
}
export interface Color {
hex: string
} }
export interface Team { export interface Team {

@ -1,6 +1,6 @@
import "../style/team_panel.css" import "../style/team_panel.css"
import { BASE } from "../Constants" import { BASE } from "../Constants"
import { Team, TeamInfo, Color, User, Member } from "../model/team/Team" import { Team, TeamInfo, User, Member } from "../model/team/Team"
export default function TeamPanel({ export default function TeamPanel({
isCoach, isCoach,
@ -53,8 +53,8 @@ function TeamDisplay({ team }: { team: TeamInfo }) {
) )
} }
function ColorDisplay({ color }: { color: Color }) { function ColorDisplay({ color }: { color: string }) {
return <div className="square" style={{ backgroundColor: color.hex }} /> return <div className="square" style={{ backgroundColor: color }} />
} }
function CoachOptions({ id }: { id: number }) { function CoachOptions({ id }: { id: number }) {

@ -67,9 +67,9 @@
<label for="picture">Logo:</label> <label for="picture">Logo:</label>
<input type="text" id="picture" name="picture" value="{{ team.getInfo().getPicture() }}" required> <input type="text" id="picture" name="picture" value="{{ team.getInfo().getPicture() }}" required>
<label for="main_color">Couleur principale</label> <label for="main_color">Couleur principale</label>
<input type="color" value="{{ team.getInfo().getMainColor().getValue() }}" id="main_color" name="main_color" required> <input type="color" value="{{ team.getInfo().getMainColor() }}" id="main_color" name="main_color" required>
<label for="second_color">Couleur secondaire</label> <label for="second_color">Couleur secondaire</label>
<input type="color" id="second_color" name="second_color" value="{{ team.getInfo().getSecondColor().getValue() }}" required> <input type="color" id="second_color" name="second_color" value="{{ team.getInfo().getSecondColor() }}" required>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="submit" value="Confirmer"> <input type="submit" value="Confirmer">

@ -1,50 +0,0 @@
<?php
namespace IQBall\Core\Data;
use InvalidArgumentException;
class Color implements \JsonSerializable {
/**
* @var string that represents an hexadecimal color code
*/
private string $hex;
/**
* @param string $value 6 bytes unsigned int that represents an RGB color
* @throws InvalidArgumentException if the value is negative or greater than 0xFFFFFF
*/
private function __construct(string $value) {
$this->hex = $value;
}
/**
* @return string
*/
public function getValue(): string {
return $this->hex;
}
public static function from(string $value): Color {
$color = self::tryFrom($value);
if ($color == null) {
throw new InvalidArgumentException("The string is not an hexadecimal code");
}
return $color;
}
public static function tryFrom(string $value): ?Color {
if (!preg_match('/#(?:[0-9a-fA-F]{6})/', $value)) {
return null;
}
return new Color($value);
}
public function jsonSerialize() {
return get_object_vars($this);
}
}

@ -6,17 +6,17 @@ class TeamInfo implements \JsonSerializable {
private int $id; private int $id;
private string $name; private string $name;
private string $picture; private string $picture;
private Color $mainColor; private string $mainColor;
private Color $secondColor; private string $secondColor;
/** /**
* @param int $id * @param int $id
* @param string $name * @param string $name
* @param string $picture * @param string $picture
* @param Color $mainColor * @param string $mainColor
* @param Color $secondColor * @param string $secondColor
*/ */
public function __construct(int $id, string $name, string $picture, Color $mainColor, Color $secondColor) { public function __construct(int $id, string $name, string $picture, string $mainColor, string $secondColor) {
$this->id = $id; $this->id = $id;
$this->name = $name; $this->name = $name;
$this->picture = $picture; $this->picture = $picture;
@ -37,11 +37,11 @@ class TeamInfo implements \JsonSerializable {
return $this->picture; return $this->picture;
} }
public function getMainColor(): Color { public function getMainColor(): string {
return $this->mainColor; return $this->mainColor;
} }
public function getSecondColor(): Color { public function getSecondColor(): string {
return $this->secondColor; return $this->secondColor;
} }

@ -3,7 +3,6 @@
namespace IQBall\Core\Gateway; namespace IQBall\Core\Gateway;
use IQBall\Core\Connection; use IQBall\Core\Connection;
use IQBall\Core\Data\Color;
use IQBall\Core\Data\TeamInfo; use IQBall\Core\Data\TeamInfo;
use PDO; use PDO;
@ -47,7 +46,7 @@ class TeamGateway {
"id" => [$id, PDO::PARAM_INT], "id" => [$id, PDO::PARAM_INT],
] ]
); );
return array_map(fn($row) => new TeamInfo($row['id'], $row['name'], $row['picture'], Color::from($row['main_color']), Color::from($row['second_color'])), $result); return array_map(fn($row) => new TeamInfo($row['id'], $row['name'], $row['picture'], $row['main_color'], $row['second_color']), $result);
} }
/** /**
@ -64,7 +63,7 @@ class TeamGateway {
if ($row == null) { if ($row == null) {
return null; return null;
} }
return new TeamInfo($row['id'], $row['name'], $row['picture'], Color::from($row['main_color']), Color::from($row['second_color'])); return new TeamInfo($row['id'], $row['name'], $row['picture'], $row['main_color'], $row['second_color']);
} }
/** /**

@ -2,7 +2,6 @@
namespace IQBall\Core\Model; namespace IQBall\Core\Model;
use IQBall\Core\Data\Color;
use IQBall\Core\Data\Team; use IQBall\Core\Data\Team;
use IQBall\Core\Data\TeamInfo; use IQBall\Core\Data\TeamInfo;
use IQBall\Core\Gateway\AccountGateway; use IQBall\Core\Gateway\AccountGateway;

Loading…
Cancel
Save