improved styling for movie search and added some css variables for colors
This commit is contained in:
parent
8ebb55e31a
commit
338cd36166
11 changed files with 87 additions and 21 deletions
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<style>
|
||||
body {
|
||||
background-color: #f5f5f5;
|
||||
background-color: var(--color-primary);
|
||||
font-family: var(--font-body), serif;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
:root {
|
||||
--color-primary: #000;
|
||||
--color-primary: #f5f5f5;
|
||||
--color-surface: #fff;
|
||||
--font-body: 'Ubuntu', serif;
|
||||
--result-background: #c4c1d2;
|
||||
--panel-background: #f5f5f5;
|
||||
--card-background: #c4c1d2;
|
||||
--color-action-button: #4caf50;
|
||||
--color-action-button-text: #fff;
|
||||
--color-error-text: red;
|
||||
}
|
||||
22
app/components/common/button-action.vue
Normal file
22
app/components/common/button-action.vue
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<script lang="ts" setup>
|
||||
defineProps<{
|
||||
buttonText: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['action'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button @click="emit('action')">{{ buttonText }}</button>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
button {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 0.25rem;
|
||||
background-color: var(--color-action-button);
|
||||
color: var(--color-action-button-text);
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
<style scoped>
|
||||
.card {
|
||||
padding: 2rem;
|
||||
background-color: lightgray;
|
||||
background-color: var(--card-background);
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ defineProps<{
|
|||
placeholder: string
|
||||
buttonText: string
|
||||
inputName: string
|
||||
inputId?: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['action'])
|
||||
|
|
@ -13,7 +14,8 @@ const emit = defineEmits(['action'])
|
|||
|
||||
<template>
|
||||
<div class="form-group">
|
||||
<input v-model="model"
|
||||
<input :id="inputId"
|
||||
v-model="model"
|
||||
:name="inputName"
|
||||
:placeholder="placeholder"
|
||||
type="text">
|
||||
|
|
@ -24,8 +26,8 @@ const emit = defineEmits(['action'])
|
|||
|
||||
<style scoped>
|
||||
button {
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
background-color: var(--color-action-button);
|
||||
color: var(--color-action-button-text, white);
|
||||
padding: .5rem 1rem;
|
||||
border: none;
|
||||
border-radius: 0 4px 4px 0;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ const handleLogin = async () => {
|
|||
gap: 1rem;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: var(--color-error-text, red);
|
||||
}
|
||||
|
||||
.password-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ form {
|
|||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
color: var(--color-error-text, red);
|
||||
padding: 2em;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -60,7 +60,7 @@ const handleRegistration = async () => {
|
|||
}
|
||||
|
||||
.error-message {
|
||||
color: red;
|
||||
color: var(--color-error-text, red);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ dt {
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 2rem;
|
||||
justify-content: center;
|
||||
max-width: 40rem;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
import type {MovieSearchResult} from "~/types/movie-search-results";
|
||||
import type {MovieList} from "~/types/movie-list";
|
||||
import type {ResourceResponse} from "@/types/api";
|
||||
import InputAction from "~/components/common/input-action.vue";
|
||||
import ButtonAction from "~/components/common/button-action.vue";
|
||||
|
||||
const emit = defineEmits(['add-movie']);
|
||||
const props = defineProps<{
|
||||
|
|
@ -9,15 +11,18 @@ const props = defineProps<{
|
|||
}>()
|
||||
|
||||
const searchQuery = ref("");
|
||||
const errorMessage = ref("");
|
||||
|
||||
const movies = ref<MovieSearchResult[]>([]);
|
||||
const searchMovies = () => {
|
||||
$api<ResourceResponse<MovieSearchResult[]>>(`/api/movies/search/${searchQuery.value}`, {
|
||||
method: "GET"
|
||||
}).then((response) => {
|
||||
errorMessage.value = "";
|
||||
movies.value = response.data
|
||||
}).catch((error) => {
|
||||
alert(error.message)
|
||||
if (error.response.status === 404)
|
||||
errorMessage.value = "No movies found"
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -37,23 +42,27 @@ const addMovieToList = (movie: MovieSearchResult) => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="content">
|
||||
<h2>Movie Search</h2>
|
||||
<form @submit.prevent="searchMovies">
|
||||
<label for="search">Search Movies</label>
|
||||
|
||||
<div>
|
||||
<input id="search" v-model="searchQuery" type="text"/>
|
||||
<button>Search</button>
|
||||
</div>
|
||||
<InputAction
|
||||
v-model="searchQuery"
|
||||
button-text="Search"
|
||||
input-id="search"
|
||||
input-name="search"
|
||||
placeholder="Enter a movie title"
|
||||
@action="searchMovies"
|
||||
/>
|
||||
</form>
|
||||
<ul class="results-list">
|
||||
<p v-if="errorMessage" class="error-message">{{ errorMessage }}</p>
|
||||
<ul v-else class="results-list">
|
||||
<li v-for="movie in movies" :key="movie.imdbId" class="movie-result">
|
||||
<img :src="movie.poster" alt="movie poster">
|
||||
<div class="movie-details">
|
||||
<span>{{ movie.title }}</span>
|
||||
<span>{{ movie.year }}</span>
|
||||
<button @click="addMovieToList(movie)">Add Movie</button>
|
||||
<ButtonAction button-text="Add Movie" @action="addMovieToList(movie)"/>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -63,6 +72,22 @@ const addMovieToList = (movie: MovieSearchResult) => {
|
|||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
h2 {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
label {
|
||||
margin-bottom: 0.5em;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: var(--color-error-text, red);
|
||||
text-align: center;
|
||||
margin: 5rem 0;
|
||||
}
|
||||
|
||||
.results-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -83,9 +108,12 @@ const addMovieToList = (movie: MovieSearchResult) => {
|
|||
.movie-result {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
border: 1px solid black;
|
||||
border: 1px solid rgba(0, 0, 0, 0.3);
|
||||
box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.1);
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
border-radius: 0.3rem;
|
||||
background-color: var(--result-background);
|
||||
}
|
||||
|
||||
.movie-result img {
|
||||
|
|
@ -93,4 +121,9 @@ const addMovieToList = (movie: MovieSearchResult) => {
|
|||
width: 10rem;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -37,11 +37,11 @@ const emit = defineEmits<{
|
|||
right: 0;
|
||||
bottom: 0;
|
||||
width: 40%;
|
||||
background: var(--color-surface, #fff);
|
||||
background: var(--panel-background, #fff);
|
||||
z-index: 101;
|
||||
overflow-y: auto;
|
||||
padding: 1rem;
|
||||
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
|
||||
padding: 3rem;
|
||||
}
|
||||
|
||||
.close-button {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue