-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply person node styles consistently in lists and teasers
- Loading branch information
Showing
8 changed files
with
168 additions
and
21 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
modules/stanford_decoupled/src/Plugin/GraphQL/SchemaExtension/CitationSchemaExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\stanford_decoupled\Plugin\GraphQL\SchemaExtension; | ||
|
||
use Drupal\graphql\GraphQL\ResolverBuilder; | ||
use Drupal\graphql\GraphQL\ResolverRegistryInterface; | ||
use Drupal\graphql_compose\Plugin\GraphQL\SchemaExtension\ResolverOnlySchemaExtensionPluginBase; | ||
use Drupal\stanford_publication\Entity\CitationInterface; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
|
||
/** | ||
* Layout Schema Extension. | ||
* | ||
* @codeCoverageIgnore | ||
* | ||
* @SchemaExtension( | ||
* id = "stanford_citation_bibliography", | ||
* name = "Stanford Decoupled Bibliography", | ||
* description = @Translation("Layout entities"), | ||
* schema = "graphql_compose", | ||
* ) | ||
*/ | ||
class CitationSchemaExtension extends ResolverOnlySchemaExtensionPluginBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { | ||
$instance = parent::create( | ||
$container, | ||
$configuration, | ||
$plugin_id, | ||
$plugin_definition | ||
); | ||
return $instance; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function registerResolvers(ResolverRegistryInterface $registry): void { | ||
$builder = new ResolverBuilder(); | ||
|
||
$registry->addFieldResolver('CitationInterface', 'apa', | ||
$builder->callback(fn(CitationInterface $citation) => $citation->getBibliography()), | ||
); | ||
$registry->addFieldResolver('CitationInterface', 'chicago', | ||
$builder->callback(fn(CitationInterface $citation) => $citation->getBibliography(CitationInterface::CHICAGO)), | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
modules/stanford_decoupled/src/Plugin/GraphQLCompose/SchemaType/Bibliography.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\stanford_decoupled\Plugin\GraphQLCompose\SchemaType; | ||
|
||
use Drupal\graphql_compose\Plugin\GraphQLCompose\GraphQLComposeSchemaTypeBase; | ||
use GraphQL\Type\Definition\CustomScalarType; | ||
use GraphQL\Type\Definition\ObjectType; | ||
use function Symfony\Component\String\u; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* | ||
* @codeCoverageIgnore | ||
* | ||
* @GraphQLComposeSchemaType( | ||
* id = "Bibliography" | ||
* ) | ||
*/ | ||
class Bibliography extends GraphQLComposeSchemaTypeBase { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getTypes(): array { | ||
$types = []; | ||
|
||
$types[] = new CustomScalarType([ | ||
'name' => $this->getPluginId(), | ||
'description' => (string) $this->t('Bibliography citation format markup.'), | ||
]); | ||
|
||
return $types; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function getExtensions(): array { | ||
$extensions = parent::getExtensions(); | ||
$citation_types = $this->entityTypeManager->getStorage('citation_type') | ||
->loadMultiple(); | ||
foreach (array_keys($citation_types) as $citation_type) { | ||
$citation_type = u($citation_type) | ||
->camel() | ||
->title() | ||
->toString(); | ||
|
||
$extensions[] = new ObjectType([ | ||
'name' => 'Citation' . trim($citation_type, 's'), | ||
'fields' => fn() => [ | ||
'apa' => static::type('Bibliography'), | ||
'chicago' => static::type('Bibliography'), | ||
], | ||
]); | ||
} | ||
|
||
return $extensions; | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
modules/stanford_profile_styles/dist/css/component/node/stanford_page.css
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
modules/stanford_profile_styles/dist/css/component/node/stanford_person.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
modules/stanford_profile_styles/lib/scss/component/node/stanford_person.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@charset 'UTF-8'; | ||
@import '../../config'; | ||
|
||
// Make the people referenced entity pictures circles. | ||
.su-person-photo { | ||
@include margin(0 auto); | ||
@include padding(30px); | ||
max-width: 300px; | ||
|
||
picture, | ||
img { | ||
border-radius: 50%; | ||
} | ||
} | ||
|
||
.ds-entity--stanford-person { | ||
text-align: center; | ||
|
||
a { | ||
color: $su-color-bright-red; | ||
|
||
&:active, | ||
&:focus, | ||
&:hover { | ||
color: $su-color-black; | ||
text-decoration: underline; | ||
} | ||
} | ||
|
||
h3 { | ||
font-size: 1.4em; | ||
margin-bottom: 1.0rem; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters