Skip to content

Commit

Permalink
Integrate attribute texture image in combination generator
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed May 27, 2024
1 parent 4783abf commit f275c10
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
v-if="attribute.color"
:style="`background-color: ${attribute.color}`"
/>
<span
class="attribute-item-texture"
v-if="attribute.texture"
:style="`background: transparent url(${attribute.texture}) no-repeat; background-size: 100% auto;`"
/>
<span class="attribute-item-name">{{ attribute.name }}</span>
</div>
</label>
Expand Down Expand Up @@ -406,7 +411,8 @@
display: none;
}

&-color {
&-color,
&-texture {
display: block;
width: 15px;
height: 15px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ export interface Attribute {
group_id: number;
group_name: string;
name: string;
texture: string|null;
}
/* eslint-enable camelcase */
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ protected function formatAttributeGroupsList(
$attributeId,
$attribute->position,
$attribute->color,
$attribute->name
$attribute->name,
file_exists(_PS_COL_IMG_DIR_ . $attributeId . '.jpg') ? _THEME_COL_DIR_ . $attributeId . '.jpg' : null
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class Attribute
*/
private $localizedNames;

/**
* @var string|null
*/
private $textureFilePath;

/**
* @param int $attributeId
* @param int $position
Expand All @@ -60,12 +65,14 @@ public function __construct(
int $attributeId,
int $position,
string $color,
array $localizedNames
array $localizedNames,
string $textureFilePath = null
) {
$this->attributeId = $attributeId;
$this->position = $position;
$this->color = $color;
$this->localizedNames = $localizedNames;
$this->textureFilePath = $textureFilePath;
}

/**
Expand Down Expand Up @@ -99,4 +106,9 @@ public function getLocalizedNames(): array
{
return $this->localizedNames;
}

public function getTextureFilePath(): ?string
{
return $this->textureFilePath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ private function formatAttributeGroupsForPresentation(array $attributeGroups): a
if (null !== $attribute->getColor()) {
$attributeData['color'] = $attribute->getColor();
}
if (null !== $attribute->getTextureFilePath()) {
$attributeData['texture'] = $attribute->getTextureFilePath();
}
$attributes[] = $attributeData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ private function performAttributesInGroupAssertion(?TableNode $tableNode, array
$attribute = $attributes[$index];
Assert::assertEquals($attributesDatum['color'], $attribute->getColor(), 'Unexpected color');
Assert::assertEquals($attributesDatum['position'], $attribute->getPosition(), 'Unexpected position');
if ($attribute->getTextureFilePath()) {
Assert::assertEquals(_THEME_COL_DIR_ . $attribute->getAttributeId() . '.jpg', $attribute->getTextureFilePath());
}

$attributeNames = $attribute->getLocalizedNames();
foreach ($attributesDatum['name'] as $langId => $name) {
Expand Down

0 comments on commit f275c10

Please sign in to comment.