Skip to content

Commit

Permalink
tweaks and unit some components
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiducho committed Oct 25, 2024
1 parent 9d1a288 commit e866f9a
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 47 deletions.
26 changes: 26 additions & 0 deletions src/components/gps/AdminGrandPrixPageHeader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
<div class="md:col-span-2">
<PTitle :name="'Administración de ' + props.grandPrix.name + ' de ' + grandPrix.season.name" />
</div>
<div class="md:col-span-1">
<GrandPrixPagination
is-admin-pag
:competition="props.competition"
:grand-prix="props.grandPrix"
/>
</div>
</div>
</template>

<script setup lang="ts">
import PTitle from "@/components/lib/PTitle.vue";
import GrandPrixPagination from "@/components/gps/GrandPrixPagination.vue";
import {GrandPrix} from "@/types/GrandPrix";
import {Competition} from "@/types/Competition";
const props = defineProps({
grandPrix: { type: GrandPrix, required: true },
competition: { type: Competition, required: true },
})
</script>
2 changes: 1 addition & 1 deletion src/components/lib/forms/PButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default defineComponent({
@apply bg-yellow-500 hover:bg-yellow-600 dark:focus:ring-offset-gray-800 text-white;
}
&.green, &.success {
@apply bg-green-400 hover:bg-green-600 dark:focus:ring-offset-gray-800 text-white;
@apply bg-green-500 hover:bg-green-600 dark:focus:ring-offset-gray-800 text-white;
}
&.blue, &.info {
@apply bg-blue-500 hover:bg-blue-600 dark:focus:ring-offset-gray-800 text-white;
Expand Down
90 changes: 51 additions & 39 deletions src/components/lib/forms/PCheckbox.vue
Original file line number Diff line number Diff line change
@@ -1,57 +1,69 @@
<template>
<div class="flex items-center mb-4 me-4">
<input id="checkbox" type="checkbox"
:checked="modelValue"
@change="handleChange"
:class="checkboxClasses"
>
<label for="checkbox" class="ms-2 text-sm font-medium text-gray-700 dark:text-gray-300">
<slot></slot>
</label>
</div>
<div class="flex items-center mb-4 me-4">
<input
:id="`checkbox-${id}`"
type="checkbox"
:checked="(modelValue) ? modelValue : checked"
:class="checkboxClasses"
@change="handleChange"
>
<label
:for="`checkbox-${id}`"
class="ms-2 text-sm font-medium text-gray-700 dark:text-gray-300"
>
<slot />
</label>
</div>
</template>

<script setup lang="ts">
import {computed, defineModel} from 'vue';
const modelValue = defineModel<boolean>({ required: true });
const modelValue = defineModel<boolean>({required: false});
const props = withDefaults(defineProps<{
color?: 'primary' | 'secondary' | 'gray' | 'warning' | 'danger';
id?: number;
checked?: boolean
}>(), {
color: 'primary',
id: 0,
checked: false
});
const handleChange = (event: Event) => {
modelValue.value = (event.target as HTMLInputElement).checked;
modelValue.value = (event.target as HTMLInputElement).checked;
};
interface Props {
color?: 'primary' | 'secondary' | 'gray' | 'warning' | 'danger';
}
const props = withDefaults(defineProps<Props>(), {
color: 'primary'
});
const checkboxClasses = computed(() => ({
'checkbox': true, // Estilos base
[props.color]: true // Colores tienen el mismo nombre que las clases de css
'checkbox': true, // Estilos base
[props.color]: true // Colores tienen el mismo nombre que las clases de css
}));
</script>

<style lang="scss" scoped>
.checkbox {
@apply cursor-pointer w-5 h-5 rounded focus:ring-2 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:ring-offset-gray-800;
&.primary {
@apply text-purple-600 accent-purple-500 focus:ring-purple-500 dark:focus:ring-purple-600;
}
&.secondary {
@apply text-blue-600 accent-blue-500 focus:ring-blue-500 dark:focus:ring-blue-600;
}
&.gray {
@apply text-gray-600 accent-gray-500 focus:ring-gray-500 dark:focus:ring-gray-600;
}
&.warning {
@apply text-yellow-600 accent-yellow-500 focus:ring-yellow-500 dark:focus:ring-yellow-600;
}
&.danger {
@apply text-red-600 accent-red-500 focus:ring-red-500 dark:focus:ring-red-600;
}
@apply cursor-pointer w-5 h-5 rounded focus:ring-2 border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:ring-offset-gray-800;
&.primary {
@apply text-purple-600 accent-purple-500 focus:ring-purple-500 dark:focus:ring-purple-600;
}
&.secondary {
@apply text-blue-600 accent-blue-500 focus:ring-blue-500 dark:focus:ring-blue-600;
}
&.gray {
@apply text-gray-600 accent-gray-500 focus:ring-gray-500 dark:focus:ring-gray-600;
}
&.warning {
@apply text-yellow-600 accent-yellow-500 focus:ring-yellow-500 dark:focus:ring-yellow-600;
}
&.danger {
@apply text-red-600 accent-red-500 focus:ring-red-500 dark:focus:ring-red-600;
}
}
</style>
</style>
22 changes: 15 additions & 7 deletions src/components/lib/forms/PInput.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<template>
<fieldset class="w-full mb-3">
<label v-if="label" class="block tracking-wide text-gray-700 dark:text-gray-300 font-bold mb-2" :for="name">
{{ label }}
</label>
<p-label
v-if="label"
:for="name"
>
{{ name }}
</p-label>
<input
class="appearance-none block w-full text-gray-700 dark:text-gray-200 border border-gray-200 rounded py-3 px-4 dark:bg-gray-700 dark:border-gray-600 leading-tight focus:ring-blue-500 focus:outline-none focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500"
:maxlength="maxLenght" :id="name" :name="name"
:type="type" :placeholder="placeholder"
:id="name"
v-bind="$attrs"
v-model="model"
/>
class="appearance-none block w-full text-gray-700 dark:text-gray-200 border border-gray-200 rounded py-3 px-4 dark:bg-gray-700 dark:border-gray-600 leading-tight focus:ring-blue-500 focus:outline-none focus:border-blue-500 dark:focus:ring-blue-500 dark:focus:border-blue-500"
:maxlength="maxLenght"
:name="name"
:type="type"
:placeholder="placeholder"
>
</fieldset>
</template>

<script setup lang="ts" generic="T">
import PLabel from "@/components/lib/forms/PLabel.vue";
const model = defineModel<T>();
const props = withDefaults(defineProps<{
Expand Down
22 changes: 22 additions & 0 deletions src/components/lib/forms/PLabel.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<label
class="block tracking-wide text-gray-700 dark:text-gray-300 font-bold mb-2"
:for="props.name"
>
{{ props.label }}
</label>
</template>

<script setup lang="ts">
const props = withDefaults(defineProps<{
label?: string;
name?: string;
}>(), {
label: '',
name: ''
})
</script>

<style scoped lang="scss">
</style>

0 comments on commit e866f9a

Please sign in to comment.