Skip to content

Commit

Permalink
chore: separate constants in /lib into separate constants files / add…
Browse files Browse the repository at this point in the history
… default storefront api version
  • Loading branch information
jeremyagabriel committed Feb 27, 2025
1 parent 46efaeb commit 8263fc9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 26 deletions.
5 changes: 4 additions & 1 deletion app/components/Document/Document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {PreviewProvider} from '@pack/react';
import {ContextsProvider} from '~/contexts';
import {CART_FRAGMENT} from '~/data/graphql/storefront/cart';
import {Layout} from '~/components/Layout';
import {DEFAULT_STOREFRONT_API_VERSION} from '~/lib/constants';
import {useLocale, useRootLoaderData} from '~/hooks';

import {Favicon} from './Favicon';
Expand Down Expand Up @@ -66,7 +67,9 @@ export function Document({children, title}: DocumentProps) {
<ShopifyProvider
storeDomain={`https://${ENV.PUBLIC_STORE_DOMAIN}`}
storefrontToken={ENV.PUBLIC_STOREFRONT_API_TOKEN}
storefrontApiVersion={ENV.PUBLIC_STOREFRONT_API_VERSION || '2025-01'}
storefrontApiVersion={
ENV.PUBLIC_STOREFRONT_API_VERSION || DEFAULT_STOREFRONT_API_VERSION
}
countryIsoCode={locale.country}
languageIsoCode={locale.language}
>
Expand Down
25 changes: 0 additions & 25 deletions app/lib/constants.ts

This file was deleted.

3 changes: 3 additions & 0 deletions app/lib/constants/collection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const COLOR_OPTION_NAME = 'Color' as const;

export const PRICE_FILTER_ID = 'filter.v.price' as const;
4 changes: 4 additions & 0 deletions app/lib/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './collection';
export * from './navigation';
export * from './product';
export * from './store';
3 changes: 3 additions & 0 deletions app/lib/constants/navigation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const PROMOBAR_HEIGHT_MOBILE = 48; /* Ensure this number (px) is equivalent to --promobar-height-mobile in app.css */

export const PROMOBAR_HEIGHT_DESKTOP = 48; /* Ensure this number (px) equivalent to --promobar-height-desktop in app.css */
5 changes: 5 additions & 0 deletions app/lib/constants/product.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type {AspectRatio} from '../types';

/* Ensure updating this ratio as needed. Required format is 'width/height' */
export const PRODUCT_IMAGE_ASPECT_RATIO: AspectRatio =
'3/4'; /* Ensure this is equivalent to product-image-aspect-ratio in app.css */
15 changes: 15 additions & 0 deletions app/lib/constants/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type {I18nLocale} from '../types';

export const DEFAULT_STOREFRONT_API_VERSION = '2025-01';

export const DEFAULT_LOCALE: I18nLocale = Object.freeze({
label: 'United States (USD $)',
language: 'EN',
country: 'US',
currency: 'USD',
pathPrefix: '',
});

export const LOGGED_OUT_REDIRECT_TO = '/account/login' as const;

export const LOGGED_IN_REDIRECT_TO = '/account/orders' as const;

0 comments on commit 8263fc9

Please sign in to comment.