StoreClosedNotification
A red, dismissible bar on product pages saying the store is closed for orders and when it opens; the engine shows it automatically.
import { StoreClosedNotification, LazyStoreClosedNotification, StoreClosedNotificationProps } from '@salla.sa/twilight-theme-engine/store';In plain words
When a merchant sets opening hours and the store is closed right now, shoppers on a product page see a red bar: "the store is closed for orders and opens at …". The shopper can close it.
You do not need to add it: the engine already places it at the top of every page and it decides for itself whether to show. LazyStoreClosedNotification is the same component, loaded only when it first renders.
Signature
function StoreClosedNotification(props: StoreClosedNotificationProps): JSX.Element | null
const LazyStoreClosedNotification: React.LazyExoticComponent<typeof StoreClosedNotification>
interface StoreClosedNotificationProps {
show?: boolean; // accepted and ignored
}Try it live
- ✗ this page is a product page (useIsProduct)
- ✗ store.settings.opening_hours.enabled
- ✗ the store is closed right now
- ✗ a next opening time: ""
import { Suspense } from 'react';
import { LazyStoreClosedNotification } from '@salla.sa/twilight-theme-engine/store';
// TwilightProvider already renders it at body:start when opening hours are enabled.
// Render your own only after removing that default with hookRegistry.clear('body:start'),
// which also removes the GTM and Sift handlers.
export function ClosedBar() {
return (
<Suspense fallback={null}>
<LazyStoreClosedNotification />
</Suspense>
);
}
Example
import { Suspense } from 'react';
import { LazyStoreClosedNotification } from '@salla.sa/twilight-theme-engine/store';
// Only if you removed the engine's default with hookRegistry.clear('body:start'),
// which also removes the GTM and Sift handlers.
export function ClosedBar() {
return (
<Suspense fallback={null}>
<LazyStoreClosedNotification />
</Suspense>
);
}
How it behaves
It shows only when all hold: the current route is the product page (
useIsProduct()),useOpeningHours(store.settings.opening_hours)reportsisEnabled, notisOpen, and a non-emptynextOpenFormatted, and the shopper has not closed it.The default
body:starthandler renders the lazy version whenstore.settings.opening_hours.enabled(priority 80, after GTM and Sift).TwilightProviderrenders that slot on every page.Text: the translation
store.closed_notificationwith anextOpenvariable, defaulting to an Arabic sentence. Styles are inline (background#d63031).
Gotchas
showdoes nothing: the component ignores its props. Control it by where you render it.Dismissing is component state, not stored: it comes back after a remount or a full reload.
opening_hoursis not in this demo store's settings, and theStoreSettingstype marks it "TODO: add to API response", so the bar may never appear with real data today.