Skip to content

Commit

Permalink
feat: news columns and row styleguide data. WIP this displays but err…
Browse files Browse the repository at this point in the history
…ors on all styleguides
  • Loading branch information
Fw7424 committed Jan 6, 2025
1 parent 642ddc8 commit a78b147
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/HomepageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function index(Request $request): View
$promos['components'] = $modularComponents['modularComponents'];
}

$articles = $this->article->listing($request->data['base']['site']['news']['application_id']);
$articles['data'] = $this->article->listing($request->data['base']['site']['news']['application_id']);

$events = $this->event->getEvents($request->data['base']['site']['id']);

Expand Down
160 changes: 160 additions & 0 deletions factories/ArticleComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<?php

namespace Factories;

use Contracts\Factories\FactoryContract;
use Faker\Factory;

class ArticleComponent implements FactoryContract
{
/**
* Construct the factory.
*/
public function __construct(Factory $faker)
{
$this->faker = $faker->create();
}

/**
* {@inheritdoc}
*/
public function create($limit = 1, $flatten = false, $options = [])
{
$hero = [
'featured' => 0,
'url' => '/styleguide/image/1600x580',
'caption' => $this->faker->sentence(rand(5, 10)),
'alt_text' => $this->faker->sentence(rand(5, 10)),
'type' => 'Hero Image',
];

$social = [
'featured' => 0,
'url' => '/styleguide/image/1600x580',
'caption' => $this->faker->sentence(rand(5, 10)),
'alt_text' => $this->faker->sentence(rand(5, 10)),
'type' => 'Social Image',
];

$featured = [
'featured' => 1,
'url' => '/styleguide/image/770x434',
'caption' => $this->faker->sentence(rand(5, 10)),
'alt_text' => $this->faker->sentence(rand(5, 10)),
'type' => 'Embeddable',
];

$faculty = [];
for ($i = 0; $i < 3; $i++) {
$faculty[] = [
'id' => $this->faker->randomDigit(),
'first_name' => $this->faker->firstName(),
'last_name' => $this->faker->lastName(),
'accessid' => $this->faker->randomLetter().$this->faker->randomLetter().$this->faker->randomNumber(4, true),
];
}

$programs = [];
for ($i = 0; $i < 3; $i++) {
$programs[] = [
'name' => $this->faker->randomElement(['Accounting (BS)', 'Art Education (BA)', 'Biological Sciences (BA)', 'Chemical Engineering (MS)']),
'url' => 'https://wayne.edu',
];
}

$assets = [];
for ($i = 0; $i < 3; $i++) {
$assets[] = [
'id' => $this->faker->randomDigit(),
'url' => 'https://wayne.edu',
'caption' => $this->faker->sentence(),
'filename' => substr(md5($this->faker->sentence()), 0, 10).'.pdf',
];
}

for ($i = 1; $i <= $limit; $i++) {
$data[$i] = [
'id' => $i,
'user_id' => $this->faker->randomDigit(),
'application_id' => $this->faker->randomDigit(),
'favicon_id' => null,
'title' => $this->faker->sentence(rand(6, 10)),
'short_title' => $this->faker->sentence(rand(3, 6)),
'sub_title' => null,
'permalink' => $this->faker->slug(),
'meta_description' => $this->faker->sentence(),
'body' => '<p>'.$this->faker->paragraph(8).'</p>
<p>'.$this->faker->paragraph(8).'</p>
<figure class="figure" style="padding-bottom:10px; float:right">
<img alt="Placeholder" height="400" src="/styleguide/image/300x400?text=Figure%20float%20right" style="padding:10px" width="300">
<figcaption>'.$this->faker->paragraph().'</figcaption>
</figure>
<p>'.$this->faker->paragraph().'</p>
<blockquote class="blockquote1">
<p>'.$this->faker->paragraph(1).'</p>
</blockquote>
<p>'.$this->faker->paragraph(8).'</p>
<p>'.$this->faker->paragraph(8).'</p>
<blockquote class="blockquote2">
<p>'.$this->faker->paragraph(1).'</p>
</blockquote>
<p>'.$this->faker->paragraph(8).'</p>
<p>'.$this->faker->paragraph(8).'</p>
<p>&nbsp;</p>
<h2>'.$this->faker->paragraph(1).'</h2>
<figure class="figure" style="padding-bottom:10px; float:left">
<img alt="Placeholder" height="600" src="/styleguide/image/800x600?text=Figure%20float%20left" style="padding:10px" width="800">
<figcaption>'.$this->faker->paragraph().'</figcaption>
</figure>
<p>'.$this->faker->paragraph(8).'</p>
<p>'.$this->faker->paragraph(15).'</p>
<blockquote class="blockquote3">
<p>'.$this->faker->paragraph(5).'</p>
</blockquote>
<p>'.$this->faker->paragraph(15).'</p>
<div style="text-align:center">
<figure class="figure" style="display:inline-block">
<img alt="Placeholder" height="450" src="/styleguide/image/800x450?text=Figure%20centered" style="padding:10px" width="800">
<figcaption>'.$this->faker->paragraph().'</figcaption>
</figure>
</div>
<p>'.$this->faker->paragraph(15).'</p>
<img alt="Placeholder" height="400" src="/styleguide/image/300x400?text=Image%20float%20right" style="padding:10px; float:right" width="300">
<p>'.$this->faker->paragraph(8).'</p>
<p>'.$this->faker->paragraph(15).'</p>
<img alt="Placeholder" height="300" src="/styleguide/image/400x300?text=Image%20float%20left" style="padding:10px; float:left" width="400">
<p>'.$this->faker->paragraph(8).'</p>
<p>'.$this->faker->paragraph(15).'</p>
<p style="text-align:center">
<img alt="Placeholder" height="350" src="/styleguide/image/800x350?text=Image%20centered" style="padding:10px" width="800">
</p>
<p>'.$this->faker->paragraph(8).'</p>
',
'article_date' => $this->faker->date(),
'status' => 'Published',
'link' => '/styleguide/'.config('base.news_view_route').'/item-1',
'hero_image' => $hero,
'social_image' => $social,
'featured' => $featured,
'files' => [
0 => $hero,
1 => $featured,
],
'assets' => $this->faker->randomElements($assets, rand(1, 3)),
'faculty' => $this->faker->randomElements($faculty, rand(1, 3)),
'programs' => $this->faker->randomElements($programs, rand(1, 3)),
'favicon' => null,
'user' => null,
'applications' => null,
];

$data[$i] = array_replace_recursive($data[$i], $options);
}

if ($limit === 1 && $flatten === true) {
$data = current($data);
}

return $data;
}
}
4 changes: 2 additions & 2 deletions resources/views/components/news-column.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
$url => string '/news/'
$link_text => string // 'More news'
--}}
@if(!empty($data['data']))
@if(!empty($data))
<ul>
@foreach($data['data'] as $item)
@foreach($data as $item)
<li class="mb-4">
<a href="{{ $item['link'] }}" class="underline hover:no-underline font-normal">
{{ $item['title'] }}
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/news-featured-column.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
$url => string '/news/'
$link_text => string // 'More news'
--}}
@if(!empty($data['data']))
@if(!empty($data))
<ul>
@foreach($data['data'] as $item)
@foreach($data as $item)
@if($loop->iteration === 1)
<li class="bg-green-800">
<a href="{{ $item['link'] }}" class="relative block mb-6 group">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/news-row.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
$url => string '/news.php'
$link_text => string // 'More news'
--}}
@if(!empty($data['data']))
@if(!empty($data))
<ul class="grid gap-x-6 gap-y-4 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-{{ !empty($component['limit']) ? $component['limit'] : '4' }}">
@foreach($data['data'] as $item)
@foreach($data as $item)
<li class="group flex items-start md:block">
<a class="group-hover:no-underline flex items-start md:block" href="{{ $item['link'] }}">
@image($item['featured']['url'] ?? 'https://wayne.edu/opengraph/wsu-social-share.png', $item['featured']['alt_text'] ?? 'Wayne State University', 'block lazy w-1/3 shrink-0 mr-2 mb-2 md:w-full md:mr-0 md:shrink')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function index(Request $request): View
],

