@salsita-ai/sdk 0.50.0-develop.8c8c362f86 → 0.50.0-develop.8e3768cb11
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.
- package/dist/application-spec/core/components/component-filter.d.ts +53 -0
- package/dist/application-spec/core/components/component-filter.js +1 -0
- package/dist/application-spec/core/components/index.d.ts +2 -0
- package/dist/application-spec/core/components/index.js +1 -0
- package/dist/application-spec/core/components/sdk-code-ref.d.ts +9 -0
- package/dist/application-spec/core/components/sdk-code-ref.js +1 -0
- package/dist/application-spec/core/enhanced-json-value.d.ts +0 -68
- package/dist/application-spec/core/enhanced-json-value.js +1 -1
- package/dist/application-spec/core/expressions/index.d.ts +2 -0
- package/dist/application-spec/core/expressions/index.js +1 -0
- package/dist/application-spec/core/expressions/relation-expression-params.d.ts +11 -0
- package/dist/application-spec/core/expressions/relation-expression-params.js +1 -0
- package/dist/application-spec/core/expressions/sdk-expression-implementation.d.ts +24 -0
- package/dist/application-spec/core/expressions/sdk-expression-implementation.js +1 -0
- package/dist/application-spec/core/index.d.ts +2 -0
- package/dist/application-spec/core/index.js +1 -1
- package/dist/application-spec/core/json-value.d.ts +1 -1
- package/dist/application-spec/{core → enhanced-json}/eval-to-constant.d.ts +1 -1
- package/dist/application-spec/enhanced-json/index.d.ts +4 -0
- package/dist/application-spec/enhanced-json/index.js +1 -0
- package/dist/application-spec/enhanced-json/is-enhanced-json-array.d.ts +2 -0
- package/dist/application-spec/enhanced-json/is-enhanced-json-array.js +1 -0
- package/dist/application-spec/enhanced-json/resolve-enhanced-json-value.d.ts +18 -0
- package/dist/application-spec/enhanced-json/resolve-enhanced-json-value.js +1 -0
- package/dist/application-spec/enhanced-json/schema-from-value.d.ts +24 -0
- package/dist/application-spec/enhanced-json/schema-from-value.js +1 -0
- package/dist/application-spec/enhanced-json/stringify-enhanced-json-value.d.ts +14 -0
- package/dist/application-spec/enhanced-json/stringify-enhanced-json-value.js +1 -0
- package/dist/application-spec/enhanced-json/validate-enhanced-json-value-caps.d.ts +12 -0
- package/dist/application-spec/enhanced-json/validate-enhanced-json-value-caps.js +1 -0
- package/dist/application-spec/enhanced-json/validate-no-legacy-code-ref.d.ts +13 -0
- package/dist/application-spec/enhanced-json/validate-no-legacy-code-ref.js +1 -0
- package/dist/application-spec/generate-application/code/generate-application-code.d.ts +3 -2
- package/dist/application-spec/generate-application/code/generate-application-code.js +1 -1
- package/dist/application-spec/generate-application/code/project-scaffolding.d.ts +9 -4
- package/dist/application-spec/generate-application/code/project-scaffolding.js +2 -2
- package/dist/application-spec/generate-application/code/standalone-app-files.d.ts +2 -2
- package/dist/application-spec/generate-application/code/standalone-app-files.js +1 -1
- package/dist/application-spec/generate-application/code/templates/configurator-config.js +6 -4
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-component-optics.js +4 -4
- package/dist/application-spec/generate-application/code/templates/domain-spec/generate-defaults.js +1 -1
- package/dist/application-spec/generate-application/code/templates/gitignore.js +1 -2
- package/dist/application-spec/generate-application/code/templates/index.d.ts +1 -1
- package/dist/application-spec/generate-application/code/templates/index.js +1 -1
- package/dist/application-spec/generate-application/code/templates/package-json.js +1 -1
- package/dist/application-spec/generate-application/code/templates/root-tsconfig.d.ts +6 -0
- package/dist/application-spec/generate-application/code/templates/root-tsconfig.js +2 -0
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-review-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/phoenix-skill.js +1 -1
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.d.ts +10 -4
- package/dist/application-spec/generate-application/code/templates/skills/sdk-content.js +2 -2
- package/dist/application-spec/generate-application/code/templates/tsconfig.d.ts +5 -0
- package/dist/application-spec/generate-application/code/templates/tsconfig.js +1 -1
- package/dist/application-spec/generate-application/code/templates/webhook-index.d.ts +6 -1
- package/dist/application-spec/generate-application/code/templates/webhook-index.js +10 -1
- package/dist/application-spec/generate-application/index.d.ts +2 -0
- package/dist/application-spec/generate-application/index.js +1 -1
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.d.ts +6 -2
- package/dist/application-spec/generate-application/runtime/admin-runtime/admin-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/application-runtime.d.ts +8 -1
- package/dist/application-spec/generate-application/runtime/application-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.d.ts +5 -1
- package/dist/application-spec/generate-application/runtime/configurator-runtime/configurator-runtime.js +1 -1
- package/dist/application-spec/generate-application/runtime/factory-data/factory-data-runtime.d.ts +43 -0
- package/dist/application-spec/generate-application/runtime/factory-data/factory-data-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/factory-data/index.d.ts +3 -0
- package/dist/application-spec/generate-application/runtime/factory-data/index.js +1 -0
- package/dist/application-spec/generate-application/runtime/factory-data/recipe-defaults.d.ts +13 -0
- package/dist/application-spec/generate-application/runtime/factory-data/recipe-defaults.js +1 -0
- package/dist/application-spec/generate-application/runtime/factory-data/static-violations.d.ts +16 -0
- package/dist/application-spec/generate-application/runtime/factory-data/static-violations.js +1 -0
- package/dist/application-spec/generate-application/runtime/migrations/index.d.ts +1 -0
- package/dist/application-spec/generate-application/runtime/migrations/index.js +1 -0
- package/dist/application-spec/generate-application/runtime/migrations/migration-runtime.d.ts +53 -0
- package/dist/application-spec/generate-application/runtime/migrations/migration-runtime.js +1 -0
- package/dist/application-spec/generate-application/runtime/sections/build-sdk-optic.d.ts +1 -1
- package/dist/application-spec/generate-application/runtime/sections/build-sdk-optic.js +1 -1
- package/dist/application-spec/generate-application/runtime/sections/expression-runtime.js +1 -1
- package/dist/application-spec/index.d.ts +1 -0
- package/dist/application-spec/index.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/categorize-files.d.ts +16 -0
- package/dist/application-spec/parse-application-files/categorize/categorize-files.js +1 -1
- package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.d.ts +9 -0
- package/dist/application-spec/parse-application-files/categorize/earlier-generated-tsconfig.js +1 -0
- package/dist/application-spec/parse-application-files/raw-spec/raw-spec-file.js +1 -1
- package/dist/application-spec/parse-application-files/spec/components/component-entry.d.ts +1 -9
- package/dist/application-spec/parse-application-files/spec/components/component-entry.js +1 -1
- package/dist/application-spec/parse-application-files/spec/components/component-filter.d.ts +1 -54
- package/dist/application-spec/parse-application-files/spec/components/component-filter.js +1 -1
- package/dist/application-spec/parse-application-files/spec/components/index.d.ts +1 -1
- package/dist/application-spec/parse-application-files/spec/components/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/expression.d.ts +1 -28
- package/dist/application-spec/parse-application-files/spec/expressions/expression.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/expressions.d.ts +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/expressions.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/index.d.ts +0 -1
- package/dist/application-spec/parse-application-files/spec/expressions/index.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/memo-eval-plan.js +1 -1
- package/dist/application-spec/parse-application-files/spec/expressions/user-expressions.js +1 -1
- package/dist/application-spec/parse-application-files/spec/model/defaults.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.d.ts +29 -0
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/assistant-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.d.ts +7 -1
- package/dist/configurator/application-runtime/extensions/systems/assistant-system/graphql-tools.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/drag-and-drop-system/drag-and-drop-system.d.ts +3 -3
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.d.ts +6 -0
- package/dist/configurator/application-runtime/extensions/systems/graphql-system/graphql-system.js +1 -1
- package/dist/configurator/application-runtime/extensions/systems/layout-system/layout-system.d.ts +2 -2
- package/dist/configurator/common/configurator-interface.d.ts +22 -1
- package/dist/configurator/common/configurator-interface.js +1 -1
- package/dist/configurator/common/frontend-analytics.d.ts +2 -0
- package/dist/configurator/common/frontend-analytics.js +1 -1
- package/dist/configurator/common/index.d.ts +2 -0
- package/dist/configurator/common/index.js +1 -1
- package/dist/configurator/common/use-finalize-action.d.ts +31 -0
- package/dist/configurator/common/use-finalize-action.js +1 -0
- package/dist/configurator/common/use-reset-camera.d.ts +6 -0
- package/dist/configurator/common/use-reset-camera.js +1 -0
- package/dist/configurator/configurator-context/configurator-hooks/layout-hooks.d.ts +1 -1
- package/dist/configurator/pages/DefaultConfiguratorLayout.d.ts +2 -2
- package/dist/configurator/pages/LoadedConfiguratorDetailPage.js +1 -1
- package/dist/configurator/pages/configurator-layout-name.d.ts +2 -0
- package/dist/configurator/pages/configurator-layout-name.js +1 -0
- package/dist/configurator/pages/default-configurator-elements.d.ts +7 -0
- package/dist/configurator/pages/default-configurator-elements.js +1 -0
- package/dist/configurator/pages/index.d.ts +1 -0
- package/dist/configurator/pages/index.js +1 -1
- package/dist/configurator/scene/scene-controls/hotspot-drag-handle/HotspotDragHandle.d.ts +1 -1
- package/dist/configurator/scene/scene-controls/hotspot-drag-handle/HotspotDragSceneHandle.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/dimension-indicators/DimensionIndicator.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/dimension-indicators/DimensionIndicatorInternal.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/drag-and-drop/shared.d.ts +2 -2
- package/dist/configurator/scene/scene-entity/drag-and-drop/use-drag-object.d.ts +1 -1
- package/dist/configurator/scene/scene-entity/materials/RemoteReplacedMaterial.js +1 -1
- package/dist/configurator/scene/scene-entity/objects/SceneEntityObjectTextDecal.d.ts +1 -1
- package/dist/configurator/ui/assistant/AssistantChips.d.ts +8 -2
- package/dist/configurator/ui/assistant/AssistantChips.js +1 -1
- package/dist/configurator/ui/assistant/AssistantMarkdown.d.ts +1 -1
- package/dist/configurator/ui/assistant/AssistantMarkdown.js +1 -1
- package/dist/configurator/ui/assistant/AssistantThread.js +1 -1
- package/dist/configurator/ui/assistant/entity-link/AssistantEntityLink.d.ts +13 -0
- package/dist/configurator/ui/assistant/entity-link/AssistantEntityLink.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-selection.d.ts +22 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-selection.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-state.d.ts +27 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-state.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-target.d.ts +5 -0
- package/dist/configurator/ui/assistant/entity-link/entity-link-target.js +1 -0
- package/dist/configurator/ui/assistant/entity-link/index.d.ts +3 -0
- package/dist/configurator/ui/assistant/entity-link/index.js +1 -0
- package/dist/configurator/ui/configurator-layout/slots/services/InvariantViolations.d.ts +4 -4
- package/dist/configurator/ui/configurator-layout/slots/services/InvariantViolations.js +1 -1
- package/dist/configurator/ui/configurator-layout/slots/services/SideEffects.d.ts +3 -6
- package/dist/configurator/ui/configurator-layout/slots/services/SideEffects.js +1 -1
- package/dist/configurator/ui/legacy/layout/steps/StepsNavigation.d.ts +2 -2
- package/dist/configurator/ui/phoenix-layout-elements/header/common/step-navigation/StepsNavigation.d.ts +2 -2
- package/dist/docs/dimensions/3d-scene-integration/dimension-indicators.mdx +2 -2
- package/dist/docs/dimensions/3d-scene-integration/editable-angle-indicator.mdx +1 -1
- package/dist/docs/dimensions/3d-scene-integration/editable-distance-dimension-indicator.mdx +1 -1
- package/dist/docs/dimensions/3d-scene-integration/list-selector-dimension-indicator.mdx +1 -1
- package/dist/docs/drag-and-drop/drag-handle.mdx +1 -1
- package/dist/docs/drag-and-drop/hotspot-handle.mdx +1 -1
- package/dist/docs/drag-and-drop/planes.mdx +1 -1
- package/dist/docs/drag-and-drop/rotatable.mdx +2 -2
- package/dist/docs/index.json +11 -1
- package/dist/docs/layouts/custom-layout.mdx +1323 -179
- package/dist/docs/layouts/header/fixed.mdx +2 -2
- package/dist/docs/layouts/header/floating.mdx +2 -2
- package/dist/docs/layouts/sidebar/in-a-custom-layout.mdx +2 -2
- package/dist/docs/layouts/sidebar-footer/basic.mdx +32 -77
- package/dist/docs/other-features/client-side-rendering/declarative.mdx +1 -1
- package/dist/docs/phoenix/application-states.mdx +9 -7
- package/dist/docs/phoenix/configurator-interface.mdx +134 -18
- package/dist/docs/phoenix/finalization.mdx +1 -1
- package/dist/docs/phoenix/layout-slots.mdx +116 -0
- package/dist/docs/phoenix/migration-guide.mdx +19 -8
- package/dist/docs/phoenix/phoenix-cli.mdx +26 -8
- package/dist/docs/phoenix/project-structure.mdx +20 -5
- package/dist/docs/phoenix/sdk-builder-workflow.mdx +2 -2
- package/dist/docs/phoenix/webhooks.mdx +17 -0
- package/dist/domain/application/application-config.d.ts +3 -1
- package/dist/domain/application/assistant/generate-assistant-prompt.js +1 -1
- package/dist/domain/application/configurator-builder.d.ts +4 -1
- package/dist/domain/application/configurator-builder.js +1 -1
- package/dist/domain/core/invariant/violation.d.ts +50 -2
- package/dist/domain/core/invariant/violation.js +1 -1
- package/dist/domain/core/model/model.d.ts +1 -1
- package/dist/domain/domain-context/index.d.ts +1 -1
- package/dist/domain/domain-context/undo-system.d.ts +28 -1
- package/dist/domain/domain-context/undo-system.js +1 -1
- package/dist/domain/domain-runtime/spec/initialize.js +1 -1
- package/dist/domain/domain-runtime/spec/selectors.js +1 -1
- package/dist/domain/domain-runtime/spec/types.d.ts +2 -0
- package/dist/domain/extensions/attribute-switch.d.ts +1 -1
- package/dist/domain/extensions/attribute-switch.js +1 -1
- package/dist/domain/extensions/canvas-config.d.ts +1 -1
- package/dist/domain/extensions/client-side-image.d.ts +2 -2
- package/dist/domain/extensions/client-side-image.js +1 -1
- package/dist/domain/extensions/common/angle-indicator-schema.d.ts +2 -2
- package/dist/domain/extensions/common/dimension-indicator-schema.d.ts +2 -2
- package/dist/domain/extensions/editable-angle-indicator.d.ts +1 -1
- package/dist/domain/extensions/editable-distance-dimension-indicator.d.ts +1 -1
- package/dist/domain/extensions/editable-offset-indicator.d.ts +1 -1
- package/dist/domain/extensions/editable-offset-indicator.js +1 -1
- package/dist/domain/extensions/fit-selection-orthographic-camera-component.js +1 -1
- package/dist/domain/extensions/fit-selection-perspective-camera-component.js +1 -1
- package/dist/domain/extensions/horizontal-tabs.d.ts +2 -2
- package/dist/domain/extensions/list-selector-dimension-indicator.d.ts +1 -1
- package/dist/domain/extensions/navigation-steps.d.ts +2 -2
- package/dist/domain/extensions/offset-indicator.js +1 -1
- package/dist/domain/extensions/rotation-handle.d.ts +2 -2
- package/dist/domain/extensions/save-template-thumbnail.d.ts +2 -2
- package/dist/domain/extensions/save-template-thumbnail.js +1 -1
- package/dist/domain/extensions/scene-entity-animation.js +1 -1
- package/dist/domain/system-components/application-config.d.ts +2 -2
- package/dist/domain/system-components/child-entity-selection.js +1 -1
- package/dist/domain/system-components/collision-box-geometry.d.ts +4 -2
- package/dist/domain/system-components/collision-geometry.d.ts +4 -2
- package/dist/domain/system-components/collision-point-geometry.d.ts +4 -2
- package/dist/domain/system-components/common/material-override-schema.d.ts +2 -2
- package/dist/domain/system-components/common/recipes.d.ts +21 -3
- package/dist/domain/system-components/common/recipes.js +1 -1
- package/dist/domain/system-components/constraint.d.ts +10 -23
- package/dist/domain/system-components/drag-handle.d.ts +1 -1
- package/dist/domain/system-components/drag-handle.js +1 -1
- package/dist/domain/system-components/fit-entity-orthographic-camera-component.js +1 -1
- package/dist/domain/system-components/fit-entity-perspective-camera-component.js +1 -1
- package/dist/domain/system-components/fit-root-orthographic-camera-component.js +1 -1
- package/dist/domain/system-components/fit-root-perspective-camera-component.js +1 -1
- package/dist/domain/system-components/hotspot-drag-handle.d.ts +1 -1
- package/dist/domain/system-components/hotspot-drag-handle.js +1 -1
- package/dist/domain/system-components/material-swatch.js +1 -1
- package/dist/domain/system-components/scene-entity-material-override.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-object-material-override.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-object-text-decal.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-object-transimissive-material-override.d.ts +1 -1
- package/dist/domain/system-components/scene-entity-transimissive-material-override.d.ts +1 -1
- package/dist/domain/system-components/static-orthographic-camera-component.js +1 -1
- package/dist/domain/system-components/static-perspective-camera-component.js +1 -1
- package/dist/i18n/locales/cs/messages.js +1 -1
- package/dist/i18n/locales/da/messages.js +1 -1
- package/dist/i18n/locales/de/messages.js +1 -1
- package/dist/i18n/locales/de-AT/messages.js +1 -1
- package/dist/i18n/locales/en/messages.js +1 -1
- package/dist/i18n/locales/en-AU/messages.js +1 -1
- package/dist/i18n/locales/en-GB/messages.js +1 -1
- package/dist/i18n/locales/es/messages.js +1 -1
- package/dist/i18n/locales/fr/messages.js +1 -1
- package/dist/i18n/locales/hu/messages.js +1 -1
- package/dist/i18n/locales/it/messages.js +1 -1
- package/dist/i18n/locales/nl/messages.js +1 -1
- package/dist/i18n/locales/pl/messages.js +1 -1
- package/dist/i18n/locales/pt/messages.js +1 -1
- package/dist/i18n/locales/ro/messages.js +1 -1
- package/dist/i18n/locales/sk/messages.js +1 -1
- package/dist/i18n/locales/tr/messages.js +1 -1
- package/dist/legacy/domain-cli/utils/cache.d.ts +1 -1
- package/dist/legacy/domain-cli/utils/cache.js +1 -1
- package/dist/legacy/domain-spec/__generated/domain-schema.d.ts +81 -68
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/claude-md.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/cursor-rules.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.d.ts +1 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/agents/shared-sdk-content.js +7 -1
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-admin.js +18 -16
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-configurator.js +14 -12
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-admin.js +13 -11
- package/dist/legacy/phoenix-cli/project-gen/generators/file-templates/frontend-embedded-configurator.js +13 -11
- package/dist/phoenix/application-spec/application-spec-builder.js +1 -1
- package/dist/phoenix/application-spec/project-files.js +1 -1
- package/dist/phoenix/commands/check.js +1 -1
- package/dist/phoenix/commands/deploy.js +1 -1
- package/dist/phoenix/commands/dev.js +5 -5
- package/dist/phoenix/commands/fix.js +1 -1
- package/dist/phoenix/services/application-spec-project-watcher.d.ts +2 -0
- package/dist/phoenix/services/application-spec-project-watcher.js +3 -3
- package/dist/phoenix/services/source-archive.d.ts +1 -0
- package/dist/phoenix/services/source-archive.js +1 -1
- package/dist/phoenix/services/swc.js +1 -1
- package/dist/react-sdk/domain-context/common-hooks/use-configurator-messages.d.ts +30 -0
- package/dist/react-sdk/domain-context/common-hooks/use-configurator-messages.js +1 -0
- package/dist/react-sdk/domain-context/index.d.ts +2 -1
- package/dist/react-sdk/domain-context/index.js +1 -1
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.d.ts +5 -0
- package/dist/react-sdk/domain-context/system-hooks/navigation-hooks.js +1 -1
- package/dist/react-sdk/domain-controls/hooks/use-angle-dimension.d.ts +1 -1
- package/dist/ui-sdk/theme/types.d.ts +1 -1
- package/package.json +33 -29
- package/schema/domain-spec.json +1115 -209
- package/dist/application-spec/generate-application/code/templates/webhook-implementation.d.ts +0 -1
- package/dist/application-spec/generate-application/code/templates/webhook-implementation.js +0 -7
- /package/dist/application-spec/{core → enhanced-json}/eval-code-uses-self.d.ts +0 -0
- /package/dist/application-spec/{core → enhanced-json}/eval-code-uses-self.js +0 -0
- /package/dist/application-spec/{core → enhanced-json}/eval-to-constant.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Custom Layout
|
|
2
2
|
|
|
3
|
-
Make the configurator look like the brand's own product page. A furniture shop wants its table configurator to read like the rest of its site: a floating panel on the left with the product's name, the edge finishes as picture cards, the price in large type and one clear call to action, and the table in the space beside it. The project writes that page as one React component. Phoenix supplies the 3D scene, the product's state and a few hooks; every pixel around the scene is the project's own.
|
|
3
|
+
Make the configurator look like the brand's own product page. A furniture shop wants its table configurator to read like the rest of its site: a floating panel on the left with the product's name, the edge finishes as picture cards, the price in large type and one clear call to action, and the table in the space beside it. On a phone the panel becomes a sheet at the bottom, and a button on the table's edge offers the finishes right where they apply. The project writes that page as one React component. Phoenix supplies the 3D scene, the product's state and a few hooks; every pixel around the scene is the project's own.
|
|
4
4
|
|
|
5
5
|
- [Choose this approach](#choose-this-approach)
|
|
6
6
|
- [Register the layout](#register-the-layout)
|
|
@@ -8,7 +8,11 @@ Make the configurator look like the brand's own product page. A furniture shop w
|
|
|
8
8
|
- [Read and change the product](#read-and-change-the-product)
|
|
9
9
|
- [Draw the choices](#draw-the-choices)
|
|
10
10
|
- [Offer fullscreen](#offer-fullscreen)
|
|
11
|
+
- [Show messages](#show-messages)
|
|
12
|
+
- [Request a quote](#request-a-quote)
|
|
11
13
|
- [Serve read mode](#serve-read-mode)
|
|
14
|
+
- [Fit a phone](#fit-a-phone)
|
|
15
|
+
- [Put a control on the product](#put-a-control-on-the-product)
|
|
12
16
|
- [The spec the layout reads](#the-spec-the-layout-reads)
|
|
13
17
|
- [Try the example](#try-the-example)
|
|
14
18
|
- [Test cases](#test-cases)
|
|
@@ -30,25 +34,43 @@ Create `src/elements/ConfiguratorLayout.tsx` with a default export made by `phx.
|
|
|
30
34
|
|
|
31
35
|
```tsx
|
|
32
36
|
import { Box } from '@mui/material'
|
|
37
|
+
import { useState } from 'react'
|
|
33
38
|
|
|
34
39
|
import { LayoutSlots, useSceneSafeArea } from '@salsita-ai/sdk/configurator'
|
|
40
|
+
import { useActiveViewports } from '@salsita-ai/sdk/react'
|
|
35
41
|
|
|
36
42
|
import { phx } from '../../.phoenix/phx.js'
|
|
43
|
+
import { BottomSheet } from '../_shared/BottomSheet.js'
|
|
37
44
|
import { FullscreenToggle } from '../_shared/FullscreenToggle.js'
|
|
45
|
+
import { MessageToast } from '../_shared/MessageToast.js'
|
|
38
46
|
import { ProductPanel } from '../_shared/ProductPanel.js'
|
|
39
47
|
|
|
40
48
|
const GUTTER = 24
|
|
41
49
|
const PANEL_WIDTH = 380
|
|
50
|
+
const PHONE_GUTTER = 16
|
|
51
|
+
const TOUCH_TARGET = 44
|
|
42
52
|
|
|
43
53
|
const ConfiguratorLayout = () => {
|
|
44
54
|
const { containerRef, safeAreaRef } = useSceneSafeArea()
|
|
45
55
|
const isFullscreen = phx.frontend.useIsFullscreenActive()
|
|
56
|
+
// `null` until the container has been measured; the layout shows only the scene until then
|
|
57
|
+
const viewports = useActiveViewports()
|
|
58
|
+
const [isSheetOpen, setSheetOpen] = useState(false)
|
|
59
|
+
|
|
60
|
+
const isDesktop = viewports?.includes('desktop') ?? false
|
|
61
|
+
const gutter = isDesktop ? GUTTER : PHONE_GUTTER
|
|
46
62
|
|
|
47
63
|
return (
|
|
48
|
-
<Box
|
|
64
|
+
<Box
|
|
65
|
+
component="div"
|
|
66
|
+
ref={containerRef}
|
|
67
|
+
// `clip`, not `hidden`: what overflows, such as the sheet's fill below its edge, can never be scrolled into view,
|
|
68
|
+
// not even by the browser when the focus moves
|
|
69
|
+
sx={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', overflow: 'clip' }}
|
|
70
|
+
>
|
|
49
71
|
<LayoutSlots.SharedCanvas />
|
|
50
72
|
|
|
51
|
-
{!isFullscreen && (
|
|
73
|
+
{viewports !== null && isDesktop && !isFullscreen && (
|
|
52
74
|
<Box
|
|
53
75
|
component="aside"
|
|
54
76
|
sx={{
|
|
@@ -62,31 +84,60 @@ const ConfiguratorLayout = () => {
|
|
|
62
84
|
borderRadius: 5,
|
|
63
85
|
bgcolor: 'background.paper',
|
|
64
86
|
boxShadow: '0 12px 40px rgba(0, 0, 0, 0.12)',
|
|
65
|
-
|
|
87
|
+
// A very short container, such as a phone held sideways, scrolls the panel instead of clipping its footer
|
|
88
|
+
overflowX: 'hidden',
|
|
89
|
+
overflowY: 'auto',
|
|
90
|
+
overscrollBehavior: 'contain',
|
|
66
91
|
}}
|
|
67
92
|
>
|
|
68
93
|
<ProductPanel />
|
|
69
94
|
</Box>
|
|
70
95
|
)}
|
|
71
96
|
|
|
72
|
-
|
|
73
|
-
component="div"
|
|
74
|
-
ref={safeAreaRef}
|
|
75
|
-
sx={{
|
|
76
|
-
position: 'absolute',
|
|
77
|
-
insetBlock: 0,
|
|
78
|
-
insetInlineStart: isFullscreen ? 0 : PANEL_WIDTH + 2 * GUTTER,
|
|
79
|
-
insetInlineEnd: 0,
|
|
80
|
-
pointerEvents: 'none',
|
|
81
|
-
}}
|
|
82
|
-
>
|
|
97
|
+
{viewports !== null && (
|
|
83
98
|
<Box
|
|
84
99
|
component="div"
|
|
85
|
-
|
|
100
|
+
ref={safeAreaRef}
|
|
101
|
+
sx={{
|
|
102
|
+
// Desktop: right of the panel. Phone: above the sheet, whose height the column gives the rest.
|
|
103
|
+
...(isDesktop
|
|
104
|
+
? {
|
|
105
|
+
position: 'absolute',
|
|
106
|
+
insetBlock: 0,
|
|
107
|
+
insetInlineStart: isFullscreen ? 0 : PANEL_WIDTH + 2 * GUTTER,
|
|
108
|
+
insetInlineEnd: 0,
|
|
109
|
+
}
|
|
110
|
+
: { position: 'relative', flex: '1 1 0', minBlockSize: 0 }),
|
|
111
|
+
pointerEvents: 'none',
|
|
112
|
+
}}
|
|
86
113
|
>
|
|
87
|
-
<
|
|
114
|
+
<Box
|
|
115
|
+
component="div"
|
|
116
|
+
sx={{ position: 'absolute', insetBlockStart: gutter, insetInlineEnd: gutter, pointerEvents: 'auto' }}
|
|
117
|
+
>
|
|
118
|
+
<FullscreenToggle compact={!isDesktop} />
|
|
119
|
+
</Box>
|
|
120
|
+
<Box
|
|
121
|
+
component="div"
|
|
122
|
+
sx={{
|
|
123
|
+
position: 'absolute',
|
|
124
|
+
pointerEvents: 'auto',
|
|
125
|
+
// Desktop: bottom left. Phone: at the top beside the fullscreen button, clear of the sheet's handle.
|
|
126
|
+
...(isDesktop
|
|
127
|
+
? { insetBlockEnd: GUTTER, insetInlineStart: GUTTER }
|
|
128
|
+
: { insetBlockStart: gutter, insetInline: `${gutter}px ${2 * gutter + TOUCH_TARGET}px` }),
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
<MessageToast />
|
|
132
|
+
</Box>
|
|
88
133
|
</Box>
|
|
89
|
-
|
|
134
|
+
)}
|
|
135
|
+
|
|
136
|
+
{viewports !== null && !isDesktop && !isFullscreen && (
|
|
137
|
+
<BottomSheet open={isSheetOpen} onOpenChange={setSheetOpen} label="Product details">
|
|
138
|
+
<ProductPanel collapsed={!isSheetOpen} inSheet />
|
|
139
|
+
</BottomSheet>
|
|
140
|
+
)}
|
|
90
141
|
</Box>
|
|
91
142
|
)
|
|
92
143
|
}
|
|
@@ -101,9 +152,10 @@ The components it uses live in `src/_shared/`, which Phoenix does not import by
|
|
|
101
152
|
- **Position the root and cover the page.** `LayoutSlots.SharedCanvas` is absolutely positioned and fills its nearest positioned ancestor. The root here is `position: absolute; inset: 0`.
|
|
102
153
|
- **Mount the shared canvas.** The app loader stays on screen until the scene has loaded. A layout without `LayoutSlots.SharedCanvas` never gets past the loader unless the project sets `appLoader: legacy`.
|
|
103
154
|
- **Put the UI above the canvas.** The canvas is opaque. Content that is positioned and comes after it in the markup is painted above it; unpositioned content is painted under it and cannot be seen.
|
|
104
|
-
- **Tell the camera where the free area is.** `useSceneSafeArea()` returns two refs. `containerRef` goes on the element that covers the whole canvas, `safeAreaRef` on the region the product should stay visible in, here everything right of the panel. The camera then frames the product in that region. The hook measures again whenever either of the two elements resizes; for a change no resize reports, such as a `transform` on an ancestor settling at the end of an animation, it also returns `update` to call. Without the two refs the product is centred in the whole canvas and sits against the panel.
|
|
155
|
+
- **Tell the camera where the free area is.** `useSceneSafeArea()` returns two refs. `containerRef` goes on the element that covers the whole canvas, `safeAreaRef` on the region the product should stay visible in, here everything right of the panel, or above the sheet on a phone. The camera then frames the product in that region. The hook measures again whenever either of the two elements resizes; for a change no resize reports, such as a `transform` on an ancestor settling at the end of an animation, it also returns `update` to call. Without the two refs the product is centred in the whole canvas and sits against the panel.
|
|
105
156
|
- **Let the pointer through.** The safe-area element lies over the canvas, so it sets `pointerEvents: 'none'`; otherwise the scene cannot be orbited. The fullscreen button inside it switches pointer events back on.
|
|
106
|
-
- **Honour fullscreen.** Fullscreen is a flag in the product's state, not a browser feature. The layout reads it with `phx.frontend.useIsFullscreenActive()`, removes the panel and lets the safe area
|
|
157
|
+
- **Honour fullscreen.** Fullscreen is a flag in the product's state, not a browser feature. The layout reads it with `phx.frontend.useIsFullscreenActive()`, removes the panel or the sheet and lets the safe area cover the canvas, so the camera frames the product in the whole canvas.
|
|
158
|
+
- **Fit the width it is given.** The configurator can be embedded in a narrow column or opened on a phone. The layout reads the container's width class with `useActiveViewports()` and renders a desktop or a phone arrangement, see [Fit a phone](#fit-a-phone).
|
|
107
159
|
- **Serve read mode.** The same element renders a configuration shared for viewing, and the layout decides what a viewer sees.
|
|
108
160
|
|
|
109
161
|
## Read and change the product
|
|
@@ -113,13 +165,23 @@ The panel reads everything it shows from hooks and writes the customer's choice
|
|
|
113
165
|
```tsx
|
|
114
166
|
import { Box, Button, Typography } from '@mui/material'
|
|
115
167
|
|
|
116
|
-
import { detailComponent } from '@salsita-ai/sdk/domain'
|
|
117
|
-
import { useResolveLocalizable } from '@salsita-ai/sdk/react'
|
|
168
|
+
import { detailComponent, finalizeActionComponent } from '@salsita-ai/sdk/domain'
|
|
169
|
+
import { PhoenixHandlerBoundary, useResolveLocalizable } from '@salsita-ai/sdk/react'
|
|
118
170
|
|
|
119
171
|
import { phx } from '../../.phoenix/phx.js'
|
|
120
172
|
import { EdgeFinishCards } from './EdgeFinishCards.js'
|
|
173
|
+
import { ReviewActions } from './ReviewActions.js'
|
|
174
|
+
|
|
175
|
+
const BUTTON_SX = { minBlockSize: 48, borderRadius: 999, textTransform: 'none', fontWeight: 600 } as const
|
|
121
176
|
|
|
122
|
-
|
|
177
|
+
interface ProductPanelProps {
|
|
178
|
+
// Only the name, the price and the action, for a collapsed bottom sheet
|
|
179
|
+
readonly collapsed?: boolean
|
|
180
|
+
// In a bottom sheet the cards region keeps the top of the cards in view, and the sheet scrolls when that does not fit
|
|
181
|
+
readonly inSheet?: boolean
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export const ProductPanel = ({ collapsed = false, inSheet = false }: ProductPanelProps) => {
|
|
123
185
|
const resolve = useResolveLocalizable()
|
|
124
186
|
const detail = phx.frontend.useFirstRootComponent(detailComponent)
|
|
125
187
|
const price = phx.frontend.useRootEntityPrice()
|
|
@@ -129,9 +191,13 @@ export const ProductPanel = () => {
|
|
|
129
191
|
const navigationState = phx.frontend.useActiveNavigationState()
|
|
130
192
|
const pushNavigate = phx.frontend.usePushNavigate()
|
|
131
193
|
const popNavigate = phx.frontend.usePopNavigate()
|
|
194
|
+
const navigate = phx.frontend.useNavigate()
|
|
195
|
+
const finalizeActions = phx.frontend.useComponents({ componentTypes: [finalizeActionComponent] }) ?? []
|
|
132
196
|
|
|
133
197
|
const isReadMode = accessInfo.viewMode
|
|
134
|
-
const isReview = isReadMode || navigationState
|
|
198
|
+
const isReview = isReadMode || navigationState !== 'configure'
|
|
199
|
+
// The spec's primary finalize action, or its first one
|
|
200
|
+
const quoteAction = finalizeActions.find(action => action.state.variant === 'primary') ?? finalizeActions[0]
|
|
135
201
|
const chosenEdge = edgeFinish.options.find(option => option.value === edgeFinish.value)
|
|
136
202
|
|
|
137
203
|
return (
|
|
@@ -152,29 +218,44 @@ export const ProductPanel = () => {
|
|
|
152
218
|
<Typography variant="h5" component="h2" fontWeight={700}>
|
|
153
219
|
{resolve(detail?.state.title)}
|
|
154
220
|
</Typography>
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
<Box component="div" sx={{ display: 'grid', gap: 1.5, paddingInline: 3, paddingBlockEnd: 3, overflowY: 'auto' }}>
|
|
161
|
-
<Typography variant="subtitle2" component="h3">
|
|
162
|
-
Edge finish
|
|
163
|
-
</Typography>
|
|
164
|
-
{isReview ? (
|
|
165
|
-
<Box component="div" sx={{ padding: 2, borderRadius: 3, bgcolor: 'action.hover' }}>
|
|
166
|
-
<Typography variant="body2" fontWeight={600}>
|
|
167
|
-
{resolve(chosenEdge?.title)}
|
|
168
|
-
</Typography>
|
|
169
|
-
<Typography variant="caption" color="text.secondary">
|
|
170
|
-
{resolve(chosenEdge?.description)}
|
|
171
|
-
</Typography>
|
|
172
|
-
</Box>
|
|
173
|
-
) : (
|
|
174
|
-
<EdgeFinishCards selection={edgeFinish} />
|
|
221
|
+
{!collapsed && (
|
|
222
|
+
<Typography variant="body2" color="text.secondary">
|
|
223
|
+
{resolve(detail?.state.description)}
|
|
224
|
+
</Typography>
|
|
175
225
|
)}
|
|
176
226
|
</Box>
|
|
177
227
|
|
|
228
|
+
{!collapsed && (
|
|
229
|
+
<Box
|
|
230
|
+
component="div"
|
|
231
|
+
sx={{
|
|
232
|
+
display: 'grid',
|
|
233
|
+
gap: 1.5,
|
|
234
|
+
paddingInline: 3,
|
|
235
|
+
paddingBlockEnd: 3,
|
|
236
|
+
// In a short container the region shrinks and scrolls; a scroll past its end moves its container on
|
|
237
|
+
minBlockSize: inSheet ? 120 : 0,
|
|
238
|
+
overflowY: 'auto',
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
<Typography variant="subtitle2" component="h3">
|
|
242
|
+
Edge finish
|
|
243
|
+
</Typography>
|
|
244
|
+
{isReview ? (
|
|
245
|
+
<Box component="div" sx={{ padding: 2, borderRadius: 3, bgcolor: 'action.hover' }}>
|
|
246
|
+
<Typography variant="body2" fontWeight={600}>
|
|
247
|
+
{resolve(chosenEdge?.title)}
|
|
248
|
+
</Typography>
|
|
249
|
+
<Typography variant="caption" color="text.secondary">
|
|
250
|
+
{resolve(chosenEdge?.description)}
|
|
251
|
+
</Typography>
|
|
252
|
+
</Box>
|
|
253
|
+
) : (
|
|
254
|
+
<EdgeFinishCards selection={edgeFinish} />
|
|
255
|
+
)}
|
|
256
|
+
</Box>
|
|
257
|
+
)}
|
|
258
|
+
|
|
178
259
|
<Box component="footer" sx={{ display: 'grid', gap: 2, padding: 3, borderTop: 1, borderColor: 'divider' }}>
|
|
179
260
|
<Box component="div" sx={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between' }}>
|
|
180
261
|
<Typography variant="body2" color="text.secondary">
|
|
@@ -184,42 +265,68 @@ export const ProductPanel = () => {
|
|
|
184
265
|
{price}
|
|
185
266
|
</Typography>
|
|
186
267
|
</Box>
|
|
187
|
-
{
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
</Typography>
|
|
191
|
-
)}
|
|
192
|
-
{!isReadMode && (
|
|
193
|
-
<Button
|
|
194
|
-
size="large"
|
|
195
|
-
variant={isReview ? 'outlined' : 'contained'}
|
|
196
|
-
onClick={isReview ? popNavigate : () => pushNavigate('checkout')}
|
|
197
|
-
sx={{ minBlockSize: 48, borderRadius: 999, textTransform: 'none', fontWeight: 600 }}
|
|
198
|
-
>
|
|
199
|
-
{isReview ? 'Back to the configuration' : 'Review and request a quote'}
|
|
268
|
+
{!isReadMode && navigationState === 'configure' && (
|
|
269
|
+
<Button size="large" variant="contained" onClick={() => pushNavigate('checkout')} sx={BUTTON_SX}>
|
|
270
|
+
Review and request a quote
|
|
200
271
|
</Button>
|
|
201
272
|
)}
|
|
273
|
+
{!isReadMode && navigationState === 'checkout' && (
|
|
274
|
+
<>
|
|
275
|
+
<Typography variant="body2" color="text.secondary">
|
|
276
|
+
Your table is ready for a quote. A real shop collects the contact details here.
|
|
277
|
+
</Typography>
|
|
278
|
+
{quoteAction ? (
|
|
279
|
+
<PhoenixHandlerBoundary name={quoteAction.state.handler}>
|
|
280
|
+
<ReviewActions
|
|
281
|
+
handler={quoteAction.state.handler}
|
|
282
|
+
label={resolve(quoteAction.state.label)}
|
|
283
|
+
onBack={popNavigate}
|
|
284
|
+
/>
|
|
285
|
+
</PhoenixHandlerBoundary>
|
|
286
|
+
) : (
|
|
287
|
+
<Button size="large" variant="outlined" onClick={popNavigate} sx={BUTTON_SX}>
|
|
288
|
+
Back to the configuration
|
|
289
|
+
</Button>
|
|
290
|
+
)}
|
|
291
|
+
</>
|
|
292
|
+
)}
|
|
293
|
+
{!isReadMode && navigationState === 'requested' && (
|
|
294
|
+
<>
|
|
295
|
+
<Typography variant="body2" role="status">
|
|
296
|
+
Thank you. Your quote request is on its way, and the shop replies within two working days.
|
|
297
|
+
</Typography>
|
|
298
|
+
<Button size="large" variant="outlined" onClick={() => navigate('configure')} sx={BUTTON_SX}>
|
|
299
|
+
Back to the configuration
|
|
300
|
+
</Button>
|
|
301
|
+
</>
|
|
302
|
+
)}
|
|
202
303
|
</Box>
|
|
203
304
|
</>
|
|
204
305
|
)
|
|
205
306
|
}
|
|
206
307
|
```
|
|
207
308
|
|
|
208
|
-
| Hook | What the layout uses it for
|
|
209
|
-
| ---------------------------------------------------------------------------- |
|
|
210
|
-
| `phx.frontend.useFirstRootComponent(detailComponent)` | The `detail` component of the root entity: name, subtitle and description. `detailComponent` comes from `@salsita-ai/sdk/domain`; the hook returns `null` without one.
|
|
211
|
-
| `phx.frontend.useRootEntityId()` | The id of the table, which the control hooks take.
|
|
212
|
-
| `phx.frontend.useAttributeSelection(entityId, instanceName)` | The `attributeSelection` component named `edgeFinish`: the current `value` and the `options`, each with `title`, `description`, `value`, `disabled` and `onSelect`.
|
|
213
|
-
| `phx.frontend.useRootEntityPrice()` | The root entity's `price` component, formatted for the current locale and currency, or `null` without one.
|
|
214
|
-
| `phx.frontend.useAccessService()` | `accessInfo.viewMode` is `true` while a configuration shared for viewing is open, and also while the host sets the `readonly` property.
|
|
215
|
-
| `phx.frontend.useActiveNavigationState()` | The active navigation state; the panel shows its review step while it is `checkout`.
|
|
216
|
-
| `phx.frontend.usePushNavigate()` and `phx.frontend.usePopNavigate()` | Enter the review step and leave it again.
|
|
217
|
-
| `phx.frontend.
|
|
218
|
-
| `
|
|
309
|
+
| Hook | What the layout uses it for |
|
|
310
|
+
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
311
|
+
| `phx.frontend.useFirstRootComponent(detailComponent)` | The `detail` component of the root entity: name, subtitle and description. `detailComponent` comes from `@salsita-ai/sdk/domain`; the hook returns `null` without one. |
|
|
312
|
+
| `phx.frontend.useRootEntityId()` | The id of the table, which the control hooks take. |
|
|
313
|
+
| `phx.frontend.useAttributeSelection(entityId, instanceName)` | The `attributeSelection` component named `edgeFinish`: the current `value` and the `options`, each with `title`, `description`, `value`, `disabled` and `onSelect`. |
|
|
314
|
+
| `phx.frontend.useRootEntityPrice()` | The root entity's `price` component, formatted for the current locale and currency, or `null` without one. |
|
|
315
|
+
| `phx.frontend.useAccessService()` | `accessInfo.viewMode` is `true` while a configuration shared for viewing is open, and also while the host sets the `readonly` property. |
|
|
316
|
+
| `phx.frontend.useActiveNavigationState()` | The active navigation state; the panel shows its review step while it is `checkout`. |
|
|
317
|
+
| `phx.frontend.usePushNavigate()` and `phx.frontend.usePopNavigate()` | Enter the review step and leave it again. |
|
|
318
|
+
| `phx.frontend.useNavigate()` | Return from the confirmation to the configuration, forgetting the review step. |
|
|
319
|
+
| `phx.frontend.useComponents({ componentTypes: [finalizeActionComponent] })` | The spec's `finalizeAction` components; the panel offers the primary one in its review step. `finalizeActionComponent` comes from `@salsita-ai/sdk/domain`. |
|
|
320
|
+
| `phx.frontend.useFinalizeAction(handler)` | Run the finalize action's handler, with its pending state, its error and whether finalizing is possible; see [Request a quote](#request-a-quote). |
|
|
321
|
+
| `phx.frontend.useIsFullscreenActive()` and `phx.frontend.useSetFullscreen()` | Read the fullscreen flag, and set it from the layout's own button. |
|
|
322
|
+
| `useActiveViewports()` from `@salsita-ai/sdk/react` | The width classes of the configurator's container, or `null` before it is measured; the layout renders its phone arrangement unless it includes `desktop`, see [Fit a phone](#fit-a-phone). |
|
|
323
|
+
| `phx.frontend.useConfiguratorMessages(onMessage)` | Receive violations, side-effect hints and errors one by one, with their text resolved, for the layout's own toast; see [Show messages](#show-messages). |
|
|
324
|
+
| `useResolveLocalizable()` from `@salsita-ai/sdk/react` | Turns the localizable texts of the spec into strings in the current language. [Localization](?path=/docs/phoenix-localization--docs) describes it and `LocalizableMessage`. |
|
|
325
|
+
| `PhoenixHandlerBoundary` from `@salsita-ai/sdk/react` | Wraps the review step's buttons, so an edited handler takes effect without a reload. |
|
|
219
326
|
|
|
220
327
|
Calling an option's `onSelect` is the whole write: it changes `edgeFinish` on the table, the scene morphs the edge and the price expression recalculates. The option fields are named for display: the spec's `label` arrives as `title`, its `img` as `imageSrc`.
|
|
221
328
|
|
|
222
|
-
The review step is the layout's own: the button pushes the `checkout` navigation state, and the panel shows a summary instead of the cards. A real shop collects the contact details
|
|
329
|
+
The review step is the layout's own: the button pushes the `checkout` navigation state, and the panel shows a summary instead of the cards. There **Request a quote** runs the spec's finalize action, whose handler moves the panel on to the `requested` state and its confirmation; see [Request a quote](#request-a-quote). A real shop collects the contact details in the review step before it sends the request.
|
|
223
330
|
|
|
224
331
|
## Draw the choices
|
|
225
332
|
|
|
@@ -365,57 +472,558 @@ The drawings are keyed by the option values of the spec. A spec can carry a pict
|
|
|
365
472
|
Fullscreen is a flag in the configurator's state, not the browser's fullscreen mode. `phx.frontend.useIsFullscreenActive()` reads it and `phx.frontend.useSetFullscreen()` returns a function that sets it: `setFullscreen(true)` turns it on, `setFullscreen(false)` off. The layout's own button flips it, and the layout decides what to hide.
|
|
366
473
|
|
|
367
474
|
```tsx
|
|
368
|
-
import { Button } from '@mui/material'
|
|
475
|
+
import { Button, Tooltip } from '@mui/material'
|
|
369
476
|
|
|
370
477
|
import { phx } from '../../.phoenix/phx.js'
|
|
371
478
|
|
|
372
479
|
const ENTER_ICON = 'M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5'
|
|
373
480
|
const EXIT_ICON = 'M9 4v5H4M15 4v5h5M15 20v-5h5M9 20v-5H4'
|
|
374
481
|
|
|
375
|
-
|
|
482
|
+
interface FullscreenToggleProps {
|
|
483
|
+
// Only the icon, with the label as its accessible name and tooltip, where a label would cover the product
|
|
484
|
+
readonly compact?: boolean
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export const FullscreenToggle = ({ compact = false }: FullscreenToggleProps) => {
|
|
376
488
|
const isFullscreen = phx.frontend.useIsFullscreenActive()
|
|
377
489
|
const setFullscreen = phx.frontend.useSetFullscreen()
|
|
490
|
+
const label = isFullscreen ? 'Exit fullscreen' : 'Fullscreen'
|
|
491
|
+
const icon = (
|
|
492
|
+
<svg viewBox="0 0 24 24" width={20} height={20} fill="none" stroke="currentColor" strokeWidth={2}>
|
|
493
|
+
<path d={isFullscreen ? EXIT_ICON : ENTER_ICON} />
|
|
494
|
+
</svg>
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
return (
|
|
498
|
+
<Tooltip title={compact ? label : ''}>
|
|
499
|
+
<Button
|
|
500
|
+
onClick={() => setFullscreen(!isFullscreen)}
|
|
501
|
+
aria-label={compact ? label : undefined}
|
|
502
|
+
startIcon={compact ? undefined : icon}
|
|
503
|
+
sx={{
|
|
504
|
+
minBlockSize: 44,
|
|
505
|
+
minInlineSize: 44,
|
|
506
|
+
paddingInline: compact ? 0 : 2.5,
|
|
507
|
+
borderRadius: 999,
|
|
508
|
+
bgcolor: 'background.paper',
|
|
509
|
+
color: 'text.primary',
|
|
510
|
+
boxShadow: '0 4px 16px rgba(0, 0, 0, 0.12)',
|
|
511
|
+
textTransform: 'none',
|
|
512
|
+
fontWeight: 600,
|
|
513
|
+
'&:hover': { bgcolor: 'background.paper', boxShadow: '0 6px 20px rgba(0, 0, 0, 0.18)' },
|
|
514
|
+
}}
|
|
515
|
+
>
|
|
516
|
+
{compact ? icon : label}
|
|
517
|
+
</Button>
|
|
518
|
+
</Tooltip>
|
|
519
|
+
)
|
|
520
|
+
}
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
The button stays in the free area in both states, so the way back is always where the user left it. [Interaction Modes](?path=/docs/ux-guidelines-interaction-modes--docs#full-screen-preview) describes what fullscreen hides.
|
|
524
|
+
|
|
525
|
+
## Show messages
|
|
526
|
+
|
|
527
|
+
When a change is rejected because it breaks an invariant, when a committed change carries a hint, or when an error is thrown while a change is validated, the configurator has a message for the customer. `phx.frontend.useConfiguratorMessages(onMessage)` calls `onMessage` once for each, with the text already in the customer's language, and the layout shows it its own way. Here a toast shows a message for six seconds, colored by its severity, at the bottom of the free area on a desktop and at its top on a phone:
|
|
528
|
+
|
|
529
|
+
```tsx
|
|
530
|
+
import { Alert } from '@mui/material'
|
|
531
|
+
import { useEffect, useState } from 'react'
|
|
532
|
+
|
|
533
|
+
import type { ConfiguratorMessage } from '@salsita-ai/sdk/react'
|
|
534
|
+
|
|
535
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
536
|
+
|
|
537
|
+
const VIOLATION_SEVERITY = { fatal: 'error', fixable: 'error', warning: 'warning', notice: 'info' } as const
|
|
538
|
+
const RANK = { info: 0, warning: 1, error: 2 } as const
|
|
539
|
+
const VISIBLE_MS = 6000
|
|
540
|
+
|
|
541
|
+
const severityOf = (message: ConfiguratorMessage) => {
|
|
542
|
+
if (message.kind === 'violation') {
|
|
543
|
+
return VIOLATION_SEVERITY[message.violation.severity]
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
return message.kind === 'error' ? 'error' : 'info'
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export const MessageToast = () => {
|
|
550
|
+
const [message, setMessage] = useState<ConfiguratorMessage | null>(null)
|
|
551
|
+
|
|
552
|
+
// A rejected change also reports the notices already present; keep the worst message while it is shown
|
|
553
|
+
phx.frontend.useConfiguratorMessages(next => {
|
|
554
|
+
setMessage(shown => (shown !== null && RANK[severityOf(next)] < RANK[severityOf(shown)] ? shown : next))
|
|
555
|
+
})
|
|
556
|
+
|
|
557
|
+
useEffect(() => {
|
|
558
|
+
if (message === null) {
|
|
559
|
+
return
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
const timeout = setTimeout(() => setMessage(null), VISIBLE_MS)
|
|
563
|
+
|
|
564
|
+
return () => clearTimeout(timeout)
|
|
565
|
+
}, [message])
|
|
566
|
+
|
|
567
|
+
if (message === null) {
|
|
568
|
+
return null
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return (
|
|
572
|
+
<Alert
|
|
573
|
+
severity={severityOf(message)}
|
|
574
|
+
onClose={() => setMessage(null)}
|
|
575
|
+
sx={{ maxInlineSize: 420, borderRadius: 3, boxShadow: '0 12px 40px rgba(0, 0, 0, 0.12)' }}
|
|
576
|
+
>
|
|
577
|
+
{message.text}
|
|
578
|
+
</Alert>
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
The hook takes a new function on every render without missing a message, so passing the state setter, or an inline function, is fine. `message.kind` is `'violation'`, `'sideEffect'` or `'error'`; a violation also carries `entityId` and the `violation` itself, with its `severity`. A rejected change brings one message for each violation of the rejected state, including notices and warnings that were already present, so the toast keeps the most severe message while it is shown instead of letting a later notice replace the reason for the rejection. The layout mounts the toast in the safe-area element, which sets `pointerEvents: 'none'`, so the toast's wrapper switches pointer events back on for the close button.
|
|
584
|
+
|
|
585
|
+
To give the toast something to show, the spec registers one transformer. Choosing **Tree trunk** keeps the change and adds a hint to it, which arrives as a `sideEffect` message:
|
|
586
|
+
|
|
587
|
+
```ts
|
|
588
|
+
import { msg } from '@lingui/core/macro'
|
|
589
|
+
|
|
590
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
591
|
+
|
|
592
|
+
// A tree-trunk edge is cut by hand; choosing it carries a hint, which reaches the layout as a side-effect message
|
|
593
|
+
export default phx.frontend.transformerBuilder.when
|
|
594
|
+
.entity(['Table'])
|
|
595
|
+
.modified({ atFields: ['edgeFinish'] })
|
|
596
|
+
.then.overrideMatchingUpdate(({ update }) => {
|
|
597
|
+
if (update.stateDelta.edgeFinish !== 'TreeTrunk') {
|
|
598
|
+
return [update]
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
return [{ ...update, hint: msg`Tree trunk edges are cut by hand, so delivery takes three weeks longer.` }]
|
|
602
|
+
})
|
|
603
|
+
.build('tree-trunk-delivery')
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
[Configurator Interface → Loaded Configuration UI](?path=/docs/phoenix-configurator-interface--docs#loaded-configuration-ui) lists the messages the hook does not deliver: a failure to save, errors of the built-in finalize and other actions, and preset errors stay snackbars.
|
|
607
|
+
|
|
608
|
+
## Request a quote
|
|
609
|
+
|
|
610
|
+
The spec declares what finalizing means for this product as a `finalizeAction` component, and the project registers the handler it names:
|
|
611
|
+
|
|
612
|
+
```yaml
|
|
613
|
+
components:
|
|
614
|
+
Table:
|
|
615
|
+
finalizeAction:
|
|
616
|
+
quote:
|
|
617
|
+
variant: primary
|
|
618
|
+
label: Request a quote
|
|
619
|
+
title: Send the configuration to the shop for a quote
|
|
620
|
+
icon: PaperPlaneTilt
|
|
621
|
+
handler: requestQuote
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
```ts
|
|
625
|
+
import { useCallback } from 'react'
|
|
626
|
+
|
|
627
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
628
|
+
|
|
629
|
+
// Stands in for the shop's quote service: the request takes a moment, then the panel shows the confirmation
|
|
630
|
+
export default phx.frontend.createPhoenixHandler('requestQuote', () => {
|
|
631
|
+
const navigate = phx.frontend.useNavigate()
|
|
632
|
+
|
|
633
|
+
return {
|
|
634
|
+
handler: useCallback(async () => {
|
|
635
|
+
await new Promise(resolve => setTimeout(resolve, 1500))
|
|
636
|
+
navigate('requested')
|
|
637
|
+
}, [navigate]),
|
|
638
|
+
}
|
|
639
|
+
})
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
The handler stands in for the shop's quote service: it waits a moment, as a request would, and then enters the `requested` navigation state, in which the panel thanks the customer. A handler is a hook factory, so it can use any hook, here `phx.frontend.useNavigate()`.
|
|
643
|
+
|
|
644
|
+
The panel lists the finalize actions with `phx.frontend.useComponents({ componentTypes: [finalizeActionComponent] })` and offers the primary one, or the first when none is primary, in its review step. It renders the review step's buttons in a component of their own inside `<PhoenixHandlerBoundary name={handler}>`, because `phx.frontend.useFinalizeAction(handler)` runs the project's handler factory: it is called once per component, never in a loop, and the boundary remounts the buttons when the handler is edited. **Back to the configuration** lives in the same component, so it can be disabled while the request is pending.
|
|
645
|
+
|
|
646
|
+
```tsx
|
|
647
|
+
import { Alert, Box, Button, CircularProgress, Typography } from '@mui/material'
|
|
648
|
+
|
|
649
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
650
|
+
|
|
651
|
+
const BUTTON_SX = { minBlockSize: 48, borderRadius: 999, textTransform: 'none', fontWeight: 600 } as const
|
|
652
|
+
|
|
653
|
+
interface ReviewActionsProps {
|
|
654
|
+
readonly handler: string
|
|
655
|
+
readonly label: string
|
|
656
|
+
readonly onBack: () => void
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// The review step's buttons: one finalize action and the way back. `useFinalizeAction` runs the action's handler,
|
|
660
|
+
// so this component calls it exactly once and is rendered inside a `PhoenixHandlerBoundary` for that handler.
|
|
661
|
+
// Back is disabled while the request is pending, so the customer cannot change the configuration while it is sent.
|
|
662
|
+
// The pending state belongs to this component: when the panel unmounts, as in fullscreen, the request goes on and
|
|
663
|
+
// the remounted buttons are enabled again.
|
|
664
|
+
export const ReviewActions = ({ handler, label, onBack }: ReviewActionsProps) => {
|
|
665
|
+
const { run, isPending, error, disabled, hints } = phx.frontend.useFinalizeAction(handler)
|
|
666
|
+
|
|
667
|
+
return (
|
|
668
|
+
<Box component="div" sx={{ display: 'grid', gap: 2 }}>
|
|
669
|
+
<Box component="div" sx={{ display: 'grid', gap: 1 }}>
|
|
670
|
+
<Button
|
|
671
|
+
size="large"
|
|
672
|
+
variant="contained"
|
|
673
|
+
disabled={disabled || isPending}
|
|
674
|
+
onClick={run}
|
|
675
|
+
startIcon={isPending ? <CircularProgress size={18} color="inherit" /> : undefined}
|
|
676
|
+
sx={BUTTON_SX}
|
|
677
|
+
>
|
|
678
|
+
{isPending ? 'Sending the request…' : label}
|
|
679
|
+
</Button>
|
|
680
|
+
{disabled && hints && (
|
|
681
|
+
<Typography variant="caption" color="text.secondary">
|
|
682
|
+
{hints}
|
|
683
|
+
</Typography>
|
|
684
|
+
)}
|
|
685
|
+
{error && <Alert severity="error">The request could not be sent: {error.message}</Alert>}
|
|
686
|
+
</Box>
|
|
687
|
+
<Button size="large" variant="outlined" disabled={isPending} onClick={onBack} sx={BUTTON_SX}>
|
|
688
|
+
Back to the configuration
|
|
689
|
+
</Button>
|
|
690
|
+
</Box>
|
|
691
|
+
)
|
|
692
|
+
}
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
- `run()` records the finalize-button click for analytics and runs the handler; it does nothing while `disabled` or `isPending`.
|
|
696
|
+
- While `isPending` the button shows a spinner and cannot be clicked again, and **Back to the configuration** is disabled, so the customer cannot change the configuration while it is sent. `isPending` and `error` belong to the mounted component: entering fullscreen unmounts the panel, the request goes on, and the panel shown after fullscreen starts with both buttons enabled. A layout that must rule that out keeps the review step mounted, or hides its fullscreen button while a request runs.
|
|
697
|
+
- `error` is what the handler rejected with. The layout shows it under the button; no snackbar is raised. It is cleared when the customer tries again.
|
|
698
|
+
- `disabled` and `hints` come from the configuration's violations: while a `warning` or worse holds, or the configuration failed to save, finalizing is not possible and `hints` says why.
|
|
699
|
+
|
|
700
|
+
The review step stays: a quote request is a commitment, so the customer sees the summary first, and a real shop collects the contact details there. A product that finalizes without a review offers the button in place of **Review and request a quote**. [Configurator Interface → Hooks for a Project Layout](?path=/docs/phoenix-configurator-interface--docs#hooks-for-a-project-layout) describes the hook, and [Finalization](?path=/docs/phoenix-finalization--docs) what a real flow does on the server.
|
|
701
|
+
|
|
702
|
+
## Serve read mode
|
|
703
|
+
|
|
704
|
+
While `accessInfo.viewMode` is `true` the panel marks the view as view only, replaces the cards with the chosen finish and shows the price without an action; the finalize action is not offered, since `useFinalizeAction` does not check read mode itself. The hooks do not hide or disable anything in read mode: what a viewer can change is decided by what the layout renders. Rotating and zooming the scene, and fullscreen, stay available, as [Interaction Modes](?path=/docs/ux-guidelines-interaction-modes--docs#view-only-mode) recommends. The button on the table's edge is hidden for viewers by the spec, see [Put a control on the product](#put-a-control-on-the-product).
|
|
705
|
+
|
|
706
|
+
## Fit a phone
|
|
707
|
+
|
|
708
|
+
A panel 380 pixels wide beside the scene leaves nothing of the table on a phone. Below a desktop width the layout puts the panel into a sheet at the bottom and lets the camera frame the table in the area above it. The layout above shows both arrangements.
|
|
709
|
+
|
|
710
|
+
**The switch.** `useActiveViewports()` from `@salsita-ai/sdk/react` returns the width classes the configurator's container satisfies. The container decides, not the window, so a configurator embedded in a narrow column of a wide page gets the phone arrangement too. The built-in layout switches on `desktop` as well.
|
|
711
|
+
|
|
712
|
+
| Value | When it is active |
|
|
713
|
+
| ----------- | ---------------------------------------------------------------------------------- |
|
|
714
|
+
| `phone` | The container is narrower than 480 pixels. |
|
|
715
|
+
| `mobile` | The container is at most 768 pixels wide. |
|
|
716
|
+
| `tablet` | The container is wider than 480 and narrower than 1024 pixels. |
|
|
717
|
+
| `desktop` | The container is wider than 768 pixels; `mobile` and `desktop` exclude each other. |
|
|
718
|
+
| `landscape` | The browser window, not the container, is wider than it is high. |
|
|
719
|
+
| `portrait` | The browser window, not the container, is higher than it is wide. |
|
|
720
|
+
|
|
721
|
+
The hook returns `null` until the container has been measured, and the layout renders only the scene until then, so a phone never shows the desktop panel for a frame.
|
|
722
|
+
|
|
723
|
+
**The sheet.** On a phone the layout is a column: the safe-area element takes the height the sheet leaves, and the sheet sits below it. The sheet has two positions. Collapsed, it shows the name, the price and the action; open, it shows the description and the cards too. The `collapsed` prop of the panel hides the description and the cards, and nothing else, and `inSheet` keeps the top of the cards in view. The sheet scrolls what does not fit, so the price, the review step, **Request a quote** and the thank-you message are reachable in both positions.
|
|
724
|
+
|
|
725
|
+
```tsx
|
|
726
|
+
import { Box, ButtonBase } from '@mui/material'
|
|
727
|
+
import { type MouseEvent, type PointerEvent, type ReactNode, useRef } from 'react'
|
|
728
|
+
|
|
729
|
+
// A drag shorter than this is a tap, and the handle's click toggles the sheet
|
|
730
|
+
const TAP_DISTANCE = 6
|
|
731
|
+
// A drag that ends this far from where it started snaps to the other position
|
|
732
|
+
const SNAP_DISTANCE = 48
|
|
733
|
+
// A drag faster than this, in pixels per millisecond, snaps in its direction even when it is short
|
|
734
|
+
const SNAP_VELOCITY = 0.5
|
|
735
|
+
// How far the sheet follows the finger towards the position it is already in
|
|
736
|
+
const OVERDRAG = 0.25
|
|
737
|
+
|
|
738
|
+
interface BottomSheetProps {
|
|
739
|
+
readonly open: boolean
|
|
740
|
+
readonly onOpenChange: (open: boolean) => void
|
|
741
|
+
readonly label: string
|
|
742
|
+
readonly children: ReactNode
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
interface Drag {
|
|
746
|
+
readonly startY: number
|
|
747
|
+
readonly startTime: number
|
|
748
|
+
delta: number
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// A persistent sheet at the bottom of the layout with two positions, open and collapsed. It is not a modal: the scene
|
|
752
|
+
// above it stays interactive. Its height comes from its content, so the layout's safe area ends where the sheet
|
|
753
|
+
// starts and changes only when the sheet snaps. While the handle is dragged the sheet follows the finger with a
|
|
754
|
+
// transform, which the safe area does not see, so the camera refits once per snap and not on every move.
|
|
755
|
+
export const BottomSheet = ({ open, onOpenChange, label, children }: BottomSheetProps) => {
|
|
756
|
+
const sheetRef = useRef<HTMLElement>(null)
|
|
757
|
+
const dragRef = useRef<Drag | null>(null)
|
|
758
|
+
const draggedRef = useRef(false)
|
|
759
|
+
|
|
760
|
+
const moveSheet = (offset: number, animate: boolean) => {
|
|
761
|
+
if (sheetRef.current) {
|
|
762
|
+
sheetRef.current.style.transition = animate ? 'transform 200ms ease-out' : 'none'
|
|
763
|
+
sheetRef.current.style.transform = offset === 0 ? '' : `translateY(${offset}px)`
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const handlePointerDown = (event: PointerEvent<HTMLButtonElement>) => {
|
|
768
|
+
event.currentTarget.setPointerCapture(event.pointerId)
|
|
769
|
+
dragRef.current = { startY: event.clientY, startTime: event.timeStamp, delta: 0 }
|
|
770
|
+
draggedRef.current = false
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
const handlePointerMove = (event: PointerEvent<HTMLButtonElement>) => {
|
|
774
|
+
const drag = dragRef.current
|
|
775
|
+
|
|
776
|
+
if (drag === null) {
|
|
777
|
+
return
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
drag.delta = event.clientY - drag.startY
|
|
781
|
+
// Down closes an open sheet and up opens a collapsed one; the other direction only gives a little
|
|
782
|
+
const towardsOther = open ? drag.delta > 0 : drag.delta < 0
|
|
783
|
+
moveSheet(towardsOther ? drag.delta : drag.delta * OVERDRAG, false)
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const handlePointerEnd = (event: PointerEvent<HTMLButtonElement>) => {
|
|
787
|
+
const drag = dragRef.current
|
|
788
|
+
dragRef.current = null
|
|
789
|
+
|
|
790
|
+
if (drag === null) {
|
|
791
|
+
return
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
moveSheet(0, true)
|
|
795
|
+
|
|
796
|
+
if (Math.abs(drag.delta) < TAP_DISTANCE) {
|
|
797
|
+
return
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
draggedRef.current = true
|
|
801
|
+
const velocity = drag.delta / Math.max(event.timeStamp - drag.startTime, 1)
|
|
802
|
+
const flicked = Math.abs(drag.delta) >= SNAP_DISTANCE || Math.abs(velocity) >= SNAP_VELOCITY
|
|
803
|
+
|
|
804
|
+
if (flicked && (open ? drag.delta > 0 : drag.delta < 0)) {
|
|
805
|
+
onOpenChange(!open)
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// A tap, Enter or Space toggles the sheet. The pointer click that ends a drag has already been handled; a keyboard
|
|
810
|
+
// click (`detail` 0) always toggles, also after a touch drag that was followed by no click.
|
|
811
|
+
const handleClick = (event: MouseEvent<HTMLButtonElement>) => {
|
|
812
|
+
const dragged = draggedRef.current
|
|
813
|
+
draggedRef.current = false
|
|
814
|
+
|
|
815
|
+
if (dragged && event.detail !== 0) {
|
|
816
|
+
return
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
onOpenChange(!open)
|
|
820
|
+
}
|
|
378
821
|
|
|
379
822
|
return (
|
|
380
|
-
<
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
<path d={isFullscreen ? EXIT_ICON : ENTER_ICON} />
|
|
385
|
-
</svg>
|
|
386
|
-
}
|
|
823
|
+
<Box
|
|
824
|
+
component="section"
|
|
825
|
+
ref={sheetRef}
|
|
826
|
+
aria-label={label}
|
|
387
827
|
sx={{
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
828
|
+
position: 'relative',
|
|
829
|
+
flexShrink: 0,
|
|
830
|
+
display: 'flex',
|
|
831
|
+
flexDirection: 'column',
|
|
832
|
+
maxBlockSize: '55%',
|
|
833
|
+
paddingBlockEnd: 'env(safe-area-inset-bottom)',
|
|
834
|
+
borderStartStartRadius: 20,
|
|
835
|
+
borderStartEndRadius: 20,
|
|
391
836
|
bgcolor: 'background.paper',
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
837
|
+
boxShadow: '0 -8px 32px rgba(0, 0, 0, 0.12)',
|
|
838
|
+
// Fills the gap below the sheet while it is dragged up
|
|
839
|
+
'&::after': {
|
|
840
|
+
content: '""',
|
|
841
|
+
position: 'absolute',
|
|
842
|
+
insetInline: 0,
|
|
843
|
+
insetBlockStart: '100%',
|
|
844
|
+
blockSize: '100vh',
|
|
845
|
+
bgcolor: 'background.paper',
|
|
846
|
+
},
|
|
397
847
|
}}
|
|
398
848
|
>
|
|
399
|
-
|
|
400
|
-
|
|
849
|
+
<ButtonBase
|
|
850
|
+
aria-expanded={open}
|
|
851
|
+
disableRipple
|
|
852
|
+
aria-label={open ? `Collapse ${label.toLowerCase()}` : `Expand ${label.toLowerCase()}`}
|
|
853
|
+
onClick={handleClick}
|
|
854
|
+
onPointerDown={handlePointerDown}
|
|
855
|
+
onPointerMove={handlePointerMove}
|
|
856
|
+
onPointerUp={handlePointerEnd}
|
|
857
|
+
onPointerCancel={handlePointerEnd}
|
|
858
|
+
sx={{
|
|
859
|
+
flexShrink: 0,
|
|
860
|
+
blockSize: 36,
|
|
861
|
+
touchAction: 'none',
|
|
862
|
+
'&.Mui-focusVisible': { outline: 2, outlineColor: 'primary.main', outlineOffset: -4, borderRadius: 3 },
|
|
863
|
+
}}
|
|
864
|
+
>
|
|
865
|
+
<Box component="span" sx={{ inlineSize: 40, blockSize: 4, borderRadius: 2, bgcolor: 'text.disabled' }} />
|
|
866
|
+
</ButtonBase>
|
|
867
|
+
{/* A column, so the panel's cards region shrinks first and the price and action stay in view; below the cards
|
|
868
|
+
region's minimum height the content scrolls as a whole, as the review step does on a short phone */}
|
|
869
|
+
<Box
|
|
870
|
+
component="div"
|
|
871
|
+
sx={{
|
|
872
|
+
display: 'flex',
|
|
873
|
+
flexDirection: 'column',
|
|
874
|
+
flex: '1 1 auto',
|
|
875
|
+
minBlockSize: 0,
|
|
876
|
+
overflowY: 'auto',
|
|
877
|
+
overscrollBehavior: 'contain',
|
|
878
|
+
}}
|
|
879
|
+
>
|
|
880
|
+
{children}
|
|
881
|
+
</Box>
|
|
882
|
+
</Box>
|
|
401
883
|
)
|
|
402
884
|
}
|
|
403
885
|
```
|
|
404
886
|
|
|
405
|
-
The button
|
|
887
|
+
- The handle is a real button with `aria-expanded`. A tap, Enter or Space toggles the sheet, and dragging it up or down snaps the sheet to the other position when the drag is long or fast enough. `touchAction: 'none'` is set on the handle only, so the cards still scroll by touch.
|
|
888
|
+
- The sheet's height comes from its content and is at most 55% of the configurator; when the content does not fit, the cards region shrinks until only the top of the cards shows and scrolls, and below that the sheet's content scrolls as a whole. On a phone with room for the header, the top of the cards and the footer, the price and the action stay in view with the sheet open; on a shorter one the customer scrolls the sheet to them, and the review step's buttons are reached the same way in both positions. A scroll on the cards that reaches their end moves the sheet on. Because the safe-area element is its neighbour in the column, the free area ends where the sheet starts without anything being measured by the layout.
|
|
889
|
+
- While the handle is dragged the sheet follows the finger with a `transform`. `useSceneSafeArea()` does not see a transform, so the free area changes once, when the sheet snaps, and the camera refits once. A safe area that followed the finger would refit the camera on every move and reset an orbit the customer made.
|
|
890
|
+
- The sheet is not a modal: no backdrop covers the scene, so the table can be orbited with one finger and zoomed with two while the sheet is open. MUI's temporary `Drawer` and `SwipeableDrawer` are modals and would block the scene; their persistent and permanent variants have no backdrop, but no drag handle with two positions either.
|
|
406
891
|
|
|
407
|
-
|
|
892
|
+
**What else moves.** The toast sits at the top of the free area, so it does not cover the sheet's handle, and the fullscreen button shows only its icon, with its label as tooltip and accessible name, so the toast has room beside it. Fullscreen removes the sheet as it removes the panel on a desktop. The sheet keeps its position while fullscreen is on.
|
|
893
|
+
|
|
894
|
+
**A camera for the phone.** The desktop camera is close enough to fill a wide free area, and on a narrow one it cuts off the ends of the table. So each camera has a filter on the viewport: the desktop camera `main` applies while `desktop` is active, and a second camera, `phone`, with a larger distance frames the whole table while `mobile` is. The filters exclude each other once the container is measured. Before that, for example when an image of the configuration is rendered, no viewport is known and a viewport filter matches, so both cameras apply and the higher priority of `main` decides:
|
|
895
|
+
|
|
896
|
+
```yaml
|
|
897
|
+
components:
|
|
898
|
+
Table:
|
|
899
|
+
fitRootPerspectiveCamera:
|
|
900
|
+
main:
|
|
901
|
+
priority: 2
|
|
902
|
+
fov: 35
|
|
903
|
+
near: 100
|
|
904
|
+
far: 10000
|
|
905
|
+
minDistance: 1000
|
|
906
|
+
maxDistance: 9000
|
|
907
|
+
distance: 5000
|
|
908
|
+
azimuthAngle: 1.5
|
|
909
|
+
polarAngle: 1.1
|
|
910
|
+
fitMeshChanges: true
|
|
911
|
+
$filter:
|
|
912
|
+
viewports: [desktop]
|
|
913
|
+
phone:
|
|
914
|
+
priority: 1
|
|
915
|
+
fov: 35
|
|
916
|
+
near: 100
|
|
917
|
+
far: 10000
|
|
918
|
+
minDistance: 1000
|
|
919
|
+
maxDistance: 12000
|
|
920
|
+
distance: 8000
|
|
921
|
+
azimuthAngle: 1.5
|
|
922
|
+
polarAngle: 1.1
|
|
923
|
+
fitMeshChanges: true
|
|
924
|
+
$filter:
|
|
925
|
+
viewports: [mobile]
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
## Put a control on the product
|
|
408
929
|
|
|
409
|
-
|
|
930
|
+
The edge finish is a detail of the tabletop, so the layout also offers it on the table itself: a round button on the middle of the long edge opens the four finishes next to the edge. On a phone it is a way to change the edge without opening the sheet.
|
|
931
|
+
|
|
932
|
+
A control in the scene is a spec component that names an element of the project. `htmlHotspot` places an HTML element at an offset from the entity's origin, in the model's units, here millimetres: half the table's depth towards the camera and just below the top's surface. Its `$filter` shows it only to the owner and only while the `configure` navigation state is active, so a viewer and the review step do not get it, and the element does not check either itself:
|
|
933
|
+
|
|
934
|
+
```yaml
|
|
935
|
+
components:
|
|
936
|
+
Table:
|
|
937
|
+
htmlHotspot:
|
|
938
|
+
edgeFinish:
|
|
939
|
+
name: EdgeFinishHotspot
|
|
940
|
+
offsetX: 500
|
|
941
|
+
offsetY: 800
|
|
942
|
+
offsetZ: 0
|
|
943
|
+
$filter:
|
|
944
|
+
modes: [owner]
|
|
945
|
+
navigationStates: [configure]
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
The element is registered with `phx.frontend.createCustomPhoenixEntityElement` under the name the spec gives. It receives the id of the entity the hotspot belongs to, and reads the same `attributeSelection` the panel reads:
|
|
949
|
+
|
|
950
|
+
```tsx
|
|
951
|
+
import { Box, ButtonBase, Popover, Tooltip } from '@mui/material'
|
|
952
|
+
import { useState } from 'react'
|
|
953
|
+
|
|
954
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
955
|
+
import { EdgeFinishCards } from '../_shared/EdgeFinishCards.js'
|
|
956
|
+
|
|
957
|
+
// The edge profile the button shows, the square edge of the cards' drawings
|
|
958
|
+
const EDGE_ICON = 'M3 7H17L21 11V13L17 17H3Z'
|
|
959
|
+
|
|
960
|
+
// Rendered by the spec's `htmlHotspot` on the table's edge: a button on the product that opens the edge finishes
|
|
961
|
+
// next to the edge, with the same cards as the panel. The spec's `$filter` decides when it is shown.
|
|
962
|
+
export default phx.frontend.createCustomPhoenixEntityElement('EdgeFinishHotspot', ({ entityId }) => {
|
|
963
|
+
const edgeFinish = phx.frontend.useAttributeSelection(entityId, 'edgeFinish')
|
|
964
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null)
|
|
965
|
+
|
|
966
|
+
return (
|
|
967
|
+
<>
|
|
968
|
+
<Tooltip title="Edge finish">
|
|
969
|
+
<ButtonBase
|
|
970
|
+
aria-label="Edge finish"
|
|
971
|
+
aria-haspopup="dialog"
|
|
972
|
+
aria-expanded={anchor !== null}
|
|
973
|
+
onClick={event => setAnchor(event.currentTarget)}
|
|
974
|
+
sx={{
|
|
975
|
+
display: 'grid',
|
|
976
|
+
placeItems: 'center',
|
|
977
|
+
inlineSize: 44,
|
|
978
|
+
blockSize: 44,
|
|
979
|
+
borderRadius: '50%',
|
|
980
|
+
bgcolor: 'background.paper',
|
|
981
|
+
color: 'primary.main',
|
|
982
|
+
boxShadow: '0 4px 16px rgba(0, 0, 0, 0.2)',
|
|
983
|
+
'&.Mui-focusVisible': { outline: 2, outlineColor: 'primary.main', outlineOffset: 2 },
|
|
984
|
+
}}
|
|
985
|
+
>
|
|
986
|
+
<svg viewBox="0 0 24 24" width={22} height={22} aria-hidden>
|
|
987
|
+
<path d={EDGE_ICON} fill="currentColor" />
|
|
988
|
+
</svg>
|
|
989
|
+
</ButtonBase>
|
|
990
|
+
</Tooltip>
|
|
991
|
+
<Popover
|
|
992
|
+
open={anchor !== null}
|
|
993
|
+
anchorEl={anchor}
|
|
994
|
+
onClose={() => setAnchor(null)}
|
|
995
|
+
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
|
|
996
|
+
transformOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
997
|
+
slotProps={{
|
|
998
|
+
paper: { role: 'dialog', 'aria-label': 'Edge finish', sx: { borderRadius: 4, marginBlockStart: -1 } },
|
|
999
|
+
}}
|
|
1000
|
+
>
|
|
1001
|
+
<Box component="div" sx={{ inlineSize: 340, maxInlineSize: 'calc(100vw - 32px)', padding: 2 }}>
|
|
1002
|
+
<EdgeFinishCards selection={edgeFinish} />
|
|
1003
|
+
</Box>
|
|
1004
|
+
</Popover>
|
|
1005
|
+
</>
|
|
1006
|
+
)
|
|
1007
|
+
})
|
|
1008
|
+
```
|
|
1009
|
+
|
|
1010
|
+
- The hotspot is rendered inside the scene, but it has the theme and every `phx.frontend` hook, like the layout. MUI's `Popover` and `Tooltip` render into the configurator's own modal root, so they are styled and work inside its shadow root.
|
|
1011
|
+
- The cards in the popover are the panel's `EdgeFinishCards`, used a second time. A choice changes the edge, the price and the panel's cards at once, and the popover stays open so the customer can compare the finishes on the table.
|
|
1012
|
+
- Keyboard: the button is in the tab order, Enter and Space open the popover and move the focus into it, the arrow keys change the finish, and Escape closes it and returns the focus to the button.
|
|
1013
|
+
- `controlHotspot: true` would hide the hotspot while a change is being applied, which would also unmount the open popover on every choice, so this hotspot does not set it.
|
|
1014
|
+
- The scene's HTML is painted inside the canvas's stacking context, under the layout's panel and sheet. A hotspot that a panel covers cannot be clicked there.
|
|
1015
|
+
|
|
1016
|
+
[Html Hotspots](?path=/docs/controls-scene-html-hotspots--docs) describes the component and its other properties.
|
|
410
1017
|
|
|
411
1018
|
## The spec the layout reads
|
|
412
1019
|
|
|
413
|
-
The layout reads
|
|
1020
|
+
The layout reads four components of the root entity and its navigation states; the scene components are in the complete implementation below.
|
|
414
1021
|
|
|
415
1022
|
```yaml
|
|
416
1023
|
navigationStates:
|
|
417
1024
|
- configure
|
|
418
1025
|
- checkout
|
|
1026
|
+
- requested
|
|
419
1027
|
|
|
420
1028
|
components:
|
|
421
1029
|
Table:
|
|
@@ -445,45 +1053,65 @@ components:
|
|
|
445
1053
|
- label: Tree trunk
|
|
446
1054
|
description: The natural edge
|
|
447
1055
|
value: TreeTrunk
|
|
1056
|
+
finalizeAction:
|
|
1057
|
+
quote:
|
|
1058
|
+
variant: primary
|
|
1059
|
+
label: Request a quote
|
|
1060
|
+
title: Send the configuration to the shop for a quote
|
|
1061
|
+
icon: PaperPlaneTilt
|
|
1062
|
+
handler: requestQuote
|
|
1063
|
+
|
|
1064
|
+
transformers:
|
|
1065
|
+
- name: tree-trunk-delivery
|
|
448
1066
|
```
|
|
449
1067
|
|
|
450
|
-
`$price` is a custom expression in `src/expressions/table.ts` that adds a surcharge per finish. The example sets no `applicationConfig` and no layout components: `layout`, the header, the sidebar footer, the toolbar, `viewControls` and property pages configure the built-in layout and have no effect on this one.
|
|
1068
|
+
`$price` is a custom expression in `src/expressions/table.ts` that adds a surcharge per finish, and `tree-trunk-delivery` is the transformer in `src/transformers/tree-trunk-delivery.ts` that adds the hint shown in [Show messages](#show-messages), and `requestQuote` is the handler in `src/handlers/request-quote.ts`. The example sets no `applicationConfig` and no layout components: `layout`, the header, the sidebar footer, the toolbar, `viewControls` and property pages configure the built-in layout and have no effect on this one. The `finalizeAction` is not one of them: it describes the product's own finalizing, which this layout offers itself.
|
|
451
1069
|
|
|
452
1070
|
## Try the example
|
|
453
1071
|
|
|
454
1072
|
To see read mode, open **Mocks** in the editor rail on the left and apply the **Read User** template.
|
|
455
1073
|
|
|
1074
|
+
The same layout in a frame 390 pixels wide, as on a phone. Opened on its own from the sidebar, the **Phone** story sets Storybook's viewport to 390 × 844.
|
|
1075
|
+
|
|
456
1076
|
## Test cases
|
|
457
1077
|
|
|
458
1078
|
- The panel is on the left and the table is centred in the area to the right of it, not in the whole canvas.
|
|
459
1079
|
- Choosing **Tree trunk** moves the check mark to that card, changes the edge of the tabletop and raises the price from $1,290.00 to $1,630.00.
|
|
1080
|
+
- Choosing **Tree trunk** also shows "Tree trunk edges are cut by hand, so delivery takes three weeks longer." at the bottom of the free area, until its close button is clicked or six seconds pass. Choosing another finish shows nothing.
|
|
460
1081
|
- Tab reaches the selected card, and the arrow keys move the selection to the next or previous card.
|
|
461
1082
|
- Dragging in the area to the right of the panel orbits the camera.
|
|
462
|
-
- **Review and request a quote** replaces the cards with the chosen finish
|
|
1083
|
+
- **Review and request a quote** replaces the cards with the chosen finish and offers **Request a quote**; **Back to the configuration** brings the cards back.
|
|
1084
|
+
- **Request a quote** shows a spinner and "Sending the request…" for about a second and a half, with **Back to the configuration** disabled, then "Thank you. Your quote request is on its way, and the shop replies within two working days."; **Back to the configuration** then returns to the cards.
|
|
463
1085
|
- **Fullscreen** removes the panel and the table moves to the centre of the canvas; **Exit fullscreen** brings both back.
|
|
464
|
-
- With the **Read User** mock the panel says **View only**, shows the chosen finish and the price, and has no button.
|
|
1086
|
+
- With the **Read User** mock the panel says **View only**, shows the chosen finish and the price, and has no button, so no quote can be requested.
|
|
1087
|
+
- A round button sits on the middle of the table's long edge. Clicking it opens the four finishes next to it; choosing **Round** there moves the check mark in the popover and in the panel, rounds the edge and raises the price to $1,410.00. Escape closes the popover.
|
|
1088
|
+
- Tab reaches the button on the edge, and Enter or Space opens the popover.
|
|
1089
|
+
- The button on the edge is gone in the review step, in the confirmation and with the **Read User** mock, and stays in fullscreen.
|
|
1090
|
+
- In the **Phone** story the panel is a sheet at the bottom showing the name, the price and **Review and request a quote**, and the whole table is visible above it.
|
|
1091
|
+
- Tapping the sheet's handle, or dragging it up, opens the sheet with the cards; the table moves up once the sheet has snapped and stays fully visible. Dragging the handle down, or tapping it again, collapses the sheet.
|
|
1092
|
+
- On the phone, the review step, **Request a quote** and the thank-you message work with the sheet collapsed and open.
|
|
1093
|
+
- On the phone, choosing **Tree trunk** shows the hint at the top of the free area, beside the fullscreen button.
|
|
1094
|
+
- On the phone, the fullscreen button removes the sheet and the table moves to the centre of the canvas; pressing it again brings the sheet back in the position it had.
|
|
465
1095
|
|
|
466
1096
|
## Known gaps
|
|
467
1097
|
|
|
468
|
-
A project layout has only what it renders. This one leaves out the following, each of which a product may need.
|
|
1098
|
+
A project layout has only what it renders. This one leaves out the following, each of which a product may need. [Layout Slots](?path=/docs/phoenix-layout-slots--docs) describes every `LayoutSlots` member named here.
|
|
469
1099
|
|
|
470
|
-
- **
|
|
471
|
-
- **Error, violation and side-effect messages.** The layout mounts nothing that shows them. `LayoutSlots.Services` raises invariant violations and side effects as snackbars, and shows "Oops, something went wrong" for an error thrown while the state is validated, for example by a custom expression, which any spec with custom expressions can hit, this one included; `LayoutSlots.DesktopSnackbarsRoot` is the element the snackbars are rendered into. A layout mounts both, or reads `phx.frontend.useStateValidity()` and shows them its own way.
|
|
472
|
-
- **A finalize page from the spec.** The review step here is the layout's own and submits nothing. It does not show a `finalizePage` component and does not check `phx.frontend.useFinalizeViolations()`. [Finalization](?path=/docs/phoenix-finalization--docs) covers what a real flow does.
|
|
1100
|
+
- **Messages that stay snackbars.** The toast shows violations, side effects and errors, and the finalize button shows its own error. A failure to save the configuration is still raised as a snackbar, which renders into `LayoutSlots.DesktopSnackbarsRoot`; this layout mounts no snackbar root, so it appears outside the configurator. A layout that wants it inside mounts the root.
|
|
473
1101
|
- **Toolbar actions.** Undo and redo, camera reset, measurements, sharing and language switching are not offered. A layout can mount `LayoutSlots.DesktopToolbar` for the toolbar the spec configures, or build its own buttons.
|
|
474
|
-
- **View controls, tool controls and leaving a tool mode.** A spec can configure view controls and tool controls, and a tool mode has a button that leaves it. The built-in layout places them with `LayoutSlots.DesktopViewControls`, `LayoutSlots.DesktopToolControls` and `LayoutSlots.DesktopCallToAction`; this layout mounts none of them, so they do not appear.
|
|
1102
|
+
- **View controls, tool controls and leaving a tool mode.** A spec can configure view controls and tool controls, and a tool mode has a button that leaves it. The built-in layout places them with `LayoutSlots.DesktopViewControls`, `LayoutSlots.DesktopToolControls` and `LayoutSlots.DesktopCallToAction`; this layout mounts none of them, so they do not appear. Nor does this layout build view buttons or a camera reset of its own.
|
|
475
1103
|
- **A project's layout dialog.** A dialog the project registers with `phx.frontend.createLayoutDialog` is shown by `LayoutDialog`, which the built-in layout mounts. This layout does not; a layout that needs the dialog mounts `LayoutDialog` from `@salsita-ai/sdk/configurator`.
|
|
476
1104
|
- **Selection.** The table has no parts to select. A product with selectable parts reads `phx.frontend.useSelectedDomainEntityId()` and shows the controls of the selected part.
|
|
477
1105
|
- **Clone to edit in read mode.** With `shareCloneToEdit` set, the built-in layout's `LayoutSlots.DesktopReadonlyBanner` offers **Edit configuration** to a viewer; this layout's "View only" label offers nothing. A layout mounts the banner, or builds its own action with `LayoutSlots.useIsCloningAllowed()` and `LayoutSlots.CloneToEditDialog`.
|
|
478
1106
|
- **Back and close.** The built-in header's back button returns to the product choice, runs the host's close action or leaves the expanded view, whichever applies. This layout has none of them. `useCloseAction()` from `@salsita-ai/sdk/configurator` returns the host's close action, or `null` when there is none; the hook that chooses among the three is not exported.
|
|
479
|
-
- **Analytics.** The built-in fullscreen
|
|
1107
|
+
- **Analytics.** The finalize button records `FinalizeButtonClicked` through `useFinalizeAction`. The built-in fullscreen button records `FullScreenModeToggled`; this layout's fullscreen and other buttons record nothing. A layout that wants the events pushes `FrontendAnalyticsFactory.FullScreenModeToggled()` and the like, from `@salsita-ai/sdk/configurator`, with `phx.frontend.useAnalytics().push(...)`.
|
|
480
1108
|
- **Preview start screen.** The built-in layout shows a preview while `usePreview().isPreview` is set, which `preview: auto` does on phones without the project opting in. This layout ignores it and always renders the interface.
|
|
481
1109
|
- **Assistant panel.** A project layout gets it only with `LayoutSlots.DesktopSidebar`, the built-in sidebar as one piece, see [Sidebar in a Custom Layout](?path=/docs/layouts-sidebar-in-a-custom-layout--docs); this layout does not use it.
|
|
482
1110
|
- **"Powered by Salsita" mark.** The built-in layout shows it; a project layout decides whether to mount `LayoutSlots.DesktopPoweredBy`, and this one does not.
|
|
483
1111
|
|
|
484
1112
|
## Related pages
|
|
485
1113
|
|
|
486
|
-
- [Configurator Interface → Loaded Configuration UI](?path=/docs/phoenix-configurator-interface--docs#loaded-configuration-ui) is the reference for the element name, the minimal layout
|
|
1114
|
+
- [Configurator Interface → Loaded Configuration UI](?path=/docs/phoenix-configurator-interface--docs#loaded-configuration-ui) is the reference for the element name, the minimal layout, the SDK pieces a layout can mount and the hooks it reads.
|
|
487
1115
|
- [Universal](?path=/docs/layouts-universal--docs) is the built-in layout this one replaces.
|
|
488
1116
|
- [Header / Custom](?path=/docs/layouts-header-custom--docs) replaces only the header, with the price from `useRootEntityPrice()`.
|
|
489
1117
|
- [Canvas Padding](?path=/docs/layouts-canvas-padding--docs) scales the gaps `useSceneSafeArea()` measures.
|
|
@@ -528,6 +1156,7 @@ presets:
|
|
|
528
1156
|
navigationStates:
|
|
529
1157
|
- configure
|
|
530
1158
|
- checkout
|
|
1159
|
+
- requested
|
|
531
1160
|
|
|
532
1161
|
components:
|
|
533
1162
|
Table:
|
|
@@ -557,9 +1186,25 @@ components:
|
|
|
557
1186
|
- label: Tree trunk
|
|
558
1187
|
description: The natural edge
|
|
559
1188
|
value: TreeTrunk
|
|
1189
|
+
finalizeAction:
|
|
1190
|
+
quote:
|
|
1191
|
+
variant: primary
|
|
1192
|
+
label: Request a quote
|
|
1193
|
+
title: Send the configuration to the shop for a quote
|
|
1194
|
+
icon: PaperPlaneTilt
|
|
1195
|
+
handler: requestQuote
|
|
1196
|
+
htmlHotspot:
|
|
1197
|
+
edgeFinish:
|
|
1198
|
+
name: EdgeFinishHotspot
|
|
1199
|
+
offsetX: 500
|
|
1200
|
+
offsetY: 800
|
|
1201
|
+
offsetZ: 0
|
|
1202
|
+
$filter:
|
|
1203
|
+
modes: [owner]
|
|
1204
|
+
navigationStates: [configure]
|
|
560
1205
|
fitRootPerspectiveCamera:
|
|
561
1206
|
main:
|
|
562
|
-
priority:
|
|
1207
|
+
priority: 2
|
|
563
1208
|
fov: 35
|
|
564
1209
|
near: 100
|
|
565
1210
|
far: 10000
|
|
@@ -569,6 +1214,21 @@ components:
|
|
|
569
1214
|
azimuthAngle: 1.5
|
|
570
1215
|
polarAngle: 1.1
|
|
571
1216
|
fitMeshChanges: true
|
|
1217
|
+
$filter:
|
|
1218
|
+
viewports: [desktop]
|
|
1219
|
+
phone:
|
|
1220
|
+
priority: 1
|
|
1221
|
+
fov: 35
|
|
1222
|
+
near: 100
|
|
1223
|
+
far: 10000
|
|
1224
|
+
minDistance: 1000
|
|
1225
|
+
maxDistance: 12000
|
|
1226
|
+
distance: 8000
|
|
1227
|
+
azimuthAngle: 1.5
|
|
1228
|
+
polarAngle: 1.1
|
|
1229
|
+
fitMeshChanges: true
|
|
1230
|
+
$filter:
|
|
1231
|
+
viewports: [mobile]
|
|
572
1232
|
sceneEntityRemoteObject:
|
|
573
1233
|
top:
|
|
574
1234
|
fileUrl: /models/tables.gltf
|
|
@@ -611,6 +1271,173 @@ components:
|
|
|
611
1271
|
value: 780
|
|
612
1272
|
scaleOne: 780
|
|
613
1273
|
scaleZero: 740
|
|
1274
|
+
|
|
1275
|
+
transformers:
|
|
1276
|
+
- name: tree-trunk-delivery
|
|
1277
|
+
```
|
|
1278
|
+
|
|
1279
|
+
### ./src/\_shared/BottomSheet.tsx
|
|
1280
|
+
|
|
1281
|
+
```tsx
|
|
1282
|
+
import { Box, ButtonBase } from '@mui/material'
|
|
1283
|
+
import { type MouseEvent, type PointerEvent, type ReactNode, useRef } from 'react'
|
|
1284
|
+
|
|
1285
|
+
// A drag shorter than this is a tap, and the handle's click toggles the sheet
|
|
1286
|
+
const TAP_DISTANCE = 6
|
|
1287
|
+
// A drag that ends this far from where it started snaps to the other position
|
|
1288
|
+
const SNAP_DISTANCE = 48
|
|
1289
|
+
// A drag faster than this, in pixels per millisecond, snaps in its direction even when it is short
|
|
1290
|
+
const SNAP_VELOCITY = 0.5
|
|
1291
|
+
// How far the sheet follows the finger towards the position it is already in
|
|
1292
|
+
const OVERDRAG = 0.25
|
|
1293
|
+
|
|
1294
|
+
interface BottomSheetProps {
|
|
1295
|
+
readonly open: boolean
|
|
1296
|
+
readonly onOpenChange: (open: boolean) => void
|
|
1297
|
+
readonly label: string
|
|
1298
|
+
readonly children: ReactNode
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
interface Drag {
|
|
1302
|
+
readonly startY: number
|
|
1303
|
+
readonly startTime: number
|
|
1304
|
+
delta: number
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
// A persistent sheet at the bottom of the layout with two positions, open and collapsed. It is not a modal: the scene
|
|
1308
|
+
// above it stays interactive. Its height comes from its content, so the layout's safe area ends where the sheet
|
|
1309
|
+
// starts and changes only when the sheet snaps. While the handle is dragged the sheet follows the finger with a
|
|
1310
|
+
// transform, which the safe area does not see, so the camera refits once per snap and not on every move.
|
|
1311
|
+
export const BottomSheet = ({ open, onOpenChange, label, children }: BottomSheetProps) => {
|
|
1312
|
+
const sheetRef = useRef<HTMLElement>(null)
|
|
1313
|
+
const dragRef = useRef<Drag | null>(null)
|
|
1314
|
+
const draggedRef = useRef(false)
|
|
1315
|
+
|
|
1316
|
+
const moveSheet = (offset: number, animate: boolean) => {
|
|
1317
|
+
if (sheetRef.current) {
|
|
1318
|
+
sheetRef.current.style.transition = animate ? 'transform 200ms ease-out' : 'none'
|
|
1319
|
+
sheetRef.current.style.transform = offset === 0 ? '' : `translateY(${offset}px)`
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
const handlePointerDown = (event: PointerEvent<HTMLButtonElement>) => {
|
|
1324
|
+
event.currentTarget.setPointerCapture(event.pointerId)
|
|
1325
|
+
dragRef.current = { startY: event.clientY, startTime: event.timeStamp, delta: 0 }
|
|
1326
|
+
draggedRef.current = false
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
const handlePointerMove = (event: PointerEvent<HTMLButtonElement>) => {
|
|
1330
|
+
const drag = dragRef.current
|
|
1331
|
+
|
|
1332
|
+
if (drag === null) {
|
|
1333
|
+
return
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
drag.delta = event.clientY - drag.startY
|
|
1337
|
+
// Down closes an open sheet and up opens a collapsed one; the other direction only gives a little
|
|
1338
|
+
const towardsOther = open ? drag.delta > 0 : drag.delta < 0
|
|
1339
|
+
moveSheet(towardsOther ? drag.delta : drag.delta * OVERDRAG, false)
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
const handlePointerEnd = (event: PointerEvent<HTMLButtonElement>) => {
|
|
1343
|
+
const drag = dragRef.current
|
|
1344
|
+
dragRef.current = null
|
|
1345
|
+
|
|
1346
|
+
if (drag === null) {
|
|
1347
|
+
return
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
moveSheet(0, true)
|
|
1351
|
+
|
|
1352
|
+
if (Math.abs(drag.delta) < TAP_DISTANCE) {
|
|
1353
|
+
return
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
draggedRef.current = true
|
|
1357
|
+
const velocity = drag.delta / Math.max(event.timeStamp - drag.startTime, 1)
|
|
1358
|
+
const flicked = Math.abs(drag.delta) >= SNAP_DISTANCE || Math.abs(velocity) >= SNAP_VELOCITY
|
|
1359
|
+
|
|
1360
|
+
if (flicked && (open ? drag.delta > 0 : drag.delta < 0)) {
|
|
1361
|
+
onOpenChange(!open)
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// A tap, Enter or Space toggles the sheet. The pointer click that ends a drag has already been handled; a keyboard
|
|
1366
|
+
// click (`detail` 0) always toggles, also after a touch drag that was followed by no click.
|
|
1367
|
+
const handleClick = (event: MouseEvent<HTMLButtonElement>) => {
|
|
1368
|
+
const dragged = draggedRef.current
|
|
1369
|
+
draggedRef.current = false
|
|
1370
|
+
|
|
1371
|
+
if (dragged && event.detail !== 0) {
|
|
1372
|
+
return
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
onOpenChange(!open)
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
return (
|
|
1379
|
+
<Box
|
|
1380
|
+
component="section"
|
|
1381
|
+
ref={sheetRef}
|
|
1382
|
+
aria-label={label}
|
|
1383
|
+
sx={{
|
|
1384
|
+
position: 'relative',
|
|
1385
|
+
flexShrink: 0,
|
|
1386
|
+
display: 'flex',
|
|
1387
|
+
flexDirection: 'column',
|
|
1388
|
+
maxBlockSize: '55%',
|
|
1389
|
+
paddingBlockEnd: 'env(safe-area-inset-bottom)',
|
|
1390
|
+
borderStartStartRadius: 20,
|
|
1391
|
+
borderStartEndRadius: 20,
|
|
1392
|
+
bgcolor: 'background.paper',
|
|
1393
|
+
boxShadow: '0 -8px 32px rgba(0, 0, 0, 0.12)',
|
|
1394
|
+
// Fills the gap below the sheet while it is dragged up
|
|
1395
|
+
'&::after': {
|
|
1396
|
+
content: '""',
|
|
1397
|
+
position: 'absolute',
|
|
1398
|
+
insetInline: 0,
|
|
1399
|
+
insetBlockStart: '100%',
|
|
1400
|
+
blockSize: '100vh',
|
|
1401
|
+
bgcolor: 'background.paper',
|
|
1402
|
+
},
|
|
1403
|
+
}}
|
|
1404
|
+
>
|
|
1405
|
+
<ButtonBase
|
|
1406
|
+
aria-expanded={open}
|
|
1407
|
+
disableRipple
|
|
1408
|
+
aria-label={open ? `Collapse ${label.toLowerCase()}` : `Expand ${label.toLowerCase()}`}
|
|
1409
|
+
onClick={handleClick}
|
|
1410
|
+
onPointerDown={handlePointerDown}
|
|
1411
|
+
onPointerMove={handlePointerMove}
|
|
1412
|
+
onPointerUp={handlePointerEnd}
|
|
1413
|
+
onPointerCancel={handlePointerEnd}
|
|
1414
|
+
sx={{
|
|
1415
|
+
flexShrink: 0,
|
|
1416
|
+
blockSize: 36,
|
|
1417
|
+
touchAction: 'none',
|
|
1418
|
+
'&.Mui-focusVisible': { outline: 2, outlineColor: 'primary.main', outlineOffset: -4, borderRadius: 3 },
|
|
1419
|
+
}}
|
|
1420
|
+
>
|
|
1421
|
+
<Box component="span" sx={{ inlineSize: 40, blockSize: 4, borderRadius: 2, bgcolor: 'text.disabled' }} />
|
|
1422
|
+
</ButtonBase>
|
|
1423
|
+
{/* A column, so the panel's cards region shrinks first and the price and action stay in view; below the cards
|
|
1424
|
+
region's minimum height the content scrolls as a whole, as the review step does on a short phone */}
|
|
1425
|
+
<Box
|
|
1426
|
+
component="div"
|
|
1427
|
+
sx={{
|
|
1428
|
+
display: 'flex',
|
|
1429
|
+
flexDirection: 'column',
|
|
1430
|
+
flex: '1 1 auto',
|
|
1431
|
+
minBlockSize: 0,
|
|
1432
|
+
overflowY: 'auto',
|
|
1433
|
+
overscrollBehavior: 'contain',
|
|
1434
|
+
}}
|
|
1435
|
+
>
|
|
1436
|
+
{children}
|
|
1437
|
+
</Box>
|
|
1438
|
+
</Box>
|
|
1439
|
+
)
|
|
1440
|
+
}
|
|
614
1441
|
```
|
|
615
1442
|
|
|
616
1443
|
### ./src/\_shared/EdgeFinishCards.tsx
|
|
@@ -751,39 +1578,106 @@ export const EdgeFinishCards = ({ selection }: EdgeFinishCardsProps) => {
|
|
|
751
1578
|
### ./src/\_shared/FullscreenToggle.tsx
|
|
752
1579
|
|
|
753
1580
|
```tsx
|
|
754
|
-
import { Button } from '@mui/material'
|
|
1581
|
+
import { Button, Tooltip } from '@mui/material'
|
|
755
1582
|
|
|
756
1583
|
import { phx } from '../../.phoenix/phx.js'
|
|
757
1584
|
|
|
758
1585
|
const ENTER_ICON = 'M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5'
|
|
759
1586
|
const EXIT_ICON = 'M9 4v5H4M15 4v5h5M15 20v-5h5M9 20v-5H4'
|
|
760
1587
|
|
|
761
|
-
|
|
1588
|
+
interface FullscreenToggleProps {
|
|
1589
|
+
// Only the icon, with the label as its accessible name and tooltip, where a label would cover the product
|
|
1590
|
+
readonly compact?: boolean
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
export const FullscreenToggle = ({ compact = false }: FullscreenToggleProps) => {
|
|
762
1594
|
const isFullscreen = phx.frontend.useIsFullscreenActive()
|
|
763
1595
|
const setFullscreen = phx.frontend.useSetFullscreen()
|
|
1596
|
+
const label = isFullscreen ? 'Exit fullscreen' : 'Fullscreen'
|
|
1597
|
+
const icon = (
|
|
1598
|
+
<svg viewBox="0 0 24 24" width={20} height={20} fill="none" stroke="currentColor" strokeWidth={2}>
|
|
1599
|
+
<path d={isFullscreen ? EXIT_ICON : ENTER_ICON} />
|
|
1600
|
+
</svg>
|
|
1601
|
+
)
|
|
764
1602
|
|
|
765
1603
|
return (
|
|
766
|
-
<
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
1604
|
+
<Tooltip title={compact ? label : ''}>
|
|
1605
|
+
<Button
|
|
1606
|
+
onClick={() => setFullscreen(!isFullscreen)}
|
|
1607
|
+
aria-label={compact ? label : undefined}
|
|
1608
|
+
startIcon={compact ? undefined : icon}
|
|
1609
|
+
sx={{
|
|
1610
|
+
minBlockSize: 44,
|
|
1611
|
+
minInlineSize: 44,
|
|
1612
|
+
paddingInline: compact ? 0 : 2.5,
|
|
1613
|
+
borderRadius: 999,
|
|
1614
|
+
bgcolor: 'background.paper',
|
|
1615
|
+
color: 'text.primary',
|
|
1616
|
+
boxShadow: '0 4px 16px rgba(0, 0, 0, 0.12)',
|
|
1617
|
+
textTransform: 'none',
|
|
1618
|
+
fontWeight: 600,
|
|
1619
|
+
'&:hover': { bgcolor: 'background.paper', boxShadow: '0 6px 20px rgba(0, 0, 0, 0.18)' },
|
|
1620
|
+
}}
|
|
1621
|
+
>
|
|
1622
|
+
{compact ? icon : label}
|
|
1623
|
+
</Button>
|
|
1624
|
+
</Tooltip>
|
|
1625
|
+
)
|
|
1626
|
+
}
|
|
1627
|
+
```
|
|
1628
|
+
|
|
1629
|
+
### ./src/\_shared/MessageToast.tsx
|
|
1630
|
+
|
|
1631
|
+
```tsx
|
|
1632
|
+
import { Alert } from '@mui/material'
|
|
1633
|
+
import { useEffect, useState } from 'react'
|
|
1634
|
+
|
|
1635
|
+
import type { ConfiguratorMessage } from '@salsita-ai/sdk/react'
|
|
1636
|
+
|
|
1637
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
1638
|
+
|
|
1639
|
+
const VIOLATION_SEVERITY = { fatal: 'error', fixable: 'error', warning: 'warning', notice: 'info' } as const
|
|
1640
|
+
const RANK = { info: 0, warning: 1, error: 2 } as const
|
|
1641
|
+
const VISIBLE_MS = 6000
|
|
1642
|
+
|
|
1643
|
+
const severityOf = (message: ConfiguratorMessage) => {
|
|
1644
|
+
if (message.kind === 'violation') {
|
|
1645
|
+
return VIOLATION_SEVERITY[message.violation.severity]
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
return message.kind === 'error' ? 'error' : 'info'
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
export const MessageToast = () => {
|
|
1652
|
+
const [message, setMessage] = useState<ConfiguratorMessage | null>(null)
|
|
1653
|
+
|
|
1654
|
+
// A rejected change also reports the notices already present; keep the worst message while it is shown
|
|
1655
|
+
phx.frontend.useConfiguratorMessages(next => {
|
|
1656
|
+
setMessage(shown => (shown !== null && RANK[severityOf(next)] < RANK[severityOf(shown)] ? shown : next))
|
|
1657
|
+
})
|
|
1658
|
+
|
|
1659
|
+
useEffect(() => {
|
|
1660
|
+
if (message === null) {
|
|
1661
|
+
return
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
const timeout = setTimeout(() => setMessage(null), VISIBLE_MS)
|
|
1665
|
+
|
|
1666
|
+
return () => clearTimeout(timeout)
|
|
1667
|
+
}, [message])
|
|
1668
|
+
|
|
1669
|
+
if (message === null) {
|
|
1670
|
+
return null
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
return (
|
|
1674
|
+
<Alert
|
|
1675
|
+
severity={severityOf(message)}
|
|
1676
|
+
onClose={() => setMessage(null)}
|
|
1677
|
+
sx={{ maxInlineSize: 420, borderRadius: 3, boxShadow: '0 12px 40px rgba(0, 0, 0, 0.12)' }}
|
|
784
1678
|
>
|
|
785
|
-
{
|
|
786
|
-
</
|
|
1679
|
+
{message.text}
|
|
1680
|
+
</Alert>
|
|
787
1681
|
)
|
|
788
1682
|
}
|
|
789
1683
|
```
|
|
@@ -793,13 +1687,23 @@ export const FullscreenToggle = () => {
|
|
|
793
1687
|
```tsx
|
|
794
1688
|
import { Box, Button, Typography } from '@mui/material'
|
|
795
1689
|
|
|
796
|
-
import { detailComponent } from '@salsita-ai/sdk/domain'
|
|
797
|
-
import { useResolveLocalizable } from '@salsita-ai/sdk/react'
|
|
1690
|
+
import { detailComponent, finalizeActionComponent } from '@salsita-ai/sdk/domain'
|
|
1691
|
+
import { PhoenixHandlerBoundary, useResolveLocalizable } from '@salsita-ai/sdk/react'
|
|
798
1692
|
|
|
799
1693
|
import { phx } from '../../.phoenix/phx.js'
|
|
800
1694
|
import { EdgeFinishCards } from './EdgeFinishCards.js'
|
|
1695
|
+
import { ReviewActions } from './ReviewActions.js'
|
|
1696
|
+
|
|
1697
|
+
const BUTTON_SX = { minBlockSize: 48, borderRadius: 999, textTransform: 'none', fontWeight: 600 } as const
|
|
1698
|
+
|
|
1699
|
+
interface ProductPanelProps {
|
|
1700
|
+
// Only the name, the price and the action, for a collapsed bottom sheet
|
|
1701
|
+
readonly collapsed?: boolean
|
|
1702
|
+
// In a bottom sheet the cards region keeps the top of the cards in view, and the sheet scrolls when that does not fit
|
|
1703
|
+
readonly inSheet?: boolean
|
|
1704
|
+
}
|
|
801
1705
|
|
|
802
|
-
export const ProductPanel = () => {
|
|
1706
|
+
export const ProductPanel = ({ collapsed = false, inSheet = false }: ProductPanelProps) => {
|
|
803
1707
|
const resolve = useResolveLocalizable()
|
|
804
1708
|
const detail = phx.frontend.useFirstRootComponent(detailComponent)
|
|
805
1709
|
const price = phx.frontend.useRootEntityPrice()
|
|
@@ -809,9 +1713,13 @@ export const ProductPanel = () => {
|
|
|
809
1713
|
const navigationState = phx.frontend.useActiveNavigationState()
|
|
810
1714
|
const pushNavigate = phx.frontend.usePushNavigate()
|
|
811
1715
|
const popNavigate = phx.frontend.usePopNavigate()
|
|
1716
|
+
const navigate = phx.frontend.useNavigate()
|
|
1717
|
+
const finalizeActions = phx.frontend.useComponents({ componentTypes: [finalizeActionComponent] }) ?? []
|
|
812
1718
|
|
|
813
1719
|
const isReadMode = accessInfo.viewMode
|
|
814
|
-
const isReview = isReadMode || navigationState
|
|
1720
|
+
const isReview = isReadMode || navigationState !== 'configure'
|
|
1721
|
+
// The spec's primary finalize action, or its first one
|
|
1722
|
+
const quoteAction = finalizeActions.find(action => action.state.variant === 'primary') ?? finalizeActions[0]
|
|
815
1723
|
const chosenEdge = edgeFinish.options.find(option => option.value === edgeFinish.value)
|
|
816
1724
|
|
|
817
1725
|
return (
|
|
@@ -832,29 +1740,44 @@ export const ProductPanel = () => {
|
|
|
832
1740
|
<Typography variant="h5" component="h2" fontWeight={700}>
|
|
833
1741
|
{resolve(detail?.state.title)}
|
|
834
1742
|
</Typography>
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
<Box component="div" sx={{ display: 'grid', gap: 1.5, paddingInline: 3, paddingBlockEnd: 3, overflowY: 'auto' }}>
|
|
841
|
-
<Typography variant="subtitle2" component="h3">
|
|
842
|
-
Edge finish
|
|
843
|
-
</Typography>
|
|
844
|
-
{isReview ? (
|
|
845
|
-
<Box component="div" sx={{ padding: 2, borderRadius: 3, bgcolor: 'action.hover' }}>
|
|
846
|
-
<Typography variant="body2" fontWeight={600}>
|
|
847
|
-
{resolve(chosenEdge?.title)}
|
|
848
|
-
</Typography>
|
|
849
|
-
<Typography variant="caption" color="text.secondary">
|
|
850
|
-
{resolve(chosenEdge?.description)}
|
|
851
|
-
</Typography>
|
|
852
|
-
</Box>
|
|
853
|
-
) : (
|
|
854
|
-
<EdgeFinishCards selection={edgeFinish} />
|
|
1743
|
+
{!collapsed && (
|
|
1744
|
+
<Typography variant="body2" color="text.secondary">
|
|
1745
|
+
{resolve(detail?.state.description)}
|
|
1746
|
+
</Typography>
|
|
855
1747
|
)}
|
|
856
1748
|
</Box>
|
|
857
1749
|
|
|
1750
|
+
{!collapsed && (
|
|
1751
|
+
<Box
|
|
1752
|
+
component="div"
|
|
1753
|
+
sx={{
|
|
1754
|
+
display: 'grid',
|
|
1755
|
+
gap: 1.5,
|
|
1756
|
+
paddingInline: 3,
|
|
1757
|
+
paddingBlockEnd: 3,
|
|
1758
|
+
// In a short container the region shrinks and scrolls; a scroll past its end moves its container on
|
|
1759
|
+
minBlockSize: inSheet ? 120 : 0,
|
|
1760
|
+
overflowY: 'auto',
|
|
1761
|
+
}}
|
|
1762
|
+
>
|
|
1763
|
+
<Typography variant="subtitle2" component="h3">
|
|
1764
|
+
Edge finish
|
|
1765
|
+
</Typography>
|
|
1766
|
+
{isReview ? (
|
|
1767
|
+
<Box component="div" sx={{ padding: 2, borderRadius: 3, bgcolor: 'action.hover' }}>
|
|
1768
|
+
<Typography variant="body2" fontWeight={600}>
|
|
1769
|
+
{resolve(chosenEdge?.title)}
|
|
1770
|
+
</Typography>
|
|
1771
|
+
<Typography variant="caption" color="text.secondary">
|
|
1772
|
+
{resolve(chosenEdge?.description)}
|
|
1773
|
+
</Typography>
|
|
1774
|
+
</Box>
|
|
1775
|
+
) : (
|
|
1776
|
+
<EdgeFinishCards selection={edgeFinish} />
|
|
1777
|
+
)}
|
|
1778
|
+
</Box>
|
|
1779
|
+
)}
|
|
1780
|
+
|
|
858
1781
|
<Box component="footer" sx={{ display: 'grid', gap: 2, padding: 3, borderTop: 1, borderColor: 'divider' }}>
|
|
859
1782
|
<Box component="div" sx={{ display: 'flex', alignItems: 'baseline', justifyContent: 'space-between' }}>
|
|
860
1783
|
<Typography variant="body2" color="text.secondary">
|
|
@@ -864,50 +1787,139 @@ export const ProductPanel = () => {
|
|
|
864
1787
|
{price}
|
|
865
1788
|
</Typography>
|
|
866
1789
|
</Box>
|
|
867
|
-
{
|
|
868
|
-
<
|
|
869
|
-
|
|
870
|
-
</Typography>
|
|
871
|
-
)}
|
|
872
|
-
{!isReadMode && (
|
|
873
|
-
<Button
|
|
874
|
-
size="large"
|
|
875
|
-
variant={isReview ? 'outlined' : 'contained'}
|
|
876
|
-
onClick={isReview ? popNavigate : () => pushNavigate('checkout')}
|
|
877
|
-
sx={{ minBlockSize: 48, borderRadius: 999, textTransform: 'none', fontWeight: 600 }}
|
|
878
|
-
>
|
|
879
|
-
{isReview ? 'Back to the configuration' : 'Review and request a quote'}
|
|
1790
|
+
{!isReadMode && navigationState === 'configure' && (
|
|
1791
|
+
<Button size="large" variant="contained" onClick={() => pushNavigate('checkout')} sx={BUTTON_SX}>
|
|
1792
|
+
Review and request a quote
|
|
880
1793
|
</Button>
|
|
881
1794
|
)}
|
|
1795
|
+
{!isReadMode && navigationState === 'checkout' && (
|
|
1796
|
+
<>
|
|
1797
|
+
<Typography variant="body2" color="text.secondary">
|
|
1798
|
+
Your table is ready for a quote. A real shop collects the contact details here.
|
|
1799
|
+
</Typography>
|
|
1800
|
+
{quoteAction ? (
|
|
1801
|
+
<PhoenixHandlerBoundary name={quoteAction.state.handler}>
|
|
1802
|
+
<ReviewActions
|
|
1803
|
+
handler={quoteAction.state.handler}
|
|
1804
|
+
label={resolve(quoteAction.state.label)}
|
|
1805
|
+
onBack={popNavigate}
|
|
1806
|
+
/>
|
|
1807
|
+
</PhoenixHandlerBoundary>
|
|
1808
|
+
) : (
|
|
1809
|
+
<Button size="large" variant="outlined" onClick={popNavigate} sx={BUTTON_SX}>
|
|
1810
|
+
Back to the configuration
|
|
1811
|
+
</Button>
|
|
1812
|
+
)}
|
|
1813
|
+
</>
|
|
1814
|
+
)}
|
|
1815
|
+
{!isReadMode && navigationState === 'requested' && (
|
|
1816
|
+
<>
|
|
1817
|
+
<Typography variant="body2" role="status">
|
|
1818
|
+
Thank you. Your quote request is on its way, and the shop replies within two working days.
|
|
1819
|
+
</Typography>
|
|
1820
|
+
<Button size="large" variant="outlined" onClick={() => navigate('configure')} sx={BUTTON_SX}>
|
|
1821
|
+
Back to the configuration
|
|
1822
|
+
</Button>
|
|
1823
|
+
</>
|
|
1824
|
+
)}
|
|
882
1825
|
</Box>
|
|
883
1826
|
</>
|
|
884
1827
|
)
|
|
885
1828
|
}
|
|
886
1829
|
```
|
|
887
1830
|
|
|
1831
|
+
### ./src/\_shared/ReviewActions.tsx
|
|
1832
|
+
|
|
1833
|
+
```tsx
|
|
1834
|
+
import { Alert, Box, Button, CircularProgress, Typography } from '@mui/material'
|
|
1835
|
+
|
|
1836
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
1837
|
+
|
|
1838
|
+
const BUTTON_SX = { minBlockSize: 48, borderRadius: 999, textTransform: 'none', fontWeight: 600 } as const
|
|
1839
|
+
|
|
1840
|
+
interface ReviewActionsProps {
|
|
1841
|
+
readonly handler: string
|
|
1842
|
+
readonly label: string
|
|
1843
|
+
readonly onBack: () => void
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
// The review step's buttons: one finalize action and the way back. `useFinalizeAction` runs the action's handler,
|
|
1847
|
+
// so this component calls it exactly once and is rendered inside a `PhoenixHandlerBoundary` for that handler.
|
|
1848
|
+
// Back is disabled while the request is pending, so the customer cannot change the configuration while it is sent.
|
|
1849
|
+
// The pending state belongs to this component: when the panel unmounts, as in fullscreen, the request goes on and
|
|
1850
|
+
// the remounted buttons are enabled again.
|
|
1851
|
+
export const ReviewActions = ({ handler, label, onBack }: ReviewActionsProps) => {
|
|
1852
|
+
const { run, isPending, error, disabled, hints } = phx.frontend.useFinalizeAction(handler)
|
|
1853
|
+
|
|
1854
|
+
return (
|
|
1855
|
+
<Box component="div" sx={{ display: 'grid', gap: 2 }}>
|
|
1856
|
+
<Box component="div" sx={{ display: 'grid', gap: 1 }}>
|
|
1857
|
+
<Button
|
|
1858
|
+
size="large"
|
|
1859
|
+
variant="contained"
|
|
1860
|
+
disabled={disabled || isPending}
|
|
1861
|
+
onClick={run}
|
|
1862
|
+
startIcon={isPending ? <CircularProgress size={18} color="inherit" /> : undefined}
|
|
1863
|
+
sx={BUTTON_SX}
|
|
1864
|
+
>
|
|
1865
|
+
{isPending ? 'Sending the request…' : label}
|
|
1866
|
+
</Button>
|
|
1867
|
+
{disabled && hints && (
|
|
1868
|
+
<Typography variant="caption" color="text.secondary">
|
|
1869
|
+
{hints}
|
|
1870
|
+
</Typography>
|
|
1871
|
+
)}
|
|
1872
|
+
{error && <Alert severity="error">The request could not be sent: {error.message}</Alert>}
|
|
1873
|
+
</Box>
|
|
1874
|
+
<Button size="large" variant="outlined" disabled={isPending} onClick={onBack} sx={BUTTON_SX}>
|
|
1875
|
+
Back to the configuration
|
|
1876
|
+
</Button>
|
|
1877
|
+
</Box>
|
|
1878
|
+
)
|
|
1879
|
+
}
|
|
1880
|
+
```
|
|
1881
|
+
|
|
888
1882
|
### ./src/elements/ConfiguratorLayout.tsx
|
|
889
1883
|
|
|
890
1884
|
```tsx
|
|
891
1885
|
import { Box } from '@mui/material'
|
|
1886
|
+
import { useState } from 'react'
|
|
892
1887
|
|
|
893
1888
|
import { LayoutSlots, useSceneSafeArea } from '@salsita-ai/sdk/configurator'
|
|
1889
|
+
import { useActiveViewports } from '@salsita-ai/sdk/react'
|
|
894
1890
|
|
|
895
1891
|
import { phx } from '../../.phoenix/phx.js'
|
|
1892
|
+
import { BottomSheet } from '../_shared/BottomSheet.js'
|
|
896
1893
|
import { FullscreenToggle } from '../_shared/FullscreenToggle.js'
|
|
1894
|
+
import { MessageToast } from '../_shared/MessageToast.js'
|
|
897
1895
|
import { ProductPanel } from '../_shared/ProductPanel.js'
|
|
898
1896
|
|
|
899
1897
|
const GUTTER = 24
|
|
900
1898
|
const PANEL_WIDTH = 380
|
|
1899
|
+
const PHONE_GUTTER = 16
|
|
1900
|
+
const TOUCH_TARGET = 44
|
|
901
1901
|
|
|
902
1902
|
const ConfiguratorLayout = () => {
|
|
903
1903
|
const { containerRef, safeAreaRef } = useSceneSafeArea()
|
|
904
1904
|
const isFullscreen = phx.frontend.useIsFullscreenActive()
|
|
1905
|
+
// `null` until the container has been measured; the layout shows only the scene until then
|
|
1906
|
+
const viewports = useActiveViewports()
|
|
1907
|
+
const [isSheetOpen, setSheetOpen] = useState(false)
|
|
1908
|
+
|
|
1909
|
+
const isDesktop = viewports?.includes('desktop') ?? false
|
|
1910
|
+
const gutter = isDesktop ? GUTTER : PHONE_GUTTER
|
|
905
1911
|
|
|
906
1912
|
return (
|
|
907
|
-
<Box
|
|
1913
|
+
<Box
|
|
1914
|
+
component="div"
|
|
1915
|
+
ref={containerRef}
|
|
1916
|
+
// `clip`, not `hidden`: what overflows, such as the sheet's fill below its edge, can never be scrolled into view,
|
|
1917
|
+
// not even by the browser when the focus moves
|
|
1918
|
+
sx={{ position: 'absolute', inset: 0, display: 'flex', flexDirection: 'column', overflow: 'clip' }}
|
|
1919
|
+
>
|
|
908
1920
|
<LayoutSlots.SharedCanvas />
|
|
909
1921
|
|
|
910
|
-
{!isFullscreen && (
|
|
1922
|
+
{viewports !== null && isDesktop && !isFullscreen && (
|
|
911
1923
|
<Box
|
|
912
1924
|
component="aside"
|
|
913
1925
|
sx={{
|
|
@@ -921,31 +1933,60 @@ const ConfiguratorLayout = () => {
|
|
|
921
1933
|
borderRadius: 5,
|
|
922
1934
|
bgcolor: 'background.paper',
|
|
923
1935
|
boxShadow: '0 12px 40px rgba(0, 0, 0, 0.12)',
|
|
924
|
-
|
|
1936
|
+
// A very short container, such as a phone held sideways, scrolls the panel instead of clipping its footer
|
|
1937
|
+
overflowX: 'hidden',
|
|
1938
|
+
overflowY: 'auto',
|
|
1939
|
+
overscrollBehavior: 'contain',
|
|
925
1940
|
}}
|
|
926
1941
|
>
|
|
927
1942
|
<ProductPanel />
|
|
928
1943
|
</Box>
|
|
929
1944
|
)}
|
|
930
1945
|
|
|
931
|
-
|
|
932
|
-
component="div"
|
|
933
|
-
ref={safeAreaRef}
|
|
934
|
-
sx={{
|
|
935
|
-
position: 'absolute',
|
|
936
|
-
insetBlock: 0,
|
|
937
|
-
insetInlineStart: isFullscreen ? 0 : PANEL_WIDTH + 2 * GUTTER,
|
|
938
|
-
insetInlineEnd: 0,
|
|
939
|
-
pointerEvents: 'none',
|
|
940
|
-
}}
|
|
941
|
-
>
|
|
1946
|
+
{viewports !== null && (
|
|
942
1947
|
<Box
|
|
943
1948
|
component="div"
|
|
944
|
-
|
|
1949
|
+
ref={safeAreaRef}
|
|
1950
|
+
sx={{
|
|
1951
|
+
// Desktop: right of the panel. Phone: above the sheet, whose height the column gives the rest.
|
|
1952
|
+
...(isDesktop
|
|
1953
|
+
? {
|
|
1954
|
+
position: 'absolute',
|
|
1955
|
+
insetBlock: 0,
|
|
1956
|
+
insetInlineStart: isFullscreen ? 0 : PANEL_WIDTH + 2 * GUTTER,
|
|
1957
|
+
insetInlineEnd: 0,
|
|
1958
|
+
}
|
|
1959
|
+
: { position: 'relative', flex: '1 1 0', minBlockSize: 0 }),
|
|
1960
|
+
pointerEvents: 'none',
|
|
1961
|
+
}}
|
|
945
1962
|
>
|
|
946
|
-
<
|
|
1963
|
+
<Box
|
|
1964
|
+
component="div"
|
|
1965
|
+
sx={{ position: 'absolute', insetBlockStart: gutter, insetInlineEnd: gutter, pointerEvents: 'auto' }}
|
|
1966
|
+
>
|
|
1967
|
+
<FullscreenToggle compact={!isDesktop} />
|
|
1968
|
+
</Box>
|
|
1969
|
+
<Box
|
|
1970
|
+
component="div"
|
|
1971
|
+
sx={{
|
|
1972
|
+
position: 'absolute',
|
|
1973
|
+
pointerEvents: 'auto',
|
|
1974
|
+
// Desktop: bottom left. Phone: at the top beside the fullscreen button, clear of the sheet's handle.
|
|
1975
|
+
...(isDesktop
|
|
1976
|
+
? { insetBlockEnd: GUTTER, insetInlineStart: GUTTER }
|
|
1977
|
+
: { insetBlockStart: gutter, insetInline: `${gutter}px ${2 * gutter + TOUCH_TARGET}px` }),
|
|
1978
|
+
}}
|
|
1979
|
+
>
|
|
1980
|
+
<MessageToast />
|
|
1981
|
+
</Box>
|
|
947
1982
|
</Box>
|
|
948
|
-
|
|
1983
|
+
)}
|
|
1984
|
+
|
|
1985
|
+
{viewports !== null && !isDesktop && !isFullscreen && (
|
|
1986
|
+
<BottomSheet open={isSheetOpen} onOpenChange={setSheetOpen} label="Product details">
|
|
1987
|
+
<ProductPanel collapsed={!isSheetOpen} inSheet />
|
|
1988
|
+
</BottomSheet>
|
|
1989
|
+
)}
|
|
949
1990
|
</Box>
|
|
950
1991
|
)
|
|
951
1992
|
}
|
|
@@ -953,6 +1994,68 @@ const ConfiguratorLayout = () => {
|
|
|
953
1994
|
export default phx.frontend.createCustomPhoenixLayoutElement('ConfiguratorLayout', ConfiguratorLayout)
|
|
954
1995
|
```
|
|
955
1996
|
|
|
1997
|
+
### ./src/elements/EdgeFinishHotspot.tsx
|
|
1998
|
+
|
|
1999
|
+
```tsx
|
|
2000
|
+
import { Box, ButtonBase, Popover, Tooltip } from '@mui/material'
|
|
2001
|
+
import { useState } from 'react'
|
|
2002
|
+
|
|
2003
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
2004
|
+
import { EdgeFinishCards } from '../_shared/EdgeFinishCards.js'
|
|
2005
|
+
|
|
2006
|
+
// The edge profile the button shows, the square edge of the cards' drawings
|
|
2007
|
+
const EDGE_ICON = 'M3 7H17L21 11V13L17 17H3Z'
|
|
2008
|
+
|
|
2009
|
+
// Rendered by the spec's `htmlHotspot` on the table's edge: a button on the product that opens the edge finishes
|
|
2010
|
+
// next to the edge, with the same cards as the panel. The spec's `$filter` decides when it is shown.
|
|
2011
|
+
export default phx.frontend.createCustomPhoenixEntityElement('EdgeFinishHotspot', ({ entityId }) => {
|
|
2012
|
+
const edgeFinish = phx.frontend.useAttributeSelection(entityId, 'edgeFinish')
|
|
2013
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null)
|
|
2014
|
+
|
|
2015
|
+
return (
|
|
2016
|
+
<>
|
|
2017
|
+
<Tooltip title="Edge finish">
|
|
2018
|
+
<ButtonBase
|
|
2019
|
+
aria-label="Edge finish"
|
|
2020
|
+
aria-haspopup="dialog"
|
|
2021
|
+
aria-expanded={anchor !== null}
|
|
2022
|
+
onClick={event => setAnchor(event.currentTarget)}
|
|
2023
|
+
sx={{
|
|
2024
|
+
display: 'grid',
|
|
2025
|
+
placeItems: 'center',
|
|
2026
|
+
inlineSize: 44,
|
|
2027
|
+
blockSize: 44,
|
|
2028
|
+
borderRadius: '50%',
|
|
2029
|
+
bgcolor: 'background.paper',
|
|
2030
|
+
color: 'primary.main',
|
|
2031
|
+
boxShadow: '0 4px 16px rgba(0, 0, 0, 0.2)',
|
|
2032
|
+
'&.Mui-focusVisible': { outline: 2, outlineColor: 'primary.main', outlineOffset: 2 },
|
|
2033
|
+
}}
|
|
2034
|
+
>
|
|
2035
|
+
<svg viewBox="0 0 24 24" width={22} height={22} aria-hidden>
|
|
2036
|
+
<path d={EDGE_ICON} fill="currentColor" />
|
|
2037
|
+
</svg>
|
|
2038
|
+
</ButtonBase>
|
|
2039
|
+
</Tooltip>
|
|
2040
|
+
<Popover
|
|
2041
|
+
open={anchor !== null}
|
|
2042
|
+
anchorEl={anchor}
|
|
2043
|
+
onClose={() => setAnchor(null)}
|
|
2044
|
+
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
|
|
2045
|
+
transformOrigin={{ vertical: 'bottom', horizontal: 'center' }}
|
|
2046
|
+
slotProps={{
|
|
2047
|
+
paper: { role: 'dialog', 'aria-label': 'Edge finish', sx: { borderRadius: 4, marginBlockStart: -1 } },
|
|
2048
|
+
}}
|
|
2049
|
+
>
|
|
2050
|
+
<Box component="div" sx={{ inlineSize: 340, maxInlineSize: 'calc(100vw - 32px)', padding: 2 }}>
|
|
2051
|
+
<EdgeFinishCards selection={edgeFinish} />
|
|
2052
|
+
</Box>
|
|
2053
|
+
</Popover>
|
|
2054
|
+
</>
|
|
2055
|
+
)
|
|
2056
|
+
})
|
|
2057
|
+
```
|
|
2058
|
+
|
|
956
2059
|
### ./src/expressions/table.ts
|
|
957
2060
|
|
|
958
2061
|
```ts
|
|
@@ -978,4 +2081,45 @@ export default phx.domain.implementCustomExpressions({
|
|
|
978
2081
|
})
|
|
979
2082
|
```
|
|
980
2083
|
|
|
2084
|
+
### ./src/handlers/request-quote.ts
|
|
2085
|
+
|
|
2086
|
+
```ts
|
|
2087
|
+
import { useCallback } from 'react'
|
|
2088
|
+
|
|
2089
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
2090
|
+
|
|
2091
|
+
// Stands in for the shop's quote service: the request takes a moment, then the panel shows the confirmation
|
|
2092
|
+
export default phx.frontend.createPhoenixHandler('requestQuote', () => {
|
|
2093
|
+
const navigate = phx.frontend.useNavigate()
|
|
2094
|
+
|
|
2095
|
+
return {
|
|
2096
|
+
handler: useCallback(async () => {
|
|
2097
|
+
await new Promise(resolve => setTimeout(resolve, 1500))
|
|
2098
|
+
navigate('requested')
|
|
2099
|
+
}, [navigate]),
|
|
2100
|
+
}
|
|
2101
|
+
})
|
|
2102
|
+
```
|
|
2103
|
+
|
|
2104
|
+
### ./src/transformers/tree-trunk-delivery.ts
|
|
2105
|
+
|
|
2106
|
+
```ts
|
|
2107
|
+
import { msg } from '@lingui/core/macro'
|
|
2108
|
+
|
|
2109
|
+
import { phx } from '../../.phoenix/phx.js'
|
|
2110
|
+
|
|
2111
|
+
// A tree-trunk edge is cut by hand; choosing it carries a hint, which reaches the layout as a side-effect message
|
|
2112
|
+
export default phx.frontend.transformerBuilder.when
|
|
2113
|
+
.entity(['Table'])
|
|
2114
|
+
.modified({ atFields: ['edgeFinish'] })
|
|
2115
|
+
.then.overrideMatchingUpdate(({ update }) => {
|
|
2116
|
+
if (update.stateDelta.edgeFinish !== 'TreeTrunk') {
|
|
2117
|
+
return [update]
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
return [{ ...update, hint: msg`Tree trunk edges are cut by hand, so delivery takes three weeks longer.` }]
|
|
2121
|
+
})
|
|
2122
|
+
.build('tree-trunk-delivery')
|
|
2123
|
+
```
|
|
2124
|
+
|
|
981
2125
|
</details>
|