@embeddables/cli 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -193,6 +193,8 @@ Styles are stored in `Flow.styles` as a map of CSS selectors to style objects. T
|
|
|
193
193
|
|
|
194
194
|
**File Mapping**: `styles/index.css` — a single CSS file containing all selectors for this flow.
|
|
195
195
|
|
|
196
|
+
**Do not use `!important` in CSS.** If a style does not apply, fix the selector (order, breakpoint, scope, tag, state, sub-element) per the CSS Selector System below; do not use `!important` as a fix.
|
|
197
|
+
|
|
196
198
|
### CSS Selector System
|
|
197
199
|
|
|
198
200
|
CSS selectors follow a specific structure. The order is:
|
|
@@ -252,7 +254,8 @@ Note: If you need to use any breakpoints other than 720px and 520px, you must ad
|
|
|
252
254
|
#### 7. Sub-Element (Descendant)
|
|
253
255
|
|
|
254
256
|
- Format: ` .ElementType-{Type}` (leading space required!)
|
|
255
|
-
-
|
|
257
|
+
- The component you target with element+tag (steps 4–5) must be the **component that owns** that sub-element (see 'Component Sub-Element Types Reference' below). Do not combine a container (or other parent) with a sub-element that belongs to a child component—e.g. do not use a container tag + `.ElementType-ButtonText`, because `ButtonText` is a sub-element of CustomButton; target the CustomButton (with its tag) instead.
|
|
258
|
+
- See the 'Component Sub-Element Types Reference' section below for which ElementTypes belong to which component type.
|
|
256
259
|
|
|
257
260
|
#### 8. Option (For Option Selectors)
|
|
258
261
|
|
|
@@ -274,8 +277,8 @@ Note: If you need to use any breakpoints other than 720px and 520px, you must ad
|
|
|
274
277
|
// Component with hover state
|
|
275
278
|
.Flow-Component.ComponentTag-primary_button:hover
|
|
276
279
|
|
|
277
|
-
// Button text on hover
|
|
278
|
-
.Flow-Component.ComponentType-CustomButton.ComponentTag-primary_button:hover.ElementType-ButtonText
|
|
280
|
+
// Button text on hover (sub-element: component in selector must be the one that owns it—CustomButton, not a container)
|
|
281
|
+
.Flow-Component.ComponentType-CustomButton.ComponentTag-primary_button:hover .ElementType-ButtonText
|
|
279
282
|
|
|
280
283
|
// Mobile breakpoint
|
|
281
284
|
.Flow-EntireFlow[max-width~='1024px'] .Flow-Component.ComponentTag-landing_container
|
|
@@ -630,11 +633,13 @@ The `config.json` file contains the reduced Embeddable JSON with:
|
|
|
630
633
|
|
|
631
634
|
7. **CSS Selectors**: Must follow exact structure with proper spacing (trailing space on breakpoints, leading space on sub-elements).
|
|
632
635
|
|
|
633
|
-
8. **
|
|
636
|
+
8. **No `!important` in CSS**: Do not use `!important` in embeddable styles. If a style does not apply, fix the selector per the CSS Selector System (principle 7); do not use `!important` as a fix.
|
|
637
|
+
|
|
638
|
+
9. **User Data Keys**: Input component keys become User Data keys. Choose descriptive names (e.g., `email` not `email_input`).
|
|
634
639
|
|
|
635
|
-
|
|
640
|
+
10. **Computed Field Dependencies**: `inputs` array defines which User Data keys trigger recalculation. Can reference other computed fields.
|
|
636
641
|
|
|
637
|
-
|
|
642
|
+
11. **Action Triggers**: Actions are triggered by events (button clicks, page completion, etc.). Configuration stored in config.json, code in JS files.
|
|
638
643
|
|
|
639
644
|
## Common Patterns
|
|
640
645
|
|
|
@@ -45,7 +45,7 @@ export function PageNavigator({ embeddableId }) {
|
|
|
45
45
|
window.addEventListener(USERDATA_UPDATED_EVENT, handler);
|
|
46
46
|
return () => window.removeEventListener(USERDATA_UPDATED_EVENT, handler);
|
|
47
47
|
}, [embeddableId, refresh]);
|
|
48
|
-
// Close dropdown when clicking outside
|
|
48
|
+
// Close dropdown when clicking outside (use 'click' so selecting a page item fires its onClick before we consider closing)
|
|
49
49
|
useEffect(() => {
|
|
50
50
|
const handleClickOutside = (event) => {
|
|
51
51
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
@@ -53,8 +53,8 @@ export function PageNavigator({ embeddableId }) {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
if (isDropdownOpen) {
|
|
56
|
-
document.addEventListener('
|
|
57
|
-
return () => document.removeEventListener('
|
|
56
|
+
document.addEventListener('click', handleClickOutside);
|
|
57
|
+
return () => document.removeEventListener('click', handleClickOutside);
|
|
58
58
|
}
|
|
59
59
|
}, [isDropdownOpen]);
|
|
60
60
|
// Scroll to current page when dropdown opens
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WorkbenchApp.d.ts","sourceRoot":"","sources":["../../src/workbench/WorkbenchApp.tsx"],"names":[],"mappings":"AAuBA,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAqCD,wBAAgB,YAAY,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"WorkbenchApp.d.ts","sourceRoot":"","sources":["../../src/workbench/WorkbenchApp.tsx"],"names":[],"mappings":"AAuBA,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAqCD,wBAAgB,YAAY,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CA4SzE"}
|
|
@@ -96,8 +96,8 @@ export function WorkbenchApp({ embeddableId, localDev }) {
|
|
|
96
96
|
}, []);
|
|
97
97
|
useEffect(() => {
|
|
98
98
|
const handler = (event) => {
|
|
99
|
-
|
|
100
|
-
const isToggleShortcut =
|
|
99
|
+
// Use event.code (physical key) so Option+K works on Mac; Option changes event.key
|
|
100
|
+
const isToggleShortcut = event.altKey && event.code === 'KeyK';
|
|
101
101
|
if (isToggleShortcut) {
|
|
102
102
|
event.preventDefault();
|
|
103
103
|
setCollapsed((prev) => {
|
|
@@ -189,5 +189,5 @@ export function WorkbenchApp({ embeddableId, localDev }) {
|
|
|
189
189
|
? 'bg-white/15 text-white ring-1 ring-inset ring-white/20'
|
|
190
190
|
: 'text-slate-400 hover:bg-white/5 hover:text-slate-200'}`, children: "Actions" }), _jsx("button", { type: "button", onClick: () => switchTab('computed-fields'), className: `cursor-pointer rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors ${activeTab === 'computed-fields'
|
|
191
191
|
? 'bg-white/15 text-white ring-1 ring-inset ring-white/20'
|
|
192
|
-
: 'text-slate-400 hover:bg-white/5 hover:text-slate-200'}`, children: "Computed Fields" })] }))] }), _jsxs("div", { className: "flex items-center gap-6", children: [isSavvyReady && _jsx(PageNavigator, { embeddableId: embeddableId }), _jsxs("div", { className: "flex cursor-pointer items-center gap-2 text-slate-300", onClick: toggleCollapsed, children: [_jsxs("div", { className: "hidden text-[11px] text-slate-400 sm:block", children: [collapsed ? 'Show' : 'Hide', " \u2022", ' ', navigator.platform.toLowerCase().includes('mac') ? '
|
|
192
|
+
: 'text-slate-400 hover:bg-white/5 hover:text-slate-200'}`, children: "Computed Fields" })] }))] }), _jsxs("div", { className: "flex items-center gap-6", children: [isSavvyReady && _jsx(PageNavigator, { embeddableId: embeddableId }), _jsxs("div", { className: "flex cursor-pointer items-center gap-2 text-slate-300", onClick: toggleCollapsed, children: [_jsxs("div", { className: "hidden text-[11px] text-slate-400 sm:block", children: [collapsed ? 'Show' : 'Hide', " \u2022", ' ', navigator.platform.toLowerCase().includes('mac') ? '⌥K' : 'Alt+K'] }), _jsx("div", { className: "grid h-7 w-7 place-items-center rounded-lg bg-white/5 ring-1 ring-inset ring-white/10", children: _jsx("span", { className: "text-sm leading-none", children: collapsed ? '▲' : '▼' }) })] })] })] }), !collapsed && (_jsx("div", { className: "flex flex-col border-t border-white/10 bg-slate-950/70 px-3 py-3 text-slate-200 shadow-2xl shadow-black/40 backdrop-blur supports-backdrop-filter:bg-slate-950/60", style: { height }, children: !isSavvyReady ? (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsx("div", { className: "text-sm text-slate-400", children: "Waiting for embeddable to initialize..." }) })) : (_jsxs(_Fragment, { children: [activeTab === 'user-data' && _jsx(UserDataPanel, { embeddableId: embeddableId }), activeTab === 'experiments' && _jsx(ExperimentsPanel, { embeddableId: embeddableId }), activeTab === 'inspector' && _jsx(InspectorPanel, { embeddableId: embeddableId }), activeTab === 'autofill' && _jsx(AutofillPanel, { embeddableId: embeddableId }), activeTab === 'actions' && _jsx(ActionsPanel, { embeddableId: embeddableId }), activeTab === 'computed-fields' && (_jsx(ComputedFieldsPanel, { embeddableId: embeddableId }))] })) }))] }));
|
|
193
193
|
}
|