'news-column' => [
'data' => app(Article::class)->create(3, false),
'data' => app(Article::class)->create(3, false)['data'],
'component' => [
'filename' => 'news-column',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,24 @@ public function index(Request $request): View
],
],
'news-column-1' => [
'data' => app(Article::class)->create(5, false),
'data' => app(Article::class)->create(5, false)['data'],
'meta' => app(Article::class)->create(5, false)['meta'],
'component' => [
'heading' => 'News column',
'filename' => 'news-column',
],
],
'news-featured-column-1' => [
'data' => app(Article::class)->create(4, false),
'data' => app(Article::class)->create(4, false)['data'],
'meta' => app(Article::class)->create(4, false)['meta'],
'component' => [
'heading' => 'Featured news column',
'filename' => 'news-featured-column',
],
],
'news-row-1' => [
'data' => app(Article::class)->create(4, false),
'data' => app(Article::class)->create(4, false)['data'],
'meta' => app(Article::class)->create(4, false)['meta'],
'component' => [
'heading' => 'News row',
'filename' => 'news-row',
Expand Down
2 changes: 1 addition & 1 deletion styleguide/Http/Controllers/FullWidthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function index(Request $request): View
],

'news_row' => [
'data' => app(Article::class)->create(4, false),
'data' => app(Article::class)->create(4, false)['data'],
'component' => [
'heading' => 'Featured news',
'filename' => 'news-row',
Expand Down

0 comments on commit a78b147

Please sign in to comment.