Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PoC] Front Ui to help you building a front webapp quickly #113

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app/EventListener/ChangePasswordListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace App\EventListener;

use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Sylius\FrontUi\Event\ChangePasswordEvent;
use Sylius\FrontUi\Symfony\EventListener\Attribute\AsChangePasswordListener;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Webmozart\Assert\Assert;

#[AsChangePasswordListener]
final class ChangePasswordListener
{
public function __construct(
private readonly UserPasswordHasherInterface $passwordHasher,
private readonly EntityManagerInterface $entityManager,
) {
}

public function __invoke(ChangePasswordEvent $event): void
{
/** @var User $user */
$user = $event->getUser();
Assert::isInstanceOf($user, User::class);

$hashedPassword = $this->passwordHasher->hashPassword($user, $event->getNewPassword());

$user->setPassword($hashedPassword);

$this->entityManager->flush();
}
}
10 changes: 9 additions & 1 deletion app/Story/DefaultUsersStory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public function build(): void
->admin()
->withEmail('[email protected]')
->withPassword('admin')
->create();
->create()
;

UserFactory::new()
->admin()
->withEmail('[email protected]')
->withPassword('front')
->create()
;
}
}
1 change: 1 addition & 0 deletions assets/icons/symfony.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
"symfony/config": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/expression-language": "^6.4 || ^7.0",
"symfony/http-client": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/security-http": "^6.4 || ^7.0",
"symfony/stopwatch": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"symfony/ux-autocomplete": "^2.17",
"symfony/ux-icons": "^2.20",
"symfony/ux-live-component": "^2.17",
"symfony/ux-twig-component": "^2.17",
"twig/twig": "^2.15 || ^3.0",
Expand Down Expand Up @@ -68,9 +70,11 @@
"psr-4": {
"Sylius\\AdminUi\\": "src/AdminUi/src/",
"Sylius\\BootstrapAdminUi\\": "src/BootstrapAdminUi/src/",
"Sylius\\BootstrapFrontUi\\": "src/BootstrapFrontUi/src/",
"Sylius\\TwigExtra\\": "src/TwigExtra/src/",
"Sylius\\TwigHooks\\": "src/TwigHooks/src/",
"Sylius\\UiTranslations\\": "src/UiTranslations/src/"
"Sylius\\UiTranslations\\": "src/UiTranslations/src/",
"Sylius\\FrontUi\\": "src/FrontUi/src/"
}
},
"autoload-dev": {
Expand All @@ -79,6 +83,7 @@
"MainTests\\Sylius\\": "tests/",
"TestApplication\\Sylius\\AdminUi\\": "src/AdminUi/tests/Functional/.application/src/",
"TestApplication\\Sylius\\BootstrapAdminUi\\": "src/BootstrapAdminUi/tests/Functional/.application/src/",
"TestApplication\\Sylius\\BootstrapFrontUi\\": "src/BootstrapFrontUi/tests/Functional/.application/src/",
"TestApplication\\Sylius\\TwigExtra\\": "src/TwigExtra/tests/Functional/.application/src/",
"TestApplication\\Sylius\\TwigHooks\\": "src/TwigHooks/tests/Functional/.application/src/",
"TestApplication\\Sylius\\UiTranslations\\": "src/UiTranslations/tests/Functional/.application/src/",
Expand All @@ -91,6 +96,8 @@
"replace": {
"sylius/admin-ui": "self.version",
"sylius/bootstrap-admin-ui": "self.version",
"sylius/bootstrap-front-ui": "self.version",
"sylius/front-ui": "self.version",
"sylius/twig-extra": "self.version",
"sylius/twig-hooks": "self.version",
"sylius/ui-translations": "self.version"
Expand Down
3 changes: 3 additions & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
Sylius\AdminUi\Symfony\SyliusAdminUiBundle::class => ['all' => true],
Sylius\UiTranslations\Symfony\SyliusUiTranslationsBundle::class => ['all' => true],
Sylius\BootstrapAdminUi\Symfony\SyliusBootstrapAdminUiBundle::class => ['all' => true],
Sylius\FrontUi\Symfony\SyliusFrontUiBundle::class => ['all' => true],
Sylius\BootstrapFrontUi\Symfony\SyliusBootstrapFrontUiBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true],
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
Symfony\UX\Icons\UXIconsBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
Sylius\Bundle\ResourceBundle\SyliusResourceBundle::class => ['all' => true],
Expand Down
29 changes: 20 additions & 9 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,42 @@ security:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

admin:
provider: app_user_provider
pattern: '^/admin/'
form_login:
login_path: sylius_admin_ui_login
check_path: sylius_admin_ui_login_check
default_target_path: app_admin_conference_index
logout:
path: sylius_admin_ui_logout
target: sylius_admin_ui_login

main:
lazy: true
provider: app_user_provider
form_login:
login_path: sylius_front_ui_login
check_path: sylius_front_ui_login_check
default_target_path: sylius_front_ui_account_dashboard
logout:
path: sylius_front_ui_logout
target: sylius_front_ui_login

# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall

# https://symfony.com/doc/current/security/impersonating_user.html
# switch_user: true

form_login:
# "app_login" is the name of the route created previously
login_path: sylius_admin_ui_login
check_path: sylius_admin_ui_login_check
default_target_path: app_admin_conference_index
logout:
path: sylius_admin_ui_logout
target: sylius_admin_ui_login

# Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used
access_control:
- { path: ^/admin/login, roles: PUBLIC_ACCESS }
- { path: ^/admin/logout, roles: PUBLIC_ACCESS }
- { path: ^/admin, roles: ROLE_ADMIN }
- { path: ^/account, roles: ROLE_USER }
- { path: ^/, roles: PUBLIC_ACCESS }
# - { path: ^/profile, roles: ROLE_USER }

Expand Down
2 changes: 2 additions & 0 deletions config/packages/sylius_bootstrap_front_ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
imports:
- { resource: '../../src/BootstrapFrontUi/config/app.php' }
2 changes: 2 additions & 0 deletions config/routes/sylius_webapp_ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sylius_webapp_ui:
resource: '@SyliusFrontUiBundle/config/routes.php'
1 change: 1 addition & 0 deletions src/BootstrapFrontUi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
12 changes: 12 additions & 0 deletions src/BootstrapFrontUi/assets/entrypoint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import './styles/main.scss';

import './scripts/bootstrap';
Binary file not shown.
Binary file added src/BootstrapFrontUi/assets/images/loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/BootstrapFrontUi/assets/scripts/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import * as bootstrap from 'bootstrap';
35 changes: 35 additions & 0 deletions src/BootstrapFrontUi/assets/styles/_base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

@font-face {
font-family: 'Inter';
src: url('../fonts/inter-variable-font-slnt-wght.ttf') format('truetype-variations');
font-weight: 1 999;
}

html {
font-feature-settings: "cv03", "cv04", "cv11";
}

a {
text-underline-offset: 0.25em;

&.link-reset {
color: inherit;
text-decoration: none;

&:hover {
color: $link-hover-color;
}
}
}

.fs-7 {
font-size: $small-font-size;
}
46 changes: 46 additions & 0 deletions src/BootstrapFrontUi/assets/styles/_buttons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

.btn-icon {
display: inline-flex;
gap: 0.4rem;
align-items: center;
padding-left: 1.4rem;
padding-right: 1.6rem;
}

.btn-primary {
color: #fff;
}

.btn-transparent {
@extend .btn-light;
background-color: transparent;
border-color: transparent;

&:hover {
background-color: $gray-100;
border-color: transparent;
}

&:focus {
background-color: transparent !important;
border-color: transparent !important;
}

&:active {
background-color: $gray-200 !important;
border-color: transparent !important;
}
}

.btn-outline-gray {
@extend .btn-outline-dark;
--bs-btn-border-color: var(--bs-gray-400);
}
5 changes: 5 additions & 0 deletions src/BootstrapFrontUi/assets/styles/_form.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.form-label.required::after {
content: "*";
padding-left: 3px;
color: $danger;
}
39 changes: 39 additions & 0 deletions src/BootstrapFrontUi/assets/styles/_icons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.symfony-icon {
height: 28px;
width: 28px;

&-xs {
height: 16px;
width: 16px;
}

&-sm {
height: 20px;
width: 20px;
}

&-md {
height: 24px;
width: 24px;
}

&-lg {
height: 32px;
width: 32px;
}

&-xl {
height: 40px;
width: 40px;
}

& > * {
stroke-width: 1.1;
}

&-xs, &-sm, &-md {
& > * {
stroke-width: 2;
}
}
}
19 changes: 19 additions & 0 deletions src/BootstrapFrontUi/assets/styles/_loader.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

.sylius-shop-loader {
display: flex;
position: absolute;
height: 100%;
width: 100%;
background: rgba(255, 255, 255, 0.9);
align-items: center;
justify-content: center;
z-index: 100;
}
37 changes: 37 additions & 0 deletions src/BootstrapFrontUi/assets/styles/_utils.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$utilities: (
"min-viewport-height": (
property: min-height,
responsive: true,
class: min-vh,
values: (100: 100vh)
),
"width": (
property: width,
class: w,
values: (
1: 1%,
25: 25%,
50: 50%,
75: 75%,
100: 100%,
auto: auto
)
),
);

$positions: 40px, 50px, 80px;

@each $position in $positions {
.border-#{$position}-dashed {
border-#{$position}-style: dashed !important;
}
}
Loading
Loading