Skip to content

Commit

Permalink
Projects Map, Articles, Gale Regionale (#62)
Browse files Browse the repository at this point in the history
* update regional controller

* added texts

* update articles pages

* update regional pages

* added map component

* update cards components

* added components
  • Loading branch information
FlorinZarafu committed Jun 28, 2023
1 parent dfa6e27 commit 28a4ea4
Show file tree
Hide file tree
Showing 14 changed files with 332 additions and 191 deletions.
56 changes: 33 additions & 23 deletions app/Http/Controllers/RegionalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace App\Http\Controllers;

use App\Models\County;
use App\Models\Project;
use Inertia\Inertia;

Expand All @@ -26,33 +27,42 @@ public function index()
],
];

$articles = [
$regions = [
[
'id' => 1,
'img' => '/images/project_img.png',
'author' => 'Ion Popescu',
'name' => 'Importanța educației remediare în România în timpul pandemiei',
'team' => 'Echipa BCR',
'content' => 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto accusantium praesentium eius, ut atque fuga culpa, similique sequi cum eos quis dolorum.',
'date' => '15.02.2022',
'cover_image' => '/images/project_img.png',
'status' => 'registration',
'name' => 'Galele Regionale Muntenia',
],
[
'id' => 2,
'img' => '/images/project_img.png',
'author' => 'Ion Popescu',
'name' => 'Importanța educației remediare în România în timpul pandemiei',
'team' => 'Echipa BCR',
'content' => 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto accusantium praesentium eius, ut atque fuga culpa, similique sequi cum eos quis dolorum.',
'date' => '15.02.2022',
'cover_image' => '/images/project_img.png',
'status' => 'finished',
'name' => 'Galele Regionale Muntenia',
],
[
'id' => 3,
'img' => '/images/project_img.png',
'author' => 'Ion Popescu',
'name' => 'Importanța educației remediare în România în timpul pandemiei',
'team' => 'Echipa BCR',
'content' => 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto accusantium praesentium eius, ut atque fuga culpa, similique sequi cum eos quis dolorum.',
'date' => '15.02.2022',
'cover_image' => '/images/project_img.png',
'status' => 'winners',
'name' => 'Galele Regionale Muntenia',
],
[
'id' => 4,
'cover_image' => '/images/project_img.png',
'status' => 'registration',
'name' => 'Galele Regionale Muntenia',
],
[
'id' => 5,
'cover_image' => '/images/project_img.png',
'status' => 'finished',
'name' => 'Galele Regionale Muntenia',
],
[
'id' => 6,
'cover_image' => '/images/project_img.png',
'status' => 'winners',
'name' => 'Galele Regionale Muntenia',
],
];

Expand Down Expand Up @@ -96,7 +106,7 @@ public function index()
return Inertia::render('Public/Regional/Regional', [
'query' => $projects,
'editions' => $editions,
'articles' => $articles,
'regions' => $regions,
'parteners' => $parteners,
'registration' => $registration,
'faqs' => $faqs,
Expand All @@ -109,15 +119,15 @@ public function edition()
$editions = [
[
'href' => '1',
'name' => 'Campionatul de bine 2020',
'name' => 'Gale Regionale 2020',
],
[
'href' => '2',
'name' => 'Campionatul de bine 2019',
'name' => 'Gale Regionale 2021',
],
[
'href' => '3',
'name' => 'Campionatul de bine 2018',
'name' => 'Gale Regionale 2022',
],
];

Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/cards/ArticleCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<h3 class="text-2xl font-bold text-gray-700 line-clamp-2">{{ data.name }}</h3>

<p class="text-base text-gray-500">{{ data.content }}</p>
<div class="text-base text-gray-500" v-html="data.content"></div>

<div class="flex items-center justify-between">
<p class="text-sm text-gray-500">{{ data.date }}</p>
Expand Down
57 changes: 57 additions & 0 deletions resources/js/Components/cards/Edition.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<li
class="flex flex-col col-span-1 bg-white divide-y divide-gray-200 rounded-lg shadow"
>
<div class="flex flex-col flex-1">
<Link
:href="route('regional.project', data.id)"
class="relative bg-gray-200 rounded-t-lg group-hover:opacity-75 sm:h-52"
>

<img
:src="data.cover_image!=='' ?data.cover_image: 'https://images.unsplash.com/photo-1508779544523-dd1b27685be3?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80'"
alt="imagine proiect"
class="object-cover object-center w-full h-full rounded-t-lg sm:h-full sm:w-full"
/>
</Link>

<div class="px-6 pt-6">
<p v-if="'registration' === data.status" class="pb-4 text-sm font-medium text-red-500">{{ $t('regional_registration') }}</p>
<p v-if="'finished' === data.status" class="pb-4 text-sm font-medium text-gray-500">{{ $t('regional_finished') }}</p>
<p v-if="'winners' === data.status" class="pb-4 text-sm font-medium text-red-500">{{ $t('regional_winners') }}</p>

<Link
:href="route('regional.project', data.id)"
class="mt-4 text-2xl font-bold text-gray-700"
>
{{ data.name }}
</Link>
</div>



<Link
:href="route('lastedition', data.id)"
class="flex items-center p-6 text-sm font-semibold gap-x-2 text-turqoise-500"
>
{{ $t('see') }}
<SvgLoader name="arrow_right" class="fill-turqoise-500 shrink-0" />
</Link>

</div>
</li>
</template>

<script setup>
/** Import from inertia. */
import { Link } from "@inertiajs/vue3";
/** Import components. */
import SvgLoader from "@/Components/SvgLoader.vue";
/** Component props. */
const props = defineProps({
data: Object,
cardType: String,
});
</script>
2 changes: 1 addition & 1 deletion resources/js/Components/cards/ProjectCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ import {computed, onMounted} from "vue";
});

onMounted(() => {
console.log(props.data);

});

const percentage = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/Components/cards/RegionalProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
>
<div class="flex flex-col flex-1">
<Link
:href="route('regional.project', data.slug)"
:href="route('regional.project', data.id)"
class="relative bg-gray-200 group-hover:opacity-75 sm:h-52"
>

Expand Down
146 changes: 146 additions & 0 deletions resources/js/Components/maps/Map.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<template>
<div>
<div id="map" class="rounded-lg" style="height: 550px"></div>
</div>
</template>

<script setup>
/** Import from vue. */
import { ref, onMounted } from 'vue';
const googleKey = import.meta.env.VITE_GOOGLE_KEY;
/** Component props. */
const props = defineProps({ data: Array });
/** Component emits */
const emit = defineEmits(['county-selected']);
const map = ref(null);
const selectedCounties = ref([]);
/** Intialize google map. */
async function initializeMap() {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = `https://maps.googleapis.com/maps/api/js?key=${googleKey}`;
script.async = true;
script.defer = true;
script.onload = () => {
resolve(window.google);
};
script.onerror = () => {
reject(new Error('Failed to load Google Maps API'));
};
document.head.appendChild(script);
});
}
/** Generate custom marker. */
const generateMarkerIcon = (numberOfProjects, isActive = false) => {
const fillColor = isActive ? '#41A6AC' : '#FFFFFF';
const svgMarkup = `<svg width="58" height="67" viewBox="0 0 58 67" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="path-1-inside-1_1033_47195" fill="white">
<path d="M49.5061 47.3762C60.8313 36.5382 60.8313 18.9664 49.5061 8.12846C38.1809 -2.70949 19.8191 -2.70949 8.4939 8.12846C-2.8313 18.9664 -2.8313 36.5382 8.4939 47.3762L29 67L49.5061 47.3762Z"/>
</mask>
<path d="M49.5061 47.3762C60.8313 36.5382 60.8313 18.9664 49.5061 8.12846C38.1809 -2.70949 19.8191 -2.70949 8.4939 8.12846C-2.8313 18.9664 -2.8313 36.5382 8.4939 47.3762L29 67L49.5061 47.3762Z" fill="${fillColor}"/>
<path d="M49.5061 47.3762L48.8147 46.6537L49.5061 47.3762ZM8.4939 47.3762L7.80251 48.0986L8.4939 47.3762ZM29 67L28.3086 67.7225L29 68.3841L29.6914 67.7225L29 67ZM48.8147 8.85094C59.7284 19.2951 59.7284 36.2095 48.8147 46.6537L50.1975 48.0986C61.9342 36.8669 61.9342 18.6377 50.1975 7.40599L48.8147 8.85094ZM9.1853 8.85094C20.1238 -1.61698 37.8762 -1.61698 48.8147 8.85094L50.1975 7.40599C38.4856 -3.802 19.5144 -3.80199 7.80251 7.40599L9.1853 8.85094ZM9.1853 46.6537C-1.72843 36.2095 -1.72843 19.2951 9.1853 8.85094L7.80251 7.40599C-3.93417 18.6377 -3.93417 36.8669 7.80251 48.0986L9.1853 46.6537ZM29.6914 66.2775L9.1853 46.6537L7.80251 48.0986L28.3086 67.7225L29.6914 66.2775ZM48.8147 46.6537L28.3086 66.2775L29.6914 67.7225L50.1975 48.0986L48.8147 46.6537Z" fill="black" mask="url(#path-1-inside-1_1033_47195)"/>
</svg>`;
return `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(svgMarkup)}`;
}
/** Filter projects based on marker selection. */
const filterProjects = (county, marker) => {
if (false === marker.get('clicked')) {
/** Zoom In and set coordoantes. */
map.value.setZoom(10);
map.value.panTo(county.coordinates);
marker.setIcon({
url: generateMarkerIcon(county.projects, true),
scaledSize: new google.maps.Size(40, 40),
});
marker.setLabel({
text: county.projects.toString(),
color: '#FFFFFF',
fontSize: '14px',
fontWeight: 'bold',
});
marker.set('clicked', true);
selectedCounties.value.push(county.id);
} else if (true === marker.get('clicked')) {
/** Zoom In and set coordoantes. */
map.value.setZoom(7);
map.value.panTo({ lat: 45.9432, lng: 24.9668 });
marker.setIcon({
url: generateMarkerIcon(county.projects, false),
scaledSize: new google.maps.Size(40, 40),
});
marker.setLabel({
text: county.projects.toString(),
color: '#333',
fontSize: '14px',
fontWeight: 'bold',
});
selectedCounties.value = selectedCounties.value.filter(item => item !== county.id);
marker.set('clicked', false);
}
emit('county-selected', selectedCounties.value);
}
/** Generate map markers for each county */
const generateMapMarkers = async () => {
/** Render map. */
const google = await initializeMap();
/** Map options, */
const mapOptions = {
center: { lat: 45.9432, lng: 24.9668 },
zoom: 7
};
/** Google map object, */
map.value = new google.maps.Map(document.getElementById('map'), mapOptions);
for (const county of props.data) {
try {
/** Intialize marker. */
const markerIcon = {
url: generateMarkerIcon(county.projects),
scaledSize: new google.maps.Size(40, 40)
};
/** Marker options, */
const marker = new google.maps.Marker({
position: county.coordinates,
map: map.value,
title: county.name,
icon: markerIcon,
label: {
text: county.projects.toString(),
color: '#333',
fontSize: '14px',
fontWeight: 'bold'
},
clicked: false
});
/** On marker click filter projects. */
marker.addListener('click', () => filterProjects(county, marker));
} catch (error) {
console.error(error);
}
}
}
onMounted(() => generateMapMarkers());
</script>
16 changes: 7 additions & 9 deletions resources/js/Components/modals/ModalAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0"
enter-to="opacity-100" leave="ease-in duration-200" leave-from="opacity-100"
leave-to="opacity-0">
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"/>
<div class="fixed inset-0 transition-opacity bg-gray-500 bg-opacity-75"/>
</TransitionChild>

