Skip to content

Commit

Permalink
Merge pull request #105 from Setono/colors
Browse files Browse the repository at this point in the history
Add color and background color to the callout
  • Loading branch information
loevgaard authored Jan 24, 2024
2 parents f161ac1 + 59e04e5 commit ac16ecb
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Form/Type/CalloutType.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
},
'placeholder' => 'setono_sylius_callout.form.callout.select_position',
])
->add('color', TextType::class, [
'label' => 'setono_sylius_callout.form.callout.color',
'required' => false,
])
->add('backgroundColor', TextType::class, [
'label' => 'setono_sylius_callout.form.callout.background_color',
'required' => false,
])
->add('enabled', CheckboxType::class, [
'label' => 'setono_sylius_callout.form.callout.enabled',
'required' => false,
Expand Down
24 changes: 24 additions & 0 deletions src/Model/Callout.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class Callout implements CalloutInterface

protected ?string $position = self::DEFAULT_KEY;

protected ?string $color = null;

protected ?string $backgroundColor = null;

/** @var Collection<array-key, BaseChannelInterface> */
protected Collection $channels;

Expand Down Expand Up @@ -142,6 +146,26 @@ public function setPosition(?string $position): void
$this->position = $position;
}

public function getColor(): ?string
{
return $this->color;
}

public function setColor(?string $color): void
{
$this->color = $color;
}

public function getBackgroundColor(): ?string
{
return $this->backgroundColor;
}

public function setBackgroundColor(?string $backgroundColor): void
{
$this->backgroundColor = $backgroundColor;
}

public function getText(): ?string
{
return $this->getCalloutTranslation()->getText();
Expand Down
8 changes: 8 additions & 0 deletions src/Model/CalloutInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public function getPosition(): ?string;

public function setPosition(?string $position): void;

public function getColor(): ?string;

public function setColor(?string $color): void;

public function getBackgroundColor(): ?string;

public function setBackgroundColor(?string $backgroundColor): void;

public function getText(): ?string;

public function setText(string $text): void;
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/doctrine/model/Callout.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<field name="priority" type="integer"/>
<field name="elements" type="json"/>
<field name="position" type="string"/>
<field name="color" type="string" nullable="true"/>
<field name="backgroundColor" type="string" nullable="true"/>
<field name="enabled" type="boolean"/>
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
Expand Down
44 changes: 44 additions & 0 deletions src/Resources/config/validation/Callout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,49 @@
</option>
</constraint>
</property>

<property name="color">
<constraint name="CssColor">
<option name="formats">
<value>hex_long</value>
<value>hex_long_with_alpha</value>
<value>hex_short</value>
<value>hex_short_with_alpha</value>
<value>basic_named_colors</value>
<value>extended_named_colors</value>
<value>system_colors</value>
<value>keywords</value>
<value>rgb</value>
<value>rgba</value>
<value>hsl</value>
<value>hsla</value>
</option>
<option name="groups">
<value>setono_sylius_callout</value>
</option>
</constraint>
</property>

<property name="backgroundColor">
<constraint name="CssColor">
<option name="formats">
<value>hex_long</value>
<value>hex_long_with_alpha</value>
<value>hex_short</value>
<value>hex_short_with_alpha</value>
<value>basic_named_colors</value>
<value>extended_named_colors</value>
<value>system_colors</value>
<value>keywords</value>
<value>rgb</value>
<value>rgba</value>
<value>hsl</value>
<value>hsla</value>
</option>
<option name="groups">
<value>setono_sylius_callout</value>
</option>
</constraint>
</property>
</class>
</constraint-mapping>
2 changes: 2 additions & 0 deletions src/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
setono_sylius_callout:
form:
callout:
background_color: Background color
channels: Channels
code: Code
color: Color
elements: Element
element_labels:
default: Default
Expand Down
17 changes: 15 additions & 2 deletions src/Resources/views/Admin/Callout/_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,21 @@
</div>
<div class="ui segment">
<h4 class="ui dividing header">{{ 'setono_sylius_callout.form.callout.layout'|trans }}</h4>
{{ form_row(form.elements) }}
{{ form_row(form.position) }}

<div class="ui two column stackable grid">
<div class="column">
<div class="ui segment">
{{ form_row(form.elements) }}
{{ form_row(form.position) }}
</div>
</div>
<div class="column">
<div class="ui segment">
{{ form_row(form.color) }}
{{ form_row(form.backgroundColor) }}
</div>
</div>
</div>
</div>
<div class="ui segment">
<h4 class="ui dividing header">{{ 'setono_sylius_callout.form.callout.rules'|trans }}</h4>
Expand Down

0 comments on commit ac16ecb

Please sign in to comment.