Skip to content

Commit 5e36851

Browse files
committed
#2 feat: add helper function refactor color value formatting
1 parent 179efd8 commit 5e36851

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

common/helpers.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
<?php
22

3-
// Helper functions go here...
3+
if (!function_exists('color_value_format')) {
4+
/**
5+
* @param string $value
6+
* @param string $color
7+
*
8+
* @return string
9+
*/
10+
function color_value_format(string $value, string $color ): string
11+
{
12+
$value = str_replace(' ', ' \space ', $value);
13+
14+
return '$${\color{'.$color.'}'.$value.'}$$';
15+
}
16+
}

resources/views/md/field_types/single_select.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
@endphp
55

66
@if($fromValue != null && $toValue != null)
7-
**`{{ $fieldName }}`** has been changed from $${\color{<?= $fromColor ?>}{{ $fromValue }}}$$ to $${\color{<?= $toColor ?>}{{ $toValue }}}$$.
7+
**`{{ $fieldName }}`** has been changed from {{ color_value_format($fromValue, $fromColor) }} to {{ color_value_format($toValue, $toColor) }}.
88
@elseif ($toValue == null)
99
The value of **`{{ $fieldName }}`** has been removed.
1010
@else
11-
**`{{ $fieldName }}`** has been set to $${\color{<?= $toColor ?>}{{ $toValue }}}$$.
11+
**`{{ $fieldName }}`** has been set to {{ color_value_format($toValue, $toColor) }}.
1212
@endif

0 commit comments

Comments
 (0)