feat(site-builder): local-business block pack (hours, call bar, reviews, booking)
Refs #60
This commit is contained in:
1 parent
8860349c9b
commit
2cb04d2537
15 files changed
+837
-6
No files matched your search
@@ -11,12 +11,12 @@ const rootChildren = (hh: EditorHarness): string[] => JSON.parse(hh.getSerialize
|
||||
const typeOf = (hh: EditorHarness, id: string): string => JSON.parse(hh.getSerialized())[id].type.resolvedName;
|
||||
|
||||
describe('blocks registry', () => {
|
||||
test('43 blocks with the original category split', () => {
|
||||
expect(BLOCKS).toHaveLength(43);
|
||||
test('47 blocks with the original category split', () => {
|
||||
expect(BLOCKS).toHaveLength(47);
|
||||
const count = (c: string) => BLOCKS.filter((b) => b.category === c).length;
|
||||
expect([count('basic'), count('layout'), count('sections'), count('media'), count('forms'), count('business')]).toEqual([12, 11, 11, 3, 6, 0]);
|
||||
expect([count('basic'), count('layout'), count('sections'), count('media'), count('forms'), count('business')]).toEqual([12, 11, 11, 3, 6, 4]);
|
||||
expect(BLOCK_CATEGORIES.map((c) => c.id)).toContain('business');
|
||||
expect(new Set(BLOCKS.map((b) => b.id)).size).toBe(43);
|
||||
expect(new Set(BLOCKS.map((b) => b.id)).size).toBe(47);
|
||||
for (const b of BLOCKS) expect(b.keywords.length).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('blocks registry', () => {
|
||||
});
|
||||
|
||||
test('searchBlocks: empty returns all, pric ranks Pricing first, matches keywords and category', () => {
|
||||
expect(searchBlocks('')).toHaveLength(43);
|
||||
expect(searchBlocks('')).toHaveLength(47);
|
||||
expect(searchBlocks('pric')[0].id).toBe('pricing-table');
|
||||
expect(searchBlocks('FAQ').map((b) => b.id)).toEqual(['accordion']);
|
||||
expect(searchBlocks('newsletter').map((b) => b.id)).toContain('subscribe-form');
|
||||
@@ -81,7 +81,7 @@ describe('BlocksPanel smoke', () => {
|
||||
h.mountChild(<BlocksPanel />);
|
||||
const cats = Array.from(h.container.querySelectorAll('.block-category'));
|
||||
const summary = cats.map((c) => [c.querySelector('.block-category-header span')!.textContent, c.querySelectorAll('.block-item').length]);
|
||||
expect(summary).toEqual([['Basic', 12], ['Layout', 11], ['Sections', 11], ['Media', 3], ['Forms', 6]]);
|
||||
expect(summary).toEqual([['Basic', 12], ['Layout', 11], ['Sections', 11], ['Media', 3], ['Forms', 6], ['Business', 4]]);
|
||||
});
|
||||
|
||||
test('double-click appends to the canvas without selecting', () => {
|
||||
|
||||
@@ -35,6 +35,10 @@ import { ContactForm } from '../../components/forms/ContactForm';
|
||||
import { SubscribeForm } from '../../components/forms/SubscribeForm';
|
||||
import { StarRating } from '../../components/basic/StarRating';
|
||||
import { SocialLinks } from '../../components/basic/SocialLinks';
|
||||
import { OpeningHours } from '../../components/business/OpeningHours';
|
||||
import { StickyCallBar } from '../../components/business/StickyCallBar';
|
||||
import { ReviewsStrip } from '../../components/business/ReviewsStrip';
|
||||
import { BookingEmbed } from '../../components/business/BookingEmbed';
|
||||
|
||||
export type BlockCategoryId = 'basic' | 'layout' | 'sections' | 'media' | 'forms' | 'business';
|
||||
|
||||
@@ -145,6 +149,14 @@ export const BLOCKS: ReadonlyArray<BlockDef> = [
|
||||
create: () => <TextareaField /> },
|
||||
{ id: 'form-button', label: 'Submit', icon: 'fa-paper-plane', category: 'forms', keywords: ['submit', 'send', 'form', 'button'],
|
||||
create: () => <FormButton /> },
|
||||
{ id: 'opening-hours', label: 'Opening Hours', icon: 'fa-clock-o', category: 'business', keywords: ['hours', 'opening', 'times', 'schedule', 'open'],
|
||||
create: () => <OpeningHours /> },
|
||||
{ id: 'call-bar', label: 'Call Bar', icon: 'fa-phone', category: 'business', keywords: ['call', 'phone', 'directions', 'sticky', 'mobile'],
|
||||
create: () => <StickyCallBar /> },
|
||||
{ id: 'reviews-strip', label: 'Reviews', icon: 'fa-star', category: 'business', keywords: ['reviews', 'testimonials', 'google', 'stars', 'ratings'],
|
||||
create: () => <ReviewsStrip /> },
|
||||
{ id: 'booking-embed', label: 'Booking', icon: 'fa-calendar', category: 'business', keywords: ['booking', 'calendly', 'appointment', 'schedule', 'square'],
|
||||
create: () => <BookingEmbed /> },
|
||||
];
|
||||
|
||||
export function getBlock(id: string): BlockDef | undefined {
|
||||
|
||||
@@ -66,6 +66,8 @@ export const VIRTUAL_CHILD_PROPS: Record<string, VirtualChildSpec> = {
|
||||
Hero: { prop: 'ctas', label: 'text', fallback: 'Button' },
|
||||
'Call to Action': { prop: 'ctas', label: 'text', fallback: 'Button' },
|
||||
'CTA Section': { prop: 'ctas', label: 'text', fallback: 'Button' },
|
||||
'Opening Hours': { prop: 'rows', label: 'day', fallback: 'Day' },
|
||||
Reviews: { prop: 'reviews', label: 'name', fallback: 'Review' },
|
||||
};
|
||||
|
||||
const MAX_LABEL = 40;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
StylePanelProps,
|
||||
CollapsibleSection,
|
||||
ColorPickerField,
|
||||
labelStyle,
|
||||
inputStyle,
|
||||
sectionGap,
|
||||
useNodeProp,
|
||||
AnimationControl,
|
||||
VisibilityControl,
|
||||
} from './shared';
|
||||
import { ArrayItemFieldsEditor } from './ArrayItemFields';
|
||||
|
||||
/* ---------- Local-business blocks: Opening Hours / Call Bar / Reviews / Booking ----------
|
||||
Text fields are listed per prop; a field renders only when the prop exists on
|
||||
the node (present-but-blank defaults make controls appear). Array props reuse
|
||||
the shared item editor (fields come from items[0]). Classified by the
|
||||
integrator in GuidedStyles: /^opening hours$|^call bar$|^reviews$|^booking$/i */
|
||||
const TEXT_PROPS: Array<[string, string]> = [
|
||||
['title', 'Title'], ['note', 'Note'],
|
||||
['phone', 'Phone'], ['callLabel', 'Call button label'],
|
||||
['directionsUrl', 'Directions link'], ['directionsLabel', 'Directions button label'],
|
||||
['allReviewsUrl', 'All-reviews link'], ['allReviewsLabel', 'All-reviews label'],
|
||||
['url', 'Booking URL (Calendly / Square)'], ['height', 'Height'],
|
||||
];
|
||||
const COLOR_PROPS: Array<[string, string]> = [
|
||||
['labelColor', 'Label color'], ['valueColor', 'Value color'],
|
||||
['bgColor', 'Background'], ['textColor', 'Text color'], ['cardBg', 'Card background'],
|
||||
];
|
||||
|
||||
export const BusinessStylePanel: React.FC<StylePanelProps> = ({ selectedId, nodeProps }) => {
|
||||
const { setProp, setProps, setPropContinuous } = useNodeProp(selectedId);
|
||||
const arrays = Object.entries(nodeProps).filter(([, v]) => Array.isArray(v));
|
||||
|
||||
return (
|
||||
<>
|
||||
<CollapsibleSection title="Content">
|
||||
{nodeProps.provider !== undefined && (
|
||||
<div style={sectionGap}>
|
||||
<label style={labelStyle}>Provider</label>
|
||||
<select value={String(nodeProps.provider)} onChange={(e) => setProp('provider', e.target.value)} style={inputStyle}>
|
||||
<option value="calendly">Calendly</option>
|
||||
<option value="square">Square Appointments</option>
|
||||
<option value="custom">Other (allowed hosts only)</option>
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
{TEXT_PROPS.filter(([k]) => typeof nodeProps[k] === 'string').map(([k, label]) => (
|
||||
<div key={k} style={sectionGap}>
|
||||
<label style={labelStyle}>{label}</label>
|
||||
<input type="text" value={nodeProps[k]} onChange={(e) => setPropContinuous(k, e.target.value)} style={inputStyle} />
|
||||
</div>
|
||||
))}
|
||||
</CollapsibleSection>
|
||||
|
||||
{arrays.map(([key, items]) => (
|
||||
<ArrayItemFieldsEditor key={key} selectedId={selectedId} propKey={key} items={items as any[]} />
|
||||
))}
|
||||
|
||||
{COLOR_PROPS.some(([k]) => typeof nodeProps[k] === 'string') && (
|
||||
<CollapsibleSection title="Colors">
|
||||
{COLOR_PROPS.filter(([k]) => typeof nodeProps[k] === 'string').map(([k, label]) => (
|
||||
<ColorPickerField key={k} label={label} value={nodeProps[k]} onChange={(v) => setPropContinuous(k, v)} />
|
||||
))}
|
||||
</CollapsibleSection>
|
||||
)}
|
||||
|
||||
<CollapsibleSection title="Animation" defaultOpen={false}>
|
||||
<AnimationControl
|
||||
value={{ animation: nodeProps.animation || 'none', animationDelay: nodeProps.animationDelay || '0' }}
|
||||
onChange={(v) => setProps({ animation: v.animation, animationDelay: v.animationDelay })}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
|
||||
<CollapsibleSection title="Visibility" defaultOpen={nodeProps.hideOnDesktop === true}>
|
||||
<VisibilityControl
|
||||
value={{ hideOnDesktop: !!nodeProps.hideOnDesktop, hideOnTablet: !!nodeProps.hideOnTablet, hideOnMobile: !!nodeProps.hideOnMobile }}
|
||||
onChange={(v) => setProps({ hideOnDesktop: !!v.hideOnDesktop, hideOnTablet: !!v.hideOnTablet, hideOnMobile: !!v.hideOnMobile })}
|
||||
/>
|
||||
</CollapsibleSection>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -12,3 +12,4 @@ export { PricingStylePanel } from './PricingStylePanel';
|
||||
export { BackgroundSectionStylePanel } from './BackgroundSectionStylePanel';
|
||||
export { GenericPropsEditor } from './GenericPropsEditor';
|
||||
export { HtmlStylePanel } from './HtmlStylePanel';
|
||||
export { BusinessStylePanel } from './BusinessStylePanel';
|
||||
Reference in new issue
Block a user