From e3372d2c4c9ec3ef104d18496ff68cae91aa5f50 Mon Sep 17 00:00:00 2001 From: Florence Randaxhe <43472197+FlorenceRandaxhe@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:02:35 +0200 Subject: [PATCH 1/4] added blockquote component --- components/blockquote/Component.php | 40 ++++++++++++++++++ components/blockquote/style.scss | 29 +++++++++++++ components/blockquote/view.blade.php | 6 +++ src/Components/Publishers/Blockquote.php | 54 ++++++++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 components/blockquote/Component.php create mode 100644 components/blockquote/style.scss create mode 100644 components/blockquote/view.blade.php create mode 100644 src/Components/Publishers/Blockquote.php diff --git a/components/blockquote/Component.php b/components/blockquote/Component.php new file mode 100644 index 0000000..4f9562f --- /dev/null +++ b/components/blockquote/Component.php @@ -0,0 +1,40 @@ +text = $text; + $this->author = $author; + } + + /** + * Get the view / contents that represent the component. + */ + public function render(): View|Closure|string + { + return view('components.blockquote'); + } +} diff --git a/components/blockquote/style.scss b/components/blockquote/style.scss new file mode 100644 index 0000000..2bf2891 --- /dev/null +++ b/components/blockquote/style.scss @@ -0,0 +1,29 @@ +.blockquote { + margin: rem(54) 0; + position: relative; + padding-left: rem(20); + + &:after { + content: ""; + position: absolute; + height: 100%; + width: 1px; + background-color: color(text-primary); + left: 0; + top: 0; + bottom: 0 + } + + &__quote { + font-size: rem(18); + line-height: 160%; + } + + &__author { + display: block; + font-size: rem(12); + line-height: 100%; + text-transform: uppercase; + margin-top: rem(20); + } +} diff --git a/components/blockquote/view.blade.php b/components/blockquote/view.blade.php new file mode 100644 index 0000000..cb57f43 --- /dev/null +++ b/components/blockquote/view.blade.php @@ -0,0 +1,6 @@ +
+
+ {{ $text }} +
+ {{ $author }} +
diff --git a/src/Components/Publishers/Blockquote.php b/src/Components/Publishers/Blockquote.php new file mode 100644 index 0000000..84121a1 --- /dev/null +++ b/src/Components/Publishers/Blockquote.php @@ -0,0 +1,54 @@ +`"; + } +} From 6aca9336a4bbe7d4dde7c9b6f52b8e0a66e900ee Mon Sep 17 00:00:00 2001 From: Florence Randaxhe <43472197+FlorenceRandaxhe@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:33:07 +0200 Subject: [PATCH 2/4] added layout --- components/blockquote/Layout.php | 64 ++++++++++++++++++++++++ src/Components/Publishers/Blockquote.php | 6 +++ 2 files changed, 70 insertions(+) create mode 100644 components/blockquote/Layout.php diff --git a/components/blockquote/Layout.php b/components/blockquote/Layout.php new file mode 100644 index 0000000..48e9e27 --- /dev/null +++ b/components/blockquote/Layout.php @@ -0,0 +1,64 @@ +fields([ + Textarea::make('Text', 'text') + ->rules('required'), + + Text::make('Author', 'author') + ->help('Optionnal.'), + ]), + ]; + } + + /** + * The layout's display components + */ + public function display(): array + { + return [ + DataList::make() + ->row('Text', TextComponent::make($this->text)) + ->row('Author', TextComponent::make($this->author ?? '--')), + ]; + } + + /** + * Extract the values from the bag to store them in the database. + */ + public function fillAttributes(Baggage $bag): array + { + return $bag->only(['text', 'author']); + } +} diff --git a/src/Components/Publishers/Blockquote.php b/src/Components/Publishers/Blockquote.php index 84121a1..643fb9f 100644 --- a/src/Components/Publishers/Blockquote.php +++ b/src/Components/Publishers/Blockquote.php @@ -37,10 +37,16 @@ public function handle(): FilesCollection destination: base_path('app/View/Components/Blockquote.php'), ); + $layout = File::makeFromStub( + stub: 'components/blockquote/Layout.php', + destination: base_path('app/Layouts/Blockquote.php'), + ); + return FilesCollection::make([ $style, $view, $component, + $layout ]); } From 9849e34603744479a5004f9f6da697dc70d8e141 Mon Sep 17 00:00:00 2001 From: Florence Randaxhe <43472197+FlorenceRandaxhe@users.noreply.github.com> Date: Thu, 21 Aug 2025 15:38:21 +0200 Subject: [PATCH 3/4] update component --- components/blockquote/Component.php | 4 ++-- components/blockquote/view.blade.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/blockquote/Component.php b/components/blockquote/Component.php index 4f9562f..3de8fe0 100644 --- a/components/blockquote/Component.php +++ b/components/blockquote/Component.php @@ -19,12 +19,12 @@ class blockquote extends Component /** * The blockquote's author. */ - public string $author; + public ?string $author = null; /** * Create a new component instance. */ - public function __construct(string $text, string $author) + public function __construct(string $text, string $author = null) { $this->text = $text; $this->author = $author; diff --git a/components/blockquote/view.blade.php b/components/blockquote/view.blade.php index cb57f43..7494575 100644 --- a/components/blockquote/view.blade.php +++ b/components/blockquote/view.blade.php @@ -2,5 +2,7 @@
{{ $text }}
- {{ $author }} + @if($author) + {{ $author }} + @endif From 45c5900db67589905cd746ec679d768be9c53b35 Mon Sep 17 00:00:00 2001 From: Florence Randaxhe <43472197+FlorenceRandaxhe@users.noreply.github.com> Date: Mon, 25 Aug 2025 11:16:57 +0200 Subject: [PATCH 4/4] updated blockquote component --- components/blockquote/Component.php | 2 +- components/blockquote/Layout.php | 2 +- components/blockquote/style.scss | 7 +++++-- components/blockquote/view.blade.php | 12 ++++++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/components/blockquote/Component.php b/components/blockquote/Component.php index 3de8fe0..c2da3ed 100644 --- a/components/blockquote/Component.php +++ b/components/blockquote/Component.php @@ -7,7 +7,7 @@ use Illuminate\View\Component; use Whitecube\BemComponents\HasBemClasses; -class blockquote extends Component +class Blockquote extends Component { use HasBemClasses; diff --git a/components/blockquote/Layout.php b/components/blockquote/Layout.php index 48e9e27..3f42c3b 100644 --- a/components/blockquote/Layout.php +++ b/components/blockquote/Layout.php @@ -50,7 +50,7 @@ public function display(): array return [ DataList::make() ->row('Text', TextComponent::make($this->text)) - ->row('Author', TextComponent::make($this->author ?? '--')), + ->row('Author', TextComponent::make($this->author)), ]; } diff --git a/components/blockquote/style.scss b/components/blockquote/style.scss index 2bf2891..9f6a35f 100644 --- a/components/blockquote/style.scss +++ b/components/blockquote/style.scss @@ -1,7 +1,10 @@ .blockquote { - margin: rem(54) 0; + margin: rem(28) auto; position: relative; padding-left: rem(20); + width: col(6, 12); + display: flex; + flex-direction: column-reverse; &:after { content: ""; @@ -24,6 +27,6 @@ font-size: rem(12); line-height: 100%; text-transform: uppercase; - margin-top: rem(20); + margin-top: rem(12); } } diff --git a/components/blockquote/view.blade.php b/components/blockquote/view.blade.php index 7494575..b3268fd 100644 --- a/components/blockquote/view.blade.php +++ b/components/blockquote/view.blade.php @@ -1,8 +1,8 @@ -
-
- {{ $text }} -
+
@if($author) - {{ $author }} +
{{ $author }}
@endif -
+
+

{{ $text }}

+
+