<div class="fixed inset-0 z-10 overflow-y-auto">
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
<div class="flex items-end justify-center min-h-full p-4 text-center sm:items-center sm:p-0">
<TransitionChild as="template" enter="ease-out duration-300"
enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
enter-to="opacity-100 translate-y-0 sm:scale-100"
leave="ease-in duration-200"
leave-from="opacity-100 translate-y-0 sm:scale-100"
leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
<DialogPanel
class="relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6">
class="relative px-4 pt-5 pb-4 overflow-hidden text-left transition-all transform bg-white rounded-lg shadow-xl sm:my-8 sm:w-full sm:max-w-lg sm:p-6">
<div>
<div
class="mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-green-100">
<CheckIcon class="h-6 w-6 text-green-500" aria-hidden="true"/>
class="flex items-center justify-center w-12 h-12 mx-auto bg-green-100 rounded-full">
<CheckIcon class="w-6 h-6 text-green-500" aria-hidden="true"/>
</div>

<div class="mt-3 text-center sm:mt-5">
Expand All @@ -47,15 +47,15 @@
<div class="mt-5 sm:mt-6 sm:grid sm:grid-flow-row-dense sm:grid-cols-2 sm:gap-3">

<button type="button"
class="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:col-start-1 sm:mt-0"
class="inline-flex justify-center w-full px-3 py-2 mt-3 text-sm font-semibold text-gray-900 bg-white rounded-md shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:col-start-1 sm:mt-0"
@click="open = false">
{{ cancelModalText }}
</button>

<button
@click="action"
type="button"
class="inline-flex w-full justify-center rounded-md bg-primary-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 sm:col-start-2"
class="inline-flex justify-center w-full px-3 py-2 text-sm font-semibold text-white rounded-md shadow-sm bg-primary-500 hover:bg-primary-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 sm:col-start-2"
>
{{ actionModalText }}
</button>
Expand Down Expand Up @@ -102,8 +102,6 @@ const props = defineProps({
/** Local state. */
const open = ref(false);
console.log(props.actionType)
/** Delete action. */
const action = () => {
/** Initialize inertia from Object. */
Expand Down
Loading

0 comments on commit 28a4ea4

Please sign in to comment.