Skip to content

Commit

Permalink
Convert some svg icons code to components
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimBougaoua committed Oct 5, 2024
1 parent c900b4a commit 694c191
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 126 deletions.
14 changes: 14 additions & 0 deletions resources/js/Shared/Icons/CalendarIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="me-1 h-4 w-4 text-gray-400">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5" />
</svg>
</template>
38 changes: 38 additions & 0 deletions resources/js/Shared/Icons/CallIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script setup>
defineProps({
answered: { type: Boolean, default: true },
isNormal: { type: Boolean, default: false },
});
</script>

<template>
<!-- icon phone cancel -->
<svg
v-if="!answered && !isNormal"
xmlns="http://www.w3.org/2000/svg"
class="me-2 h-4 w-4 text-red-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M16 8l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2M5 3a2 2 0 00-2 2v1c0 8.284 6.716 15 15 15h1a2 2 0 002-2v-3.28a1 1 0 00-.684-.948l-4.493-1.498a1 1 0 00-1.21.502l-1.13 2.257a11.042 11.042 0 01-5.516-5.517l2.257-1.128a1 1 0 00.502-1.21L9.228 3.683A1 1 0 008.279 3H5z" />
</svg>

<!-- call accepted -->
<svg
v-if="answered || isNormal"
xmlns="http://www.w3.org/2000/svg"
:class="`h-4 w-4 ${isNormal ? 'icon-sidebar relative inline' : 'me-2 text-green-600'}`"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
</svg>
</template>
14 changes: 14 additions & 0 deletions resources/js/Shared/Icons/EditIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon-sidebar relative inline h-3 w-3 text-gray-300 hover:text-gray-600 dark:text-gray-400"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
</template>
15 changes: 15 additions & 0 deletions resources/js/Shared/Icons/MapPointerIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon-sidebar relative inline h-4 w-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
</template>
14 changes: 14 additions & 0 deletions resources/js/Shared/Icons/MoonIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="me-1 h-4 w-4 text-gray-400">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z" />
</svg>
</template>
31 changes: 31 additions & 0 deletions resources/js/Shared/Icons/StarIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script setup>
defineProps({
isFavorite: { type: Boolean, default: false },
});
</script>

<template>
<svg
v-if="isFavorite"
xmlns="http://www.w3.org/2000/svg"
class="h-4 w-4 text-gray-400 hover:cursor-pointer hover:text-yellow-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z" />
</svg>

