Repository navigation
feat: artisanpack/copyright + marquee + comments-number site-chrome blocks #571
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
Merged
ViewFromTheBox
merged 2 commits into
feature/495-port-crosswinds-blocks
from
feature/500-site-chrome-blocks
Jun 12, 2026
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
packages/visual-editor-renderer-blade/resources/assets/frontend/marquee.css
This file contains hidden or 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 @@ | ||
| /** | ||
| * Front-end styles for the marquee block (artisanpack/marquee — #500). | ||
| * | ||
| * Mirrors the editor preview styles in | ||
| * `resources/js/visual-editor/blocks/marquee/marquee.css`. Host apps | ||
| * load this stylesheet on any page that renders a marquee block — the | ||
| * `<x-ve-blocks-styles />` component emits the `<link>`. | ||
| * | ||
| * The block's `marqueeSpeed` attribute lands as an inline | ||
| * `animation: ap-marquee-scroll Ns linear infinite` on the inner `<p>`, | ||
| * so the keyframe definition here is all the frontend needs. | ||
| */ | ||
|
|
||
| .ap-marquee { | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .ap-marquee__text { | ||
| margin: 0; | ||
| transform: translateX(100%); | ||
| white-space: nowrap; | ||
| will-change: transform; | ||
| } | ||
|
|
||
| @keyframes ap-marquee-scroll { | ||
| from { | ||
| transform: translateX(100%); | ||
| } | ||
| to { | ||
| transform: translateX(-100%); | ||
| } | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
...visual-editor-renderer-blade/resources/views/blocks/artisanpack/comments-number.blade.php
This file contains hidden or 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,19 @@ | ||
| @php | ||
| use ArtisanPackUI\VisualEditorRendererBlade\Support\BlockSupports; | ||
|
|
||
| $rawCount = $attributes['_resolvedCommentCount'] ?? 0; | ||
| $count = is_numeric( $rawCount ) ? (int) $rawCount : 0; | ||
|
|
||
| if ( $count < 0 ) { | ||
| $count = 0; | ||
| } | ||
|
|
||
| $singular = (string) ( $attributes['singularCommentText'] ?? 'Comment' ); | ||
| $plural = (string) ( $attributes['pluralCommentText'] ?? 'Comments' ); | ||
| $label = 1 === $count ? $singular : $plural; | ||
|
|
||
| $line = trim( $count . ' ' . $label ); | ||
|
|
||
| $baseClasses = [ 'ap-comments-number' ]; | ||
| @endphp | ||
| <p{!! BlockSupports::wrapperAttrs( $attributes, $baseClasses ) !!}>{{ $line }}</p> |
28 changes: 28 additions & 0 deletions
28
packages/visual-editor-renderer-blade/resources/views/blocks/artisanpack/copyright.blade.php
This file contains hidden or 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,28 @@ | ||
| @php | ||
| use ArtisanPackUI\VisualEditorRendererBlade\Support\BlockSupports; | ||
|
|
||
| $validTypes = [ 'icon-text', 'icon-only', 'text-only' ]; | ||
|
|
||
| $copyrightType = (string) ( $attributes['copyrightType'] ?? 'icon-text' ); | ||
|
|
||
| if ( ! in_array( $copyrightType, $validTypes, true ) ) { | ||
| $copyrightType = 'icon-text'; | ||
| } | ||
|
|
||
| $copyrightText = trim( (string) ( $attributes['copyrightText'] ?? 'Copyright' ) ); | ||
|
|
||
| $currentYear = gmdate( 'Y' ); | ||
|
|
||
| if ( 'icon-only' === $copyrightType ) { | ||
| $line = '© ' . $currentYear; | ||
| } elseif ( 'text-only' === $copyrightType ) { | ||
| $line = '' === $copyrightText ? $currentYear : $copyrightText . ' ' . $currentYear; | ||
| } else { | ||
| $line = '' === $copyrightText | ||
| ? '© ' . $currentYear | ||
| : '© ' . $copyrightText . ' ' . $currentYear; | ||
| } | ||
|
|
||
| $baseClasses = [ 'ap-copyright' ]; | ||
| @endphp | ||
| <p{!! BlockSupports::wrapperAttrs( $attributes, $baseClasses ) !!}>{{ $line }}</p> |
33 changes: 33 additions & 0 deletions
33
packages/visual-editor-renderer-blade/resources/views/blocks/artisanpack/marquee.blade.php
This file contains hidden or 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,33 @@ | ||
| @php | ||
| use ArtisanPackUI\VisualEditorRendererBlade\Support\BlockSupports; | ||
|
|
||
| $rawWidth = $attributes['marqueeWidth'] ?? 100; | ||
| $width = is_numeric( $rawWidth ) ? (int) round( (float) $rawWidth ) : 100; | ||
| $width = max( 1, min( 100, $width ) ); | ||
|
|
||
| $rawSpeed = $attributes['marqueeSpeed'] ?? 5; | ||
| $speed = is_numeric( $rawSpeed ) ? (int) round( (float) $rawSpeed ) : 5; | ||
| $speed = max( 1, min( 100, $speed ) ); | ||
|
|
||
| $content = (string) ( $attributes['marqueeContent'] ?? '' ); | ||
|
|
||
| $baseClasses = [ 'ap-marquee' ]; | ||
|
|
||
| // The wrapper width is a per-instance inline declaration that has | ||
| // to live alongside any block-supports style (background, padding, | ||
| // border) on the same `style="…"` attribute — emit them as one | ||
| // declaration so a second `style="…"` doesn't override the first. | ||
| $compiled = BlockSupports::compile( $attributes ); | ||
| $classes = array_values( array_unique( array_merge( $baseClasses, $compiled['classes'] ) ) ); | ||
| $styles = '' !== $compiled['style'] ? rtrim( $compiled['style'], ';' ) : ''; | ||
| $styles = ( '' !== $styles ? $styles . '; ' : '' ) . 'width: ' . $width . '%'; | ||
|
|
||
| $classAttr = sprintf( ' class="%s"', e( implode( ' ', $classes ) ) ); | ||
| $styleAttr = sprintf( ' style="%s"', e( $styles . ';' ) ); | ||
| $idAttr = null !== $compiled['id'] ? sprintf( ' id="%s"', e( $compiled['id'] ) ) : ''; | ||
|
|
||
| $textStyle = 'animation: ap-marquee-scroll ' . $speed . 's linear infinite;'; | ||
| @endphp | ||
| <div{!! $classAttr . $styleAttr . $idAttr !!}> | ||
| <p class="ap-marquee__text" style="{{ $textStyle }}">{!! $content !!}</p> | ||
| </div> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
28 changes: 28 additions & 0 deletions
28
packages/visual-editor-renderer-react/src/blocks/artisanpack/commentsNumber.tsx
This file contains hidden or 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,28 @@ | ||
| /** | ||
| * React renderer for the `artisanpack/comments-number` block (#500). | ||
| * | ||
| * Mirrors the Blade partial and the Vue renderer so every environment | ||
| * emits identical markup. The count is server-resolved (PostResolver | ||
| * stamps `_resolvedCommentCount`) and combined with the saved | ||
| * singular / plural labels at render time. | ||
| */ | ||
|
|
||
| import type { JSX } from 'react'; | ||
|
|
||
| import { attrInt, attrString, classList } from '../../support/attributes'; | ||
| import type { BlockRendererProps } from '../../types'; | ||
|
|
||
| export function CommentsNumberBlock({ | ||
| attributes, | ||
| }: BlockRendererProps): JSX.Element { | ||
| const count = Math.max(0, attrInt(attributes._resolvedCommentCount, 0)); | ||
| const singular = attrString(attributes.singularCommentText, 'Comment'); | ||
| const plural = attrString(attributes.pluralCommentText, 'Comments'); | ||
| const label = count === 1 ? singular : plural; | ||
| const className = attrString(attributes.className); | ||
|
|
||
| const classes = classList(['ap-comments-number', className]); | ||
| const line = `${count} ${label}`.trim(); | ||
|
|
||
| return <p className={classes}>{line}</p>; | ||
| } |
52 changes: 52 additions & 0 deletions
52
packages/visual-editor-renderer-react/src/blocks/artisanpack/copyright.tsx
This file contains hidden or 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,52 @@ | ||
| /** | ||
| * React renderer for the `artisanpack/copyright` block (#500). | ||
| * | ||
| * Mirrors the Blade partial at | ||
| * `packages/visual-editor-renderer-blade/resources/views/blocks/artisanpack/copyright.blade.php` | ||
| * and the Vue renderer so every environment emits identical markup. The | ||
| * current year is read at render time (not stamped server-side) so the | ||
| * line stays accurate whenever the page is rendered. | ||
| */ | ||
|
|
||
| import type { JSX } from 'react'; | ||
|
|
||
| import { attrString, classList } from '../../support/attributes'; | ||
| import type { BlockRendererProps } from '../../types'; | ||
|
|
||
| type CopyrightType = 'icon-text' | 'icon-only' | 'text-only'; | ||
|
|
||
| const VALID_TYPES: ReadonlyArray<CopyrightType> = [ | ||
| 'icon-text', | ||
| 'icon-only', | ||
| 'text-only', | ||
| ]; | ||
|
|
||
| function normalizeType(value: unknown): CopyrightType { | ||
| const raw = attrString(value, 'icon-text'); | ||
| return (VALID_TYPES as ReadonlyArray<string>).includes(raw) | ||
| ? (raw as CopyrightType) | ||
| : 'icon-text'; | ||
| } | ||
|
|
||
| function buildLine(type: CopyrightType, text: string, year: number): string { | ||
| const trimmed = text.trim(); | ||
| if (type === 'icon-only') { | ||
| return `© ${year}`; | ||
| } | ||
| if (type === 'text-only') { | ||
| return trimmed === '' ? `${year}` : `${trimmed} ${year}`; | ||
| } | ||
| return trimmed === '' ? `© ${year}` : `© ${trimmed} ${year}`; | ||
| } | ||
|
|
||
| export function CopyrightBlock({ attributes }: BlockRendererProps): JSX.Element { | ||
| const copyrightType = normalizeType(attributes.copyrightType); | ||
| const copyrightText = attrString(attributes.copyrightText, 'Copyright'); | ||
| const className = attrString(attributes.className); | ||
|
|
||
| const classes = classList(['ap-copyright', className]); | ||
| const year = new Date().getUTCFullYear(); | ||
| const line = buildLine(copyrightType, copyrightText, year); | ||
|
|
||
| return <p className={classes}>{line}</p>; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.