Compare commits

..

No commits in common. "84f369f4c685ccc09ae61dc678fce4d62c472d25" and "8ebb55e31a4e2767684b7f2c1f1ef1605b686c91" have entirely different histories.

11 changed files with 21 additions and 87 deletions

View file

@ -11,7 +11,7 @@
<style>
body {
background-color: var(--color-primary);
background-color: #f5f5f5;
font-family: var(--font-body), serif;
}

View file

@ -1,11 +1,5 @@
:root {
--color-primary: #f5f5f5;
--color-primary: #000;
--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;
}

View file

@ -1,22 +0,0 @@
<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>

View file

@ -12,7 +12,7 @@
<style scoped>
.card {
padding: 2rem;
background-color: var(--card-background);
background-color: lightgray;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 0.5rem;
}

View file

@ -5,7 +5,6 @@ defineProps<{
placeholder: string
buttonText: string
inputName: string
inputId?: string
}>()
const emit = defineEmits(['action'])
@ -14,8 +13,7 @@ const emit = defineEmits(['action'])
<template>
<div class="form-group">
<input :id="inputId"
v-model="model"
<input v-model="model"
:name="inputName"
:placeholder="placeholder"
type="text">
@ -26,8 +24,8 @@ const emit = defineEmits(['action'])
<style scoped>
button {
background-color: var(--color-action-button);
color: var(--color-action-button-text, white);
background-color: #4caf50;
color: white;
padding: .5rem 1rem;
border: none;
border-radius: 0 4px 4px 0;

View file

@ -55,10 +55,6 @@ const handleLogin = async () => {
gap: 1rem;
}
.error-message {
color: var(--color-error-text, red);
}
.password-form {
display: flex;
flex-direction: column;

View file

@ -50,7 +50,7 @@ form {
}
.error {
color: var(--color-error-text, red);
color: red;
padding: 2em;
}
</style>

View file

@ -60,7 +60,7 @@ const handleRegistration = async () => {
}
.error-message {
color: var(--color-error-text, red);
color: red;
text-align: center;
}

View file

@ -79,6 +79,7 @@ dt {
display: flex;
flex-direction: column;
padding: 2rem;
justify-content: center;
max-width: 40rem;
margin: 0 auto;
}

View file

@ -2,8 +2,6 @@
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<{
@ -11,18 +9,15 @@ 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) => {
if (error.response.status === 404)
errorMessage.value = "No movies found"
alert(error.message)
});
}
@ -42,27 +37,23 @@ const addMovieToList = (movie: MovieSearchResult) => {
</script>
<template>
<div class="content">
<div>
<h2>Movie Search</h2>
<form @submit.prevent="searchMovies">
<label for="search">Search Movies</label>
<InputAction
v-model="searchQuery"
button-text="Search"
input-id="search"
input-name="search"
placeholder="Enter a movie title"
@action="searchMovies"
/>
<div>
<input id="search" v-model="searchQuery" type="text"/>
<button>Search</button>
</div>
</form>
<p v-if="errorMessage" class="error-message">{{ errorMessage }}</p>
<ul v-else class="results-list">
<ul 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>
<ButtonAction button-text="Add Movie" @action="addMovieToList(movie)"/>
<button @click="addMovieToList(movie)">Add Movie</button>
</div>
</li>
</ul>
@ -72,22 +63,6 @@ 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;
@ -108,12 +83,9 @@ label {
.movie-result {
display: flex;
flex-direction: row;
border: 1px solid rgba(0, 0, 0, 0.3);
box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.1);
border: 1px solid black;
align-items: center;
text-align: center;
border-radius: 0.3rem;
background-color: var(--result-background);
}
.movie-result img {
@ -121,9 +93,4 @@ label {
width: 10rem;
}
.content {
display: flex;
flex-direction: column;
margin: 0 auto;
}
</style>

View file

@ -37,11 +37,11 @@ const emit = defineEmits<{
right: 0;
bottom: 0;
width: 40%;
background: var(--panel-background, #fff);
background: var(--color-surface, #fff);
z-index: 101;
overflow-y: auto;
padding: 1rem;
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
padding: 3rem;
}
.close-button {