'; }
public static function tag() { return 'div'; }
public static function tagOptions() { return []; }
public static function tagControlPath() { return false; }
public static function name() { return 'Commerce View'; }
public static function className() { return 'fcbd-commerce-view-element'; }
public static function category() { return 'fluentcart'; }
public static function badge() { return ['label' => 'FC', 'backgroundColor' => '#3157d5', 'textColor' => '#fff']; }
public static function slug() { return __CLASS__; }
public static function template() { return file_get_contents(__DIR__ . '/html.twig'); }
public static function defaultCss() { return file_get_contents(__DIR__ . '/default.css'); }
public static function cssTemplate() { return file_get_contents(__DIR__ . '/css.twig'); }
public static function defaultChildren() { return false; }
public static function dependencies() { return false; }
public static function settingsControls() { return []; }
public static function settings() { return ['proOnly' => false]; }
public static function availableIn() { return ['oxygen', 'breakdance']; }
public static function propertyPathsToSsrElementWhenValueChanges()
{
return ['content.view'];
}
public static function defaultProperties()
{
return ['content' => ['view' => ['type' => 'cart', 'live_preview' => false]]];
}
public static function contentControls()
{
return [c('view', __('Commerce view', 'sparkcore-commerce'), [
c('type', __('View', 'sparkcore-commerce'), [], ['type' => 'dropdown', 'layout' => 'inline', 'items' => [
['value' => 'cart', 'text' => __('Cart', 'sparkcore-commerce')],
['value' => 'checkout', 'text' => __('Checkout', 'sparkcore-commerce')],
['value' => 'account', 'text' => __('Customer account', 'sparkcore-commerce')],
['value' => 'receipt', 'text' => __('Receipt', 'sparkcore-commerce')],
]], false, false, []),
c('live_preview', __('Live editor preview', 'sparkcore-commerce'), [], ['type' => 'toggle', 'layout' => 'inline'], false, false, []),
], ['type' => 'section', 'layout' => 'vertical'], false, false, [])];
}
/**
* Keeps only the named children (by slug) of a `c()`/`controlSection()`-shaped
* section, in the order they already appear. Used below to adopt PART of a shared
* ControlPresets section without duplicating a field this element already has under
* a different path (FIXTAAK TAAK 2).
*
* @param array $section
* @param array $keepSlugs
* @return array
*/
private static function onlyChildren(array $section, array $keepSlugs): array
{
$section['children'] = array_values(array_filter(
$section['children'],
static fn(array $child): bool => in_array($child['slug'], $keepSlugs, true)
));
return $section;
}
/**
* FIXTAAK TAAK 2: this element already has four working fields under its own
* 'layout' section (max_width, background, padding, radius) rendering real, already
* shipped CSS in css.twig; none of those paths change here, so an existing page keeps
* looking exactly as it does today. What was missing was a border color, a border
* width and a shadow, i.e. containerSection()'s remaining three fields ("geverfd
* blok" -> "kaart met rand").
*
* Chosen route: AUGMENT, not replace. containerSection() is adopted but filtered down
* to border_color/border_width/shadow only (onlyChildren() above); its own
* 'background' and 'border_radius' fields are deliberately dropped so this element
* never shows two competing background controls, or two competing radius controls,
* at two different paths (design.layout.background vs design.container.background,
* design.layout.radius vs design.container.border_radius). Replacing the 'layout'
* section instead (moving background/padding/radius onto containerSection()'s own
* paths) was rejected: it would orphan any already-set design.layout.* value on an
* existing page with no control left to show or fall back to it, exactly the silent
* regression TAAK 1 warns against, for no benefit over augmenting.
*
* spacingSection() is filtered the same way, to margin_top/margin_bottom only:
* 'padding' is dropped for the same reason (design.layout.padding already does that
* job). typographySection() is added whole, with $parts = ['text'] only (FIXTAAK
* TAAK 3): every one of this element's four views (cart/checkout/account/receipt) is
* FluentCart's own native shortcode output, never this plugin's own `.fcbd-heading`
* node, so the Heading Color/Heading Font Family fields would be dead controls.
*/
public static function designControls()
{
return [
controlSection('layout', __('Layout', 'sparkcore-commerce'), [
control('max_width', __('Maximum width', 'sparkcore-commerce'), ['type' => 'unit', 'layout' => 'inline'], true),
control('background', __('Background', 'sparkcore-commerce'), ['type' => 'color', 'layout' => 'inline']),
control('padding', __('Padding', 'sparkcore-commerce'), ['type' => 'unit', 'layout' => 'inline']),
control('radius', __('Radius', 'sparkcore-commerce'), ['type' => 'unit', 'layout' => 'inline']),
]),
self::onlyChildren(
ControlPresets::containerSection('container', __('Container', 'sparkcore-commerce')),
['border_color', 'border_width', 'shadow']
),
self::onlyChildren(
ControlPresets::spacingSection(),
['margin_top', 'margin_bottom']
),
ControlPresets::typographySection('typography', __('Typography', 'sparkcore-commerce'), ['text']),
];
}
}