Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion com.woltlab.wcf/templates/shared_trophyBadge.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<span
class="trophyIcon{if $showTooltip} jsTooltip{/if}"
style="color: {$trophy->iconColor}; background-color: {$trophy->badgeColor}"
style="color: {$trophy->iconColor}; background-color: {$trophy->badgeColor}{if $trophy->borderColor}; --trophy-border-color: {$trophy->borderColor}{/if}"
data-trophy-id="{$trophy->trophyID}"
{if $showTooltip}title="{$trophy->getTitle()}"{/if}
>
Expand Down
4 changes: 3 additions & 1 deletion com.woltlab.wcf/templates/shared_trophyBadgeFormField.tpl
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<div class="badgeIconEditor" id="{$field->getPrefixedId()}_container">
<span class="trophyIcon" style="color: {$field->getIconColor()}; background-color: {$field->getBadgeColor()}">
<span class="trophyIcon" style="color: {$field->getIconColor()}; background-color: {$field->getBadgeColor()}; --trophy-border-color: {$field->getBorderColor()}">
{unsafe:$field->getIcon()->toHtml(64)}
</span>
{if !$field->isImmutable()}
<div class="badgeIconEditorButtons">
<button type="button" class="button small" data-value="icon">{lang}wcf.global.fontAwesome.selectIcon{/lang}</button>
<button type="button" class="button small" data-value="color">{lang}wcf.style.colorPicker.changeColor{/lang}</button>
<button type="button" class="button small" data-value="background-color">{lang}wcf.style.colorPicker.changeBackgroundColor{/lang}</button>
<button type="button" class="button small" data-value="border-color">{lang}wcf.style.colorPicker.changeBorderColor{/lang}</button>
</div>
{/if}
</div>

<input type="hidden" id="{$field->getPrefixedId()}_iconName" name="{$field->getPrefixedId()}[iconName]" value="{$field->getIconName()}">
<input type="hidden" id="{$field->getPrefixedId()}_iconColor" name="{$field->getPrefixedId()}[iconColor]" value="{$field->getIconColor()}">
<input type="hidden" id="{$field->getPrefixedId()}_badgeColor" name="{$field->getPrefixedId()}[badgeColor]" value="{$field->getBadgeColor()}">
<input type="hidden" id="{$field->getPrefixedId()}_borderColor" name="{$field->getPrefixedId()}[borderColor]" value="{$field->getBorderColor()}">

