Skip to content

Commit

Permalink
Merge branch 'release/8.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
breakdancingcat committed Dec 1, 2023
2 parents 82f4d2a + c967af5 commit f96faad
Show file tree
Hide file tree
Showing 130 changed files with 2,167 additions and 1,634 deletions.
17 changes: 16 additions & 1 deletion app/Http/Controllers/ModularPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ public function index(Request $request)
{
$components['components'] = $this->modular->getModularComponents($request->data['base']);

return view('modular/modularpage', merge($request->data, $components));
// Set hero from components
if (empty($request->data['base']['hero'])) {
$hero = collect($components['components'])->reject(function ($data, $component_name) {
return !str_contains($component_name, 'hero');
})->toArray();

$hero_key = array_key_first($hero);

if(!empty($hero)) {
$request->data['base']['hero'] = $components['components'][$hero_key]['data'];
}

unset($components['components'][$hero_key]);
}

return view('modularpage', merge($request->data, $components));
}
}
58 changes: 52 additions & 6 deletions app/Support/helpers.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* Merge data together and ensure duplicate keys can't exist by throwing an error.
*
Expand All @@ -15,27 +16,72 @@ function merge()

foreach ((array) $params as $key => $value) {
// Require only arrays
if (! is_array($value)) {
throw new Exception('Merged variables must be type array, but a '.gettype($value).' was given. '."\n\n".'Value: '.$value);
if (!is_array($value)) {
throw new Exception('Merged variables must be type array, but a ' . gettype($value) . ' was given. ' . "\n\n" . 'Value: ' . $value);
}

// Make sure every key has a string name
collect($value)->each(function ($value, $key) {
if (! is_string($key)) {
throw new Exception('Merged variables must have key as a string, but a '.gettype($key).' was given. '."\n\n Key: ".$key."\n Values: ".(is_array($value) ? json_encode(array_keys($value)) : $value));
if (!is_string($key)) {
throw new Exception('Merged variables must have key as a string, but a ' . gettype($key) . ' was given. ' . "\n\n Key: " . $key . "\n Values: " . (is_array($value) ? json_encode(array_keys($value)) : $value));
}
});

// Make sure there aren't any similiar keys
if (collect($value)->diffKeys($merged)->count() != count($value)) {
throw new Exception('Array key conflict. Update your array to not conflict with other keys: '."\n\n Values:".json_encode(array_keys($value)));
throw new Exception('Array key conflict. Update your array to not conflict with other keys: ' . "\n\n Values:" . json_encode(array_keys($value)));
}

// Merge the arrays
$merged = $merged->merge($value);
}

return $merged->toArray();
$merged = $merged->toArray();

// Add computed title tag
if (!empty($merged['base']) && !array_key_exists('title', $merged['base']['meta'])) {
$merged['base']['meta']['title'] = stringify_page_title($merged['base']);
}

return $merged;
}

/**
* Calculate the title tag based in priority information about the page
*
* @param array $data
* @return string
*/
function stringify_page_title($data)
{
$titles = [];
$char_length = 0;

// Page title (except homepages)
if (!empty($data['page']['title'])
&& !empty($data['server']['path'])
&& $data['server']['path'] != '/'
&& $data['server']['path'] != rtrim($data['site']['subsite-folder'], '/')
) {
$titles[] = $data['page']['title'];
$char_length += strlen($data['page']['title']);
}

// Site title (if there is enough room)
if (!empty($data['site']['title'])
&& ($char_length + 22) < 60
) {
$titles[] = $data['site']['title'];
$char_length += strlen($data['site']['title']);
}

// University name (if there is room)
if (($char_length + 22) <= 70) {
$titles[] = 'Wayne State University';
}

// Use dash separators
return implode(' - ', $titles);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion factories/Accordion.php → factories/AccordionItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Contracts\Factories\FactoryContract;
use Faker\Factory;

class Accordion implements FactoryContract
class AccordionItems implements FactoryContract
{
/**
* Construct the factory.
Expand All @@ -24,6 +24,7 @@ public function create($limit = 1, $flatten = false, $options = [])
$data[$i] = [
'title' => $this->faker->sentence(),
'description' => '<p>'.$this->faker->paragraph().' <a href="/styleguide">Example link.</a></p>',
'promo_item_id' => $this->faker->numberBetween(1000, 10000),
];

$data[$i] = array_replace_recursive($data[$i], $options);
Expand Down
2 changes: 1 addition & 1 deletion factories/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function create($limit = 1, $flatten = false, $options = [])

$featured = [
'featured' => 1,
'url' => '/styleguide/image/1600x580',
'url' => '/styleguide/image/770x434',
'caption' => $this->faker->sentence(rand(5, 10)),
'alt_text' => $this->faker->sentence(rand(5, 10)),
'type' => 'Embeddable',
Expand Down
53 changes: 53 additions & 0 deletions factories/Button.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Factories;

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

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

/**
* {@inheritdoc}
*/
public function create($limit = 1, $flatten = false, $options = [])
{
for ($i = 1; $i <= $limit; $i++) {
$data[$i] = [
'link' => '#',
'title' => ucfirst(implode(' ', $this->faker->words(3))),
//'excerpt' => $this->faker->catchPhrase,
'description' => '',
'promo_item_id' => $i,
//'relative_url' => '/styleguide/image/100x100', // 1:1
//'filename_url' => '/styleguide/image/100x100?text=100x100:'.$i, // 4:3
//'filename_alt_text' => 'Placeholder image '.$i,
//'secondary_image' => '',
//'secondary_relative_url' => '/styleguide/image/150x150?text=150x150:'.$i, // 4:3
//'secondary_filename_url' => '',
//'secondary_alt_text' => 'Secondary placeholder image '.$i,
'option' => '',
//'option' => $this->faker->randomElement(['Gold', 'Green', '']),
'group' => [
'title' => 'Promo group title',
],
];

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

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

return $data;
}
}
7 changes: 5 additions & 2 deletions factories/GenericPromo.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ public function __construct(Factory $faker)
*/
public function create($limit = 1, $flatten = false, $options = [])
{
// Doc https://github.com/fzaninotto/Faker

$promo_group_id = $this->faker->randomNumber(5);

for ($i = 0; $i <= $limit - 1; $i++) {
$data[$i] = [
'title' => ucfirst(implode(' ', $this->faker->words(3))),
'excerpt' => $this->faker->sentence(),
'title' => ucfirst(implode(' ', $this->faker->words(6))),
'excerpt' => $this->faker->catchPhrase,
'description' => '<p>' . $this->faker->text(100) . ' <a href="https://wayne.edu">'. $this->faker->sentence(3) .'</a></p>',
'description' => '<p>' . $this->faker->text(100) . ' <a href="https://wayne.edu">'. $this->faker->sentence(3) .'</a></p>',
'link' => 'https://wayne.edu',
'promo_item_id' => $i,
Expand Down
2 changes: 1 addition & 1 deletion factories/Spotlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function create($limit = 1, $flatten = false, $options = [])
'title' => $this->faker->name,
'excerpt' => $this->faker->jobTitle,
'description' => '<p>&ldquo;' . $this->faker->text(200) . '&rdquo;</p>',
'link' => 'https://wayne.edu',
'link' => '#',
'promo_item_id' => $i,
'promo_group_id' => strval($promo_group_id),
'relative_url' => '/styleguide/image/600x600?text=600x600:'.$i,
Expand Down
38 changes: 0 additions & 38 deletions factories/UnderMenu.php

This file was deleted.

7 changes: 4 additions & 3 deletions factories/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public function create($limit = 1, $flatten = false, $options = [])
{
for ($i = 1; $i <= $limit; $i++) {
$data[$i] = [
'link' => 'https://www.youtube.com/watch?v=QYVv994xz6s',
'youtube_id' => 'QYVv994xz6s',
'relative_url' => $this->faker->randomElement(['/styleguide/image/800x450?text=Video', '']),
'link' => 'https://www.youtube.com/watch?v=PHqfwq033yQ',
'youtube_id' => 'PHqfwq033yQ',
'relative_url' => '',
//'relative_url' => $this->faker->randomElement(['/styleguide/image/800x450?text=Video', '']),
'title' => $this->faker->sentence(),
'excerpt' => $this->faker->sentence(),
'filename_alt_text' => 'Example video image',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "base",
"private": true,
"version": "8.5.5",
"version": "8.6.0",
"description": "",
"scripts": {
"dev": "npm run development",
Expand Down
16 changes: 14 additions & 2 deletions resources/js/modules/pdf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
(function() {
"use strict";

document.querySelectorAll('a[href$=".pdf"]').forEach(function(item) {
item.innerHTML += ' (pdf)';
document.querySelectorAll('a[href$=".pdf"]').forEach(function(link) {
const pdfSpan = document.createElement("span");
const pdfLabel = document.createTextNode(" (pdf)");
if(link.classList.contains('button') && link.children.length > 0) {
const lastChild = link.children.length - 1;
pdfSpan.appendChild(pdfLabel);
link.children[lastChild].appendChild(pdfSpan);
} else if(!link.classList.contains('button') && link.getElementsByTagName('img').length > 0) {
pdfSpan.appendChild(pdfLabel);
link.appendChild(pdfSpan);

} else {
link.innerHTML += ' (pdf)';
}
});
})();
25 changes: 15 additions & 10 deletions resources/scss/components/_accordion.scss
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
.accordion.enabled {
@apply p-0 mb-4 ml-0 relative;
@apply border-t border-gray-200 p-0 mb-4 ml-0 relative grid grid-cols-1;

transition: 0.3s ease all;

& > li {
@apply border border-solid border-gray-400 w-full absolute border-b-0;
@apply border-b border-gray-200 w-full focus-within:outline outline-2 outline-green focus-within:border-b-0 focus-within:rounded-sm;

transition: 0.3s ease all;

&:last-child {
@apply border-b;
}

> a {
@apply bg-gray-200 relative block p-4 pr-8 font-bold border-b-0 no-underline;
@apply relative block p-4 pl-8 font-bold border-b-0 no-underline outline-0;

cursor: pointer;
user-select: none;

&:first-child:hover,
&:first-child:focus, {
@apply bg-gray-500 text-white;
}

// Open symbol
& span::before {
@apply absolute right-0 pr-4 top-0 pt-4;
@apply absolute left-0 pl-4 top-0 pt-4;

content: '+';
}
}

& a:focus {
@apply outline outline-0;
}

// Close symbol
&.open > a span::before {
content: '\2013';
}

// Content area
> .fold {
@apply bg-white p-4 border-t-0;
@apply p-4 pt-0 pl-8 border-t-0;

transition: 0.3s ease all;
}
}

Expand Down

0 comments on commit f96faad

Please sign in to comment.