Skip to content

Commit

Permalink
Tag component refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
shivendra-webkul committed Oct 10, 2024
1 parent 4149b0f commit 79c7245
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,36 @@
detach-endpoint="{{ $detachEndpoint }}"
:added-tags='@json($addedTags)'
>
<template #tag-before>
{{ $tagBefore ?? '' }}
</template>

<template #tag-after>
{{ $tagAfter ?? '' }}
</template>

<x-admin::shimmer.tags count="3" />
</v-tags>

@pushOnce('scripts')
<script type="text/x-template" id="v-tags-template">
<div class="flex flex-wrap items-center gap-1">
<!-- Tags -->
<slot name="tag-before"></slot>

<span
class="flex items-center gap-1 rounded-md bg-rose-100 px-3 py-1.5 text-xs font-medium"
:style="{
'background-color': tag.color,
'color': backgroundColors.find(color => color.background === tag.color)?.text
}"
v-for="(tag, index) in tags"
v-html="tag.name"
v-text="tag.name"
>
</span>

<slot name="tag-after"></slot>

<!-- Add Button -->
<x-admin::dropdown ::close-on-click="false" position="bottom-{{ in_array(app()->getLocale(), ['fa', 'ar']) ? 'right' : 'left' }}">
<x-slot:toggle>
Expand Down
25 changes: 15 additions & 10 deletions packages/Webkul/Admin/src/Resources/views/leads/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,28 @@
</div>

<div class="mb-2">
@if (($days = $lead->rotten_days) > 0)
@php
$lead->tags->prepend([
'name' => '<span class="icon-rotten text-base"></span>' . trans('admin::app.leads.view.rotten-days', ['days' => $days]),
'color' => '#FEE2E2'
]);
@endphp
@endif

{!! view_render_event('admin.leads.view.tags.before', ['lead' => $lead]) !!}

<!-- Tags -->
<x-admin::tags
:attach-endpoint="route('admin.leads.tags.attach', $lead->id)"
:detach-endpoint="route('admin.leads.tags.detach', $lead->id)"
:added-tags="$lead->tags"
/>
>
<x-slot:tag-before>
@if (($days = $lead->rotten_days) > 0)
<span
class="flex items-center gap-1 rounded-md bg-rose-100 px-3 py-1.5 text-xs font-medium"
:style="{
'background-color': '#FEE2E2',
'color': '#DC2626',
}"
>
<span class="icon-rotten text-base"></span> @lang('admin::app.leads.view.rotten-days', ['days' => $days])
</span>
@endif
</x-slot>
</x-admin::tags>

{!! view_render_event('admin.leads.view.tags.after', ['lead' => $lead]) !!}
</div>
Expand Down
8 changes: 0 additions & 8 deletions packages/Webkul/Tag/src/Models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,4 @@ public function user()
{
return $this->belongsTo(UserProxy::modelClass());
}

/**
* Accessor to strip tags from the name attribute.
*/
public function getNameAttribute($value): string
{
return strip_tags($value);
}
}

0 comments on commit 79c7245

Please sign in to comment.