<svg
v-else
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 text-yellow-500 hover:cursor-pointer"
viewBox="0 0 20 20"
fill="currentColor">
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
</template>
14 changes: 14 additions & 0 deletions resources/js/Shared/Icons/WorldIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon-sidebar relative inline h-4 w-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</template>
15 changes: 2 additions & 13 deletions resources/js/Shared/Modules/Addresses.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Dropdown from '@/Shared/Form/Dropdown.vue';
import JetConfirmationModal from '@/Components/Jetstream/ConfirmationModal.vue';
import JetDangerButton from '@/Components/Jetstream/DangerButton.vue';
import JetSecondaryButton from '@/Components/Jetstream/SecondaryButton.vue';
import MapPointerIcon from '@/Shared/Icons/MapPointerIcon.vue';
const props = defineProps({
layoutData: Object,
Expand Down Expand Up @@ -150,19 +151,7 @@ const destroy = () => {
<div class="mb-3 items-center justify-between border-b border-gray-200 pb-2 dark:border-gray-700 sm:flex">
<div class="mb-2 sm:mb-0">
<span class="relative me-1">
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon-sidebar relative inline h-4 w-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 11a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
<MapPointerIcon />
</span>

<span class="font-semibold">
Expand Down
44 changes: 3 additions & 41 deletions resources/js/Shared/Modules/Calls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import PrettyButton from '@/Shared/Form/PrettyButton.vue';
import PrettySpan from '@/Shared/Form/PrettySpan.vue';
import TextArea from '@/Shared/Form/TextArea.vue';
import Errors from '@/Shared/Form/Errors.vue';
import CallIcon from '@/Shared/Icons/CallIcon.vue';
const props = defineProps({
data: Object,
Expand Down Expand Up @@ -153,18 +154,7 @@ const destroy = (call) => {
<div class="mb-3 items-center justify-between border-b border-gray-200 pb-2 dark:border-gray-700 sm:flex">
<div class="mb-2 sm:mb-0">
<span class="relative me-1">
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon-sidebar relative inline h-4 w-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
</svg>
<CallIcon :isNormal="true" />
</span>

<span class="font-semibold"> {{ $t('Calls') }} </span>
Expand Down Expand Up @@ -403,35 +393,7 @@ const destroy = (call) => {
<div v-if="editedCallId !== call.id" class="flex items-center justify-between p-3">
<div class="flex items-center">
<div>
<!-- icon phone cancel -->
<svg
v-if="!call.answered"
xmlns="http://www.w3.org/2000/svg"
class="me-2 h-4 w-4 text-red-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M16 8l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2M5 3a2 2 0 00-2 2v1c0 8.284 6.716 15 15 15h1a2 2 0 002-2v-3.28a1 1 0 00-.684-.948l-4.493-1.498a1 1 0 00-1.21.502l-1.13 2.257a11.042 11.042 0 01-5.516-5.517l2.257-1.128a1 1 0 00.502-1.21L9.228 3.683A1 1 0 008.279 3H5z" />
</svg>

<!-- call accepted -->
<svg
v-if="call.answered"
xmlns="http://www.w3.org/2000/svg"
class="me-2 h-4 w-4 text-green-600"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z" />
</svg>
<CallIcon :answered="call.answered" />
</div>

<span class="me-2 text-sm text-gray-500">{{ call.called_at }}</span>
Expand Down
15 changes: 3 additions & 12 deletions resources/js/Shared/Modules/ContactInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@
<div class="mb-3 items-center justify-between border-b border-gray-200 pb-2 dark:border-gray-700 sm:flex">
<div class="mb-2 sm:mb-0">
<span class="relative me-1">
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon-sidebar relative inline h-4 w-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<WorldIcon />
</span>

<span class="font-semibold">
Expand Down Expand Up @@ -163,6 +152,7 @@ import PrettySpan from '@/Shared/Form/PrettySpan.vue';
import TextInput from '@/Shared/Form/TextInput.vue';
import Dropdown from '@/Shared/Form/Dropdown.vue';
import Errors from '@/Shared/Form/Errors.vue';
import WorldIcon from '@/Shared/Icons/WorldIcon.vue';
export default {
components: {
Expand All @@ -171,6 +161,7 @@ export default {
TextInput,
Dropdown,
Errors,
WorldIcon,
},
props: {
Expand Down
43 changes: 8 additions & 35 deletions resources/js/Shared/Modules/ContactName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@
<div class="mb-1 items-center justify-between border-b border-gray-200 dark:border-gray-700 sm:flex">
<div class="mb-2 text-xs sm:mb-0">{{ $t('Name') }}</div>
<InertiaLink :href="data.url.edit" class="relative">
<svg
xmlns="http://www.w3.org/2000/svg"
class="icon-sidebar relative inline h-3 w-3 text-gray-300 hover:text-gray-600 dark:text-gray-400"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
</svg>
<EditIcon />
</InertiaLink>
</div>

Expand All @@ -30,43 +19,27 @@
:title="$t('Set as favorite')"
arrow-point-at-center
@click.prevent="toggleFavorite">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-4 w-4 text-gray-400 hover:cursor-pointer hover:text-yellow-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z" />
</svg>
<StarIcon />
</a-tooltip>

<!-- if the contact is a favorite -->
<svg
v-else
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 text-yellow-500 hover:cursor-pointer"
viewBox="0 0 20 20"
fill="currentColor"
@click.prevent="toggleFavorite">
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
</svg>
<StarIcon :isFavorite="localData.is_favorite" @click.prevent="toggleFavorite" />
</h1>
</div>
</template>

<script>
import { Link } from '@inertiajs/vue3';
import { Tooltip as ATooltip } from 'ant-design-vue';
import EditIcon from '@/Shared/Icons/EditIcon.vue';
import StarIcon from '@/Shared/Icons/StarIcon.vue';
export default {
components: {
InertiaLink: Link,
ATooltip,
EditIcon,
StarIcon
},
props: {
Expand Down
Loading

0 comments on commit 694c191

Please sign in to comment.