{if !$field->isImmutable()}
{if $__trophyBadgeFormFieldIncludeJavaScript}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Enables editing of the icon, the icon color and the background color of a
* badge trophy.
* Enables editing of the icon, the icon color, the background color and the
* border color of a badge trophy.
*
* @author Alexander Ebert, Marcel Werk
* @copyright 2001-2026 WoltLab GmbH
Expand Down Expand Up @@ -56,7 +56,7 @@ function setupColorPicker(
button: HTMLButtonElement,
preview: HTMLElement,
input: HTMLInputElement,
property: "color" | "background-color",
property: "color" | "background-color" | "--trophy-border-color",
): void {
button.dataset.store = input.id;

Expand All @@ -83,4 +83,10 @@ export function setup(fieldId: string): void {
getInput(fieldId, "badgeColor"),
"background-color",
);
setupColorPicker(
getButton(container, "border-color"),
preview,
getInput(fieldId, "borderColor"),
"--trophy-border-color",
);
}
1 change: 1 addition & 0 deletions ts/WoltLabSuite/Core/Form/Builder/Field/TrophyBadge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TrophyBadge extends Field {
iconName: this.#getValue("iconName"),
iconColor: this.#getValue("iconColor"),
badgeColor: this.#getValue("badgeColor"),
borderColor: this.#getValue("borderColor"),
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
->notNull()
->defaultValue(1),
IntDatabaseTableColumn::create('iconFileID'),
VarcharDatabaseTableColumn::create('borderColor')
->length(255),
JsonDatabaseTableColumn::create('conditions'),
])
->foreignKeys([
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion wcfsetup/install/files/lib/acp/form/TrophyAddForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ protected function createForm(): void
->label('wcf.acp.trophy.type.badge')
->required()
->saveValueCallback(static function (TrophyBuilder $builder, TrophyBadgeFormField $field): void {
$builder->setBadge($field->getIconName(), $field->getIconColor(), $field->getBadgeColor());
$builder->setBadge(
$field->getIconName(),
$field->getIconColor(),
$field->getBadgeColor(),
$field->getBorderColor()
);
})
->loadValueCallback(static function (Trophy $object, IFormField $field): void {
// Image trophies keep the default badge.
Expand All @@ -214,6 +219,7 @@ protected function createForm(): void
'iconName' => $object->iconName,
'iconColor' => $object->iconColor,
'badgeColor' => $object->badgeColor,
'borderColor' => $object->borderColor,
]);
}
})
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/files/lib/data/trophy/Trophy.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @property-read ?string $iconName
* @property-read ?string $iconColor
* @property-read ?string $badgeColor
* @property-read ?string $borderColor
* @property-read 0|1 $isDisabled `1` if the trophy is disabled, otherwise `0`
* @property-read 0|1 $awardAutomatically `1` if the trophy is awarded automatically, otherwise `0`
* @property-read 0|1 $revokeAutomatically `1` if the trophy should be automatically revoked once the conditions are no longer met, otherwise `0`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function setType(int $type): static
$this->properties['iconName'] = '';
$this->properties['iconColor'] = '';
$this->properties['badgeColor'] = '';
$this->properties['borderColor'] = '';
} elseif ($type === Trophy::TYPE_BADGE) {
$this->properties['iconFileID'] = null;
}
Expand All @@ -100,11 +101,12 @@ public function setIconFileID(?int $iconFileID): static
/**
* Sets the icon and the colors of a badge trophy.
*/
public function setBadge(string $iconName, string $iconColor, string $badgeColor): static
public function setBadge(string $iconName, string $iconColor, string $badgeColor, string $borderColor): static
{
$this->properties['iconName'] = $iconName;
$this->properties['iconColor'] = $iconColor;
$this->properties['badgeColor'] = $badgeColor;
$this->properties['borderColor'] = $borderColor;

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
use wcf\system\style\FontAwesomeIcon;

/**
* Form field to configure the icon, the icon color and the background color of
* a badge trophy.
* Form field to configure the icon, the icon color, the background color and the
* border color of a badge trophy.
*
* The value is an array with the keys `iconName`, `iconColor` and `badgeColor`.
* The value is an array with the keys `iconName`, `iconColor`, `badgeColor` and
* `borderColor`.
*
* @author Marcel Werk
* @copyright 2001-2026 WoltLab GmbH
Expand All @@ -29,6 +30,8 @@ final class TrophyBadgeFormField extends AbstractFormField implements IImmutable

public const DEFAULT_BADGE_COLOR = 'rgba(50, 92, 132, 1)';

public const DEFAULT_BORDER_COLOR = 'rgba(0, 0, 0, 0)';

private const COLOR_PATTERN = '~^rgba\(\d{1,3}, ?\d{1,3}, ?\d{1,3}, ?(1|1\.00?|0|0?\.[0-9]{1,2})\)$~';

/**
Expand All @@ -48,6 +51,7 @@ final class TrophyBadgeFormField extends AbstractFormField implements IImmutable
'iconName' => self::DEFAULT_ICON_NAME,
'iconColor' => self::DEFAULT_ICON_COLOR,
'badgeColor' => self::DEFAULT_BADGE_COLOR,
'borderColor' => self::DEFAULT_BORDER_COLOR,
];

/**
Expand Down Expand Up @@ -76,6 +80,7 @@ public function readValue(): TrophyBadgeFormField
'iconName' => (string)($value['iconName'] ?? ''),
'iconColor' => (string)($value['iconColor'] ?? ''),
'badgeColor' => (string)($value['badgeColor'] ?? ''),
'borderColor' => (string)($value['borderColor'] ?? ''),
];
}
}
Expand All @@ -96,6 +101,7 @@ public function value(mixed $value): TrophyBadgeFormField
'iconName' => (string)($value['iconName'] ?? self::DEFAULT_ICON_NAME),
'iconColor' => (string)($value['iconColor'] ?? self::DEFAULT_ICON_COLOR),
'badgeColor' => (string)($value['badgeColor'] ?? self::DEFAULT_BADGE_COLOR),
'borderColor' => (string)($value['borderColor'] ?? self::DEFAULT_BORDER_COLOR),
];

return $this;
Expand Down Expand Up @@ -126,6 +132,7 @@ public function validate(): void
if (
\preg_match(self::COLOR_PATTERN, $this->getIconColor()) !== 1
|| \preg_match(self::COLOR_PATTERN, $this->getBadgeColor()) !== 1
|| \preg_match(self::COLOR_PATTERN, $this->getBorderColor()) !== 1
) {
$this->addValidationError(new FormFieldValidationError(
'invalidValue',
Expand All @@ -149,6 +156,11 @@ public function getBadgeColor(): string
return $this->value['badgeColor'];
}

public function getBorderColor(): string
{
return $this->value['borderColor'];
}

/**
* Returns the selected icon or the default icon if the selection is invalid.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public static function getTestObjects(UserProfile $recipient, UserProfile $autho
->setBadge(
FontAwesomeIcon::fromString('trophy;false')->__toString(),
'rgba(255, 255, 255, 1)',
'rgba(50, 92, 132, 1)'
'rgba(50, 92, 132, 1)',
'rgba(0, 0, 0, 0)'
)
->create();

Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/files/style/ui/trophy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
align-self: flex-start;
display: inline-block;
border-radius: 50%;
box-shadow: inset 0 0 0 2px var(--trophy-border-color, transparent);

fa-icon {
transform: scale(0.5625);
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/lang/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4514,6 +4514,7 @@ Erlaubte Dateiendungen: gif, jpg, jpeg, png, webp]]></item>
<item name="wcf.style.colorPicker.lightness"><![CDATA[Helligkeit]]></item>
<item name="wcf.style.colorPicker.changeColor"><![CDATA[Farbe ändern]]></item>
<item name="wcf.style.colorPicker.changeBackgroundColor"><![CDATA[Hintergrundfarbe ändern]]></item>
<item name="wcf.style.colorPicker.changeBorderColor"><![CDATA[Rahmenfarbe ändern]]></item>
<item name="wcf.style.colorPicker.opacity"><![CDATA[Deckkraft]]></item>
<item name="wcf.style.setColorScheme"><![CDATA[Farbschema festlegen]]></item>
<item name="wcf.style.setColorScheme.dark"><![CDATA[Dunkles Farbschema]]></item>
Expand Down
1 change: 1 addition & 0 deletions wcfsetup/install/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4513,6 +4513,7 @@ Allowed extensions: gif, jpg, jpeg, png, webp]]></item>
<item name="wcf.style.colorPicker.lightness"><![CDATA[Lightness]]></item>
<item name="wcf.style.colorPicker.changeColor"><![CDATA[Change Color]]></item>
<item name="wcf.style.colorPicker.changeBackgroundColor"><![CDATA[Change Background Color]]></item>
<item name="wcf.style.colorPicker.changeBorderColor"><![CDATA[Change Border Color]]></item>
<item name="wcf.style.colorPicker.opacity"><![CDATA[Opacity]]></item>
<item name="wcf.style.setColorScheme"><![CDATA[Set Color Scheme]]></item>
<item name="wcf.style.setColorScheme.dark"><![CDATA[Dark Theme]]></item>
Expand Down
2 changes: 2 additions & 0 deletions wcfsetup/setup/db/install_com.woltlab.wcf.php
Original file line number Diff line number Diff line change
Expand Up @@ -3868,6 +3868,8 @@
->length(255),
VarcharDatabaseTableColumn::create('badgeColor')
->length(255),
VarcharDatabaseTableColumn::create('borderColor')
->length(255),
DefaultFalseBooleanDatabaseTableColumn::create('isDisabled'),
DefaultFalseBooleanDatabaseTableColumn::create('awardAutomatically'),
DefaultFalseBooleanDatabaseTableColumn::create('revokeAutomatically'),
Expand Down
Loading