-
Notifications
You must be signed in to change notification settings - Fork 1
Added blockquote layout #42
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
base: mix
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <?php | ||
|
|
||
| namespace App\View\Components; | ||
|
|
||
| use Closure; | ||
| use Illuminate\Contracts\View\View; | ||
| use Illuminate\View\Component; | ||
| use Whitecube\BemComponents\HasBemClasses; | ||
|
|
||
| class blockquote extends Component | ||
| { | ||
| use HasBemClasses; | ||
|
|
||
| /** | ||
| * The blockquote's text. | ||
| */ | ||
| public string $text; | ||
|
|
||
| /** | ||
| * The blockquote's author. | ||
| */ | ||
| public ?string $author = null; | ||
|
|
||
| /** | ||
| * Create a new component instance. | ||
| */ | ||
| public function __construct(string $text, string $author = null) | ||
| { | ||
| $this->text = $text; | ||
| $this->author = $author; | ||
| } | ||
|
|
||
| /** | ||
| * Get the view / contents that represent the component. | ||
| */ | ||
| public function render(): View|Closure|string | ||
| { | ||
| return view('components.blockquote'); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|
|
||
| namespace App\Layouts\CMS; | ||
|
|
||
| use Hiker\Cms\Layouts\BaseLayout; | ||
| use Hiker\Components\DataList\DataList; | ||
| use Hiker\Components\Editor\Step; | ||
| use Hiker\Components\Fields\Text\Text; | ||
| use Hiker\Components\Fields\Textarea\Textarea; | ||
| use Hiker\Components\Text\Text as TextComponent; | ||
| use Hiker\Tracks\Baggage; | ||
|
|
||
| class Blockquote extends BaseLayout | ||
| { | ||
| /** | ||
| * The label of the layout | ||
| */ | ||
| public function label(): string | ||
| { | ||
| return 'Blockquote'; | ||
| } | ||
|
|
||
| public function view(): string | ||
| { | ||
| return 'blockquote'; | ||
| } | ||
|
|
||
| /** | ||
| * The list of steps to display in the form | ||
| */ | ||
| public function form(Baggage $bag): array | ||
| { | ||
| return [ | ||
| Step::make(static::label(), 'edit_blockquote_layout') | ||
| ->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']); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <div class="blockquote"> | ||
| <blockquote class="blockquote__quote"> | ||
| {{ $text }} | ||
| </blockquote> | ||
| @if($author) | ||
| <cite class="blockquote__author">{{ $author }}</cite> | ||
| @endif | ||
|
||
| </div> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?php | ||
|
|
||
| namespace Whitecube\LaravelPreset\Components\Publishers; | ||
|
|
||
| use Whitecube\LaravelPreset\Components\File; | ||
| use Whitecube\LaravelPreset\Components\FilesCollection; | ||
| use Whitecube\LaravelPreset\Components\PublisherInterface; | ||
|
|
||
| class Blockquote implements PublisherInterface | ||
| { | ||
| /** | ||
| * Get the component's displayable name. | ||
| */ | ||
| public function label(): string | ||
| { | ||
| return 'Blockquote'; | ||
| } | ||
|
|
||
| /** | ||
| * Let the publisher prompt for eventual extra input | ||
| * and return a collection of publishable files. | ||
| */ | ||
| public function handle(): FilesCollection | ||
| { | ||
| $style = File::makeFromStub( | ||
| stub: 'components/blockquote/style.scss', | ||
| destination: resource_path('sass/parts/_blockquote.scss'), | ||
| ); | ||
|
|
||
| $view = File::makeFromStub( | ||
| stub: 'components/blockquote/view.blade.php', | ||
| destination: resource_path('views/components/blockquote.blade.php'), | ||
| ); | ||
|
|
||
| $component = File::makeFromStub( | ||
| stub: 'components/blockquote/Component.php', | ||
| 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 | ||
| ]); | ||
| } | ||
|
|
||
| /** | ||
| * Get the component's usage instructions | ||
| */ | ||
| public function instructions(): ?string | ||
| { | ||
| return "1. Add `@import 'parts/blockquote';` to `resources/sass/app.scss`\r\n2. Use the blade component: `<x-blockquote text=\"By 2018, Partch had won awards and assembled a formidable portfolio of grants. She sat on the boards of learned societies. She’d had a second son and recruited a group of students and postdocs inspired by her vision. Priya Crosby, a recent postdoc in her lab, remembers meeting Partch at a party and feeling awed. Partch’s passion for understanding the clock was palpable, and she seemed to have every piece of data about it at her fingertips.\" author=\"Mauris pharetra turpis eget placerat fringilla\" />`"; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Il faut une majuscule ici, non ?