diff --git a/assets/styles/app.css b/assets/styles/app.css index 8a7ad86..790b83a 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -1,104 +1,106 @@ body { - font-family: Arial, sans-serif; - /* background-color: #f0f0f0; */ - color: #1a2c4c; + font-family: Arial, sans-serif; + /* background-color: #f0f0f0; */ + color: #1a2c4c; } .profile-container { - background-color: #fff; - border: 1px solid #5c5d7f; - border-radius: 8px; - max-width: 600px; - margin: 20px auto; - padding: 20px; - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); - } - - .profile-header { - display: flex; - align-items: center; - border-bottom: 1px solid #5c5d7f; - padding-bottom: 10px; - margin-bottom: 20px; - } - - .profile-image { - border-radius: 50%; - width: 100px; - height: 100px; - object-fit: cover; - margin-right: 20px; + background-color: #fff; + border: 1px solid #5c5d7f; + border-radius: 8px; + margin: 20px auto; + padding: 20px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + width: 70%; +} + +.profile-header { + display: flex; + align-items: center; + border-bottom: 1px solid #5c5d7f; + padding-bottom: 10px; + margin-bottom: 20px; +} + +.profile-image { + border-radius: 50%; + width: 100px; + height: 100px; + object-fit: cover; + margin-right: 20px; } .profile-info { - flex-grow: 1; - } - - .profile-info h1 { - font-size: 24px; - margin: 0; - color: #1a2c4c; - } - + flex-grow: 1; +} + +.profile-info h1 { + font-size: 24px; + margin: 0; + color: #1a2c4c; +} + .profile-info p { - margin: 5px 0; - color: #38476b; + margin: 5px 0; + color: #38476b; } .horizontal-layout { - display: flex; - align-items: center; + display: flex; + align-items: center; } .follow-button { - background-color: #38476b; - color: #fff; - padding: 10px 20px; - border: none; - border-radius: 4px; - cursor: pointer; - text-align: center; - text-decoration: none; - margin: 4px; + background-color: #38476b; + color: #fff; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + text-align: center; + text-decoration: none; + margin: 4px; } .delete-button { - background-color: #970c2a; - color: #fff; - padding: 10px 20px; - border: none; - border-radius: 4px; - cursor: pointer; - text-align: center; - text-decoration: none; - margin: 4px; + background-color: #970c2a; + color: #fff; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + text-align: center; + text-decoration: none; + margin: 4px; } + .count-container { - display: flex; - margin-left: auto; /* Pushes the container to the right */ + display: flex; + margin-left: auto; + /* Pushes the container to the right */ } .count-button { - background-color: #38476b; - color: #fff; - padding: 10px 20px; - border: none; - border-radius: 4px; - cursor: pointer; - text-align: center; - text-decoration: none; - margin: 4px; + background-color: #38476b; + color: #fff; + padding: 10px 20px; + border: none; + border-radius: 4px; + cursor: pointer; + text-align: center; + text-decoration: none; + margin: 4px; } -.count-button:hover{ - background-color: #5c5d7f; +.count-button:hover { + background-color: #5c5d7f; } .follow-button:hover { - background-color: #5c5d7f; + background-color: #5c5d7f; } @@ -107,125 +109,127 @@ body { /* Ajoutez les styles existants ici */ .popup { - display: none; /* Hidden by default */ - position: fixed; - z-index: 1; - left: 0; - top: 0; - width: 100%; - height: 100%; - overflow: auto; - background-color: rgb(0,0,0); - background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ + display: none; + /* Hidden by default */ + position: fixed; + z-index: 1; + left: 0; + top: 0; + width: 100%; + height: 100%; + overflow: auto; + background-color: rgb(0, 0, 0); + background-color: rgba(0, 0, 0, 0.4); + /* Black w/ opacity */ } .popup-content { - background-color: #fefefe; - margin: 15% auto; - padding: 20px; - border: 1px solid #888; - width: 80%; - max-width: 400px; - border-radius: 8px; - text-align: center; + background-color: #fefefe; + margin: 15% auto; + padding: 20px; + border: 1px solid #888; + width: 80%; + max-width: 400px; + border-radius: 8px; + text-align: center; } .close { - color: #aaa; - float: right; - font-size: 28px; - font-weight: bold; + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; } .close:hover, .close:focus { - color: black; - text-decoration: none; - cursor: pointer; + color: black; + text-decoration: none; + cursor: pointer; } html { - --s: 257px; - /* control the size */ - --c1: #38476b; - --c2: #bda3b6; - - --_c: var(--c1) calc(100% - var(--s)/2) 99%, #0000; - --_g: var(--s), #0000 calc(99% - var(--s)/2), var(--_c); - background: - radial-gradient(var(--s) at 100% var(--_g)), - radial-gradient(calc(var(--s)/4) at 50% calc(100%/3), var(--_c)) var(--s) 0, - radial-gradient(var(--s) at 0% var(--_g)) 0 calc(3*var(--s)) var(--c2); - background-size: - calc(2*var(--s)) calc(9*var(--s)/4), - calc(2*var(--s)) calc(3*var(--s)/4); - } - - header { - background-color: #bda3b6; - padding: 4px; - border-radius: 10px; - border-style: solid; - border-color: #1a2c4c; - border-width: 2px; + --s: 257px; + /* control the size */ + --c1: #38476b; + --c2: #bda3b6; + + --_c: var(--c1) calc(100% - var(--s)/2) 99%, #0000; + --_g: var(--s), #0000 calc(99% - var(--s)/2), var(--_c); + background: + radial-gradient(var(--s) at 100% var(--_g)), + radial-gradient(calc(var(--s)/4) at 50% calc(100%/3), var(--_c)) var(--s) 0, + radial-gradient(var(--s) at 0% var(--_g)) 0 calc(3*var(--s)) var(--c2); + background-size: + calc(2*var(--s)) calc(9*var(--s)/4), + calc(2*var(--s)) calc(3*var(--s)/4); +} + +header { + background-color: #bda3b6; + padding: 4px; + border-radius: 10px; + border-style: solid; + border-color: #1a2c4c; + border-width: 2px; } nav { - display: flex; - justify-content: space-between; - align-items: center; + display: flex; + justify-content: space-between; + align-items: center; } -.nav-logo{ - text-decoration: none; - color: #333; - margin-left: 15px; +.nav-logo { + text-decoration: none; + color: #333; + margin-left: 15px; } -.nav-link{ - text-decoration: none; - color: #333; - margin-right: 30px; +.nav-link { + text-decoration: none; + color: #333; + margin-right: 30px; } nav img { - height: 40px; + height: 40px; } .nav-links { - display: flex; - align-items: center; + display: flex; + align-items: center; } .floating-button { - position: fixed; - bottom: 20px; - right: 20px; - width: 60px; - height: 60px; - background-color: #bda3b6; - border: none; - border-radius: 50%; - display: flex; - justify-content: center; - align-items: center; - font-size: 24px; - box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); - cursor: pointer; - transition: background-color 0.3s; - border-style: solid; - border-color: #1a2c4c; - border-width: 4px; - padding-bottom: 10px; - font-size: 50px; - color: #1a2c4c; + position: fixed; + bottom: 20px; + right: 20px; + width: 60px; + height: 60px; + background-color: #bda3b6; + border: none; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + font-size: 24px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2); + cursor: pointer; + transition: background-color 0.3s; + border-style: solid; + border-color: #1a2c4c; + border-width: 4px; + padding-bottom: 10px; + font-size: 50px; + color: #1a2c4c; } .nav-links a:hover { - color: #494949; + color: #494949; } .floating-button:hover { - background-color: #72606d; -} \ No newline at end of file + background-color: #72606d; +} diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 3f795d9..90391cb 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -1,5 +1,6 @@ twig: file_name_pattern: '*.twig' + form_themes: ['form_div_layout.html.twig'] when@test: twig: diff --git a/migrations/Version20240612212104.php b/migrations/Version20240612225056.php similarity index 98% rename from migrations/Version20240612212104.php rename to migrations/Version20240612225056.php index 2af7f21..769c0bc 100644 --- a/migrations/Version20240612212104.php +++ b/migrations/Version20240612225056.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20240612212104 extends AbstractMigration +final class Version20240612225056 extends AbstractMigration { public function getDescription(): string { diff --git a/public/css/components/post_all.css b/public/css/base.css similarity index 100% rename from public/css/components/post_all.css rename to public/css/base.css diff --git a/public/css/components/form.css b/public/css/components/form.css new file mode 100644 index 0000000..8682925 --- /dev/null +++ b/public/css/components/form.css @@ -0,0 +1,107 @@ +.form-container { + + .form-group { + display: flex; + flex-direction: column; + margin-bottom: 20px; + } + + label { + font-size: 1.5em; + font-weight: bold; + } + + textarea { + padding: 10px; + border: 1px solid black; + border-radius: 1em; + resize: none; + } + + input { + font-size: 1.2em; + padding: 10px; + border: 1px solid black; + border-radius: 16px; + } + + input[type="checkbox"] { + font-size: 10px; + width: 20px; + height: 20px; + transform: scale(1.25); + accent-color: #3a3c6e; + border: 5px solid black; + } + + button[type="submit"] { + border: 3px solid #3a3c6e; + padding: 10px 30px; + display: block; + font-size: 1.5em; + font-weight: bold; + border-radius: 10px; + background-color: #3a3c6e; + color: white; + transition: 0.5s; + width: fit-content; + } + + button[type="submit"]:hover { + cursor: pointer; + background-color: white; + color: #3a3c6e; + } +} + +.form-label { + display: block; + margin-bottom: 5px; + font-weight: bold; + font-size: 14px; +} + +.form-control { + width: 100%; + padding: 10px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 16px; + box-sizing: border-box; +} + +.form-error { + color: #e74c3c; + font-size: 14px; + margin-left: -25px; +} + +.form-errors { + list-style: none; + padding-left: 0; + margin: 0; +} + +.form-errors li { + margin-bottom: 5px; +} + +.btn { + display: inline-block; + padding: 10px 20px; + font-size: 16px; + border-radius: 4px; + text-align: center; + cursor: pointer; + text-decoration: none; +} + +.btn-primary { + background-color: #3498db; + color: #fff; + border: none; +} + +.btn-primary:hover { + background-color: #2980b9; +} \ No newline at end of file diff --git a/public/css/components/post.css b/public/css/components/post.css index 7c0bada..6f67aa8 100644 --- a/public/css/components/post.css +++ b/public/css/components/post.css @@ -1,7 +1,3 @@ -:root { - font-family: "Helvetica", 'Courier New', Courier, monospace; -} - #post-wrapper { width: 70%; background-color: #f2f2f7; @@ -36,21 +32,4 @@ p { hr { color: black; -} - -html { - --s: 257px; - /* control the size */ - --c1: #38476b; - --c2: #bda3b6; - - --_c: var(--c1) calc(100% - var(--s)/2) 99%, #0000; - --_g: var(--s), #0000 calc(99% - var(--s)/2), var(--_c); - background: - radial-gradient(var(--s) at 100% var(--_g)), - radial-gradient(calc(var(--s)/4) at 50% calc(100%/3), var(--_c)) var(--s) 0, - radial-gradient(var(--s) at 0% var(--_g)) 0 calc(3*var(--s)) var(--c2); - background-size: - calc(2*var(--s)) calc(9*var(--s)/4), - calc(2*var(--s)) calc(3*var(--s)/4); -} +} \ No newline at end of file diff --git a/public/css/components/post_mini.css b/public/css/components/post_mini.css index 0ed7a8e..ca42be8 100644 --- a/public/css/components/post_mini.css +++ b/public/css/components/post_mini.css @@ -3,6 +3,11 @@ border: 3px solid black; border-radius: 1rem; padding: 20px; + transition: .3s; +} + +#post-wrapper:hover { + transform: scale(1.02); } #post-info { @@ -22,3 +27,8 @@ font-size: 1em; } } + +a { + text-decoration: none; + color: black; +} \ No newline at end of file diff --git a/src/Controller/PostController.php b/src/Controller/PostController.php index 452a073..21b90e9 100644 --- a/src/Controller/PostController.php +++ b/src/Controller/PostController.php @@ -34,7 +34,7 @@ class PostController extends AbstractController #[Route( '/post/{id}', - name: 'display post', + name: 'display_post', methods: ['GET'], requirements: ['id' => '\d+'] )] @@ -68,7 +68,8 @@ class PostController extends AbstractController $this->em->persist($post); $this->em->flush(); - return $this->redirectToRoute('display post', ['id' => $post->getId()]); + + return $this->redirectToRoute('display_post', ['id' => $post->getId()]); } return $this->render('post/new.html.twig', [ diff --git a/src/Entity/Post.php b/src/Entity/Post.php index d978eec..155998b 100644 --- a/src/Entity/Post.php +++ b/src/Entity/Post.php @@ -7,6 +7,8 @@ use DateTime; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\Mapping\ClassMetadata; #[ORM\Entity(repositoryClass: PostRepository::class)] class Post @@ -98,7 +100,6 @@ class Post return $this; } - public function getUpVote(): ?int { return $this->upVote; @@ -189,6 +190,16 @@ class Post return $this; } + public static function loadValidatorMetadata(ClassMetadata $metadata): void + { + $metadata->addPropertyConstraint('title', new Assert\Length([ + 'min' => 10, + 'max' => 200, + 'minMessage' => 'Your title must be at least {{ limit }} characters long', + 'maxMessage' => 'Your title cannot be longer than {{ limit }} characters', + ])); + } + public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; diff --git a/src/Form/Type/PostType.php b/src/Form/Type/PostType.php index 3578cea..6ca98ac 100644 --- a/src/Form/Type/PostType.php +++ b/src/Form/Type/PostType.php @@ -4,7 +4,6 @@ namespace App\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -16,12 +15,20 @@ class PostType extends AbstractType { $builder ->add('title', TextType::class) - ->add('text', TextareaType::class) - ->add('dream', CheckboxType::class) + ->add('text', TextareaType::class, [ + 'attr' => ['rows' => '10'], + 'label' => 'Your dream' + ]) + ->add('dream', CheckboxType::class, [ + 'required' => false, + 'label' => 'Was it a nightmare ?' + ]) // ->add('tags', ChoiceType::class, [ // "multiple" => true // ]) - ->add('submit', SubmitType::class) + ->add('submit', SubmitType::class, [ + 'label' => 'Publish' + ]) ; } } diff --git a/templates/base.html.twig b/templates/base.html.twig index efb418c..3d89853 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -2,13 +2,15 @@
-{{ post.text|u.truncate(150, true, '...') }}
{{ profil.description }}
-