Add sticky icon to story cards

This commit is contained in:
Tetrakern 2023-02-04 16:15:25 +01:00
parent 75c27cdb50
commit 7352ecd5c3
4 changed files with 24 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,12 @@ $story = fictioneer_get_story_data( $post->ID );
$tags = get_option( 'fictioneer_show_tags_on_story_cards' ) ? get_the_tags() : false;
$latest = isset( $args['show_latest'] ) && $args['show_latest'];
$chapter_ids = array_slice( $story['chapter_ids'], $latest ? -3 : 0, 3, true ); // Does not include hidden or non-chapters
$classes = ['card'];
// Sticky?
if ( fictioneer_get_field( 'fictioneer_story_sticky' ) ) {
$classes[] = '_sticky';
}
// Flags
$hide_author = isset( $args['hide_author'] ) && $args['hide_author'];
@ -28,7 +34,7 @@ $show_type = isset( $args['show_type'] ) && $args['show_type'];
?>
<li id="story-card-<?php the_ID(); ?>" class="card <?php if ( fictioneer_get_field( 'fictioneer_story_sticky' ) ) echo 'sticky'; ?>">
<li id="story-card-<?php the_ID(); ?>" class="<?php echo implode( ' ', $classes ); ?>">
<div class="card__body polygon">
<div class="card__header _large">
@ -39,6 +45,10 @@ $show_type = isset( $args['show_type'] ) && $args['show_type'];
<h3 class="card__title"><a href="<?php the_permalink(); ?>" class="truncate truncate--1-1"><?php echo $story['title']; ?></a></h3>
<?php if ( fictioneer_get_field( 'fictioneer_story_sticky' ) && ! is_search() && ! is_archive() ) : ?>
<div class="card__sticky-icon" title="<?php echo esc_attr__( 'Sticky', 'fictioneer' ); ?>"><i class="fa-solid fa-thumbtack"></i></div>
<?php endif; ?>
<?php echo fictioneer_get_card_controls( get_the_ID() ); ?>
</div>

View File

@ -122,6 +122,17 @@
border-radius: var(--layout-border-radius-small);
}
&__sticky-icon {
color: var(--fg-700);
font-size: 75%;
opacity: .375;
transform: translateY(1px);
&:not(:last-child) {
margin-right: 4px;
}
}
&__controls {
cursor: pointer;
position: relative;