-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transition Inertia Vue stubs to
<script setup>
syntax (#127)
* Transition to <script setup> * update inertia version * Fix autofocus of Input component * use value property Co-authored-by: Taylor Otwell <taylor@laravel.com>
- Loading branch information
1 parent
5af95ec
commit 9680289
Showing
20 changed files
with
455 additions
and
631 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
<script setup> | ||
defineProps({ | ||
type: { | ||
type: String, | ||
default: 'submit', | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<button :type="type" class="inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:shadow-outline-gray transition ease-in-out duration-150"> | ||
<slot /> | ||
</button> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: { | ||
type: { | ||
type: String, | ||
default: 'submit', | ||
}, | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
<template> | ||
<input type="checkbox" :value="value" v-model="proxyChecked" | ||
class="rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"> | ||
</template> | ||
<script setup> | ||
import { computed } from 'vue'; | ||
<script> | ||
export default { | ||
emits: ['update:checked'], | ||
const emit = defineEmits(['update:checked']); | ||
props: { | ||
checked: { | ||
type: [Array, Boolean], | ||
default: false, | ||
}, | ||
value: { | ||
default: null, | ||
}, | ||
const props = defineProps({ | ||
checked: { | ||
type: [Array, Boolean], | ||
default: false, | ||
}, | ||
value: { | ||
default: null, | ||
}, | ||
}); | ||
computed: { | ||
proxyChecked: { | ||
get() { | ||
return this.checked; | ||
}, | ||
const proxyChecked = computed({ | ||
get() { | ||
return props.checked; | ||
}, | ||
set(val) { | ||
this.$emit("update:checked", val); | ||
}, | ||
}, | ||
set(val) { | ||
emit("update:checked", val); | ||
}, | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<input type="checkbox" :value="value" v-model="proxyChecked" | ||
class="rounded border-gray-300 text-indigo-600 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 4 additions & 10 deletions
14
stubs/inertia-vue/resources/js/Components/DropdownLink.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
<script setup> | ||
import { Link } from '@inertiajs/inertia-vue3'; | ||
</script> | ||
|
||
<template> | ||
<Link class="block w-full px-4 py-2 text-left text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out"> | ||
<slot /> | ||
</Link> | ||
</template> | ||
|
||
<script> | ||
import { Link } from '@inertiajs/inertia-vue3'; | ||
export default { | ||
components: { | ||
Link, | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
<template> | ||
<input class="border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm" :value="modelValue" @input="$emit('update:modelValue', $event.target.value)" ref="input"> | ||
</template> | ||
<script setup> | ||
import { onMounted, ref } from 'vue'; | ||
defineProps(['modelValue']); | ||
<script> | ||
export default { | ||
props: ['modelValue'], | ||
defineEmits(['update:modelValue']); | ||
emits: ['update:modelValue'], | ||
const input = ref(null); | ||
methods: { | ||
focus() { | ||
this.$refs.input.focus() | ||
} | ||
onMounted(() => { | ||
if (input.value.hasAttribute('autofocus')) { | ||
input.value.focus(); | ||
} | ||
} | ||
}); | ||
</script> | ||
|
||
<template> | ||
<input class="border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm" :value="modelValue" @input="$emit('update:modelValue', $event.target.value)" ref="input"> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
<script setup> | ||
defineProps(['message']); | ||
</script> | ||
|
||
<template> | ||
<div v-show="message"> | ||
<p class="text-sm text-red-600"> | ||
{{ message }} | ||
</p> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['message'] | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
<script setup> | ||
defineProps(['value']); | ||
</script> | ||
|
||
<template> | ||
<label class="block font-medium text-sm text-gray-700"> | ||
<span v-if="value">{{ value }}</span> | ||
<span v-else><slot /></span> | ||
</label> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['value'] | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
<script setup> | ||
import { computed } from 'vue'; | ||
import { Link } from '@inertiajs/inertia-vue3'; | ||
const props = defineProps(['href', 'active']); | ||
const classes = computed(() => props.active | ||
? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out' | ||
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out' | ||
); | ||
</script> | ||
|
||
<template> | ||
<Link :href="href" :class="classes"> | ||
<slot /> | ||
</Link> | ||
</template> | ||
|
||
<script> | ||
import { Link } from '@inertiajs/inertia-vue3'; | ||
export default { | ||
components: { | ||
Link, | ||
}, | ||
props: ['href', 'active'], | ||
computed: { | ||
classes() { | ||
return this.active | ||
? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out' | ||
: 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out' | ||
} | ||
} | ||
} | ||
</script> |
32 changes: 12 additions & 20 deletions
32
stubs/inertia-vue/resources/js/Components/ResponsiveNavLink.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
<script setup> | ||
import { computed } from 'vue'; | ||
import { Link } from '@inertiajs/inertia-vue3'; | ||
const props = defineProps(['href', 'active']); | ||
const classes = computed(() => props.active | ||
? 'block pl-3 pr-4 py-2 border-l-4 border-indigo-400 text-base font-medium text-indigo-700 bg-indigo-50 focus:outline-none focus:text-indigo-800 focus:bg-indigo-100 focus:border-indigo-700 transition duration-150 ease-in-out' | ||
: 'block pl-3 pr-4 py-2 border-l-4 border-transparent text-base font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-50 hover:border-gray-300 focus:outline-none focus:text-gray-800 focus:bg-gray-50 focus:border-gray-300 transition duration-150 ease-in-out' | ||
); | ||
</script> | ||
|
||
<template> | ||
<Link :href="href" :class="classes"> | ||
<slot /> | ||
</Link> | ||
</template> | ||
|
||
<script> | ||
import { Link } from '@inertiajs/inertia-vue3'; | ||
export default { | ||
components: { | ||
Link, | ||
}, | ||
props: ['href', 'active'], | ||
computed: { | ||
classes() { | ||
return this.active | ||
? 'block pl-3 pr-4 py-2 border-l-4 border-indigo-400 text-base font-medium text-indigo-700 bg-indigo-50 focus:outline-none focus:text-indigo-800 focus:bg-indigo-100 focus:border-indigo-700 transition duration-150 ease-in-out' | ||
: 'block pl-3 pr-4 py-2 border-l-4 border-transparent text-base font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-50 hover:border-gray-300 focus:outline-none focus:text-gray-800 focus:bg-gray-50 focus:border-gray-300 transition duration-150 ease-in-out' | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.