Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #54

Merged
merged 15 commits into from
Nov 24, 2023
Merged

Dev #54

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
SESSION_SECRET="super-secret"
PUBLIC_STORE_DOMAIN="mock.shop"
#PUBLIC_STOREFRONT_API_TOKEN="your-public-storefront-api-token"
#WEAVERSE_PROJECT_ID="your-weaverse-project-id"
#WEAVERSE_API_KEY="your-weaverse-api-key"
#PRIVATE_STOREFRONT_API_TOKEN="your-private-storefront-api-token"
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @type {import('@types/eslint').Linter.BaseConfig}
* @type {import("@types/eslint").Linter.BaseConfig}
*/
module.exports = {
extends: [
Expand Down
15 changes: 0 additions & 15 deletions app/components/Container.tsx

This file was deleted.

12 changes: 12 additions & 0 deletions app/components/Heading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {clsx} from 'clsx';

type HeadingProps = {
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
children: React.ReactNode | string;
className?: string;
};

export function Heading(props: HeadingProps) {
let {as: Tag = 'h1', children, className} = props;
return <Tag className={clsx('font-medium', className)}>{children}</Tag>;
}
3 changes: 2 additions & 1 deletion app/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ function DesktopHeader({
className={clsx(
'bg-primary text-body',
y > 50 && ' shadow-header',
'hidden h-nav lg:flex items-center sticky transition duration-300 backdrop-blur-lg z-40 top-0 justify-between w-full leading-none gap-8 px-12 py-4',
'hidden h-nav lg:flex items-center sticky transition duration-300 backdrop-blur-lg z-40 top-0 justify-between leading-none gap-8',
'w-full px-6 md:px-8 lg:px-12 py-4',
)}
>
<div className="flex gap-12">
Expand Down
17 changes: 15 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ export const links: LinksFunction = () => {
href: 'https://shop.app',
},
{rel: 'icon', type: 'image/svg+xml', href: favicon},
{
rel: 'preconnect',
href: 'https://fonts.googleapis.com',
},
{
href: 'https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap',
rel: 'preload',
as: 'style',
},
{
href: 'https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap',
rel: 'stylesheet',
},
];
};

Expand Down Expand Up @@ -155,7 +168,7 @@ const ErrorBoundaryComponent = ({error}: {error: Error}) => {
<Meta />
<Links />
</head>
<body>
<body className="font-sans">
<Layout
layout={rootData?.layout}
key={`${locale.language}-${locale.country}`}
Expand All @@ -182,7 +195,7 @@ const ErrorBoundaryComponent = ({error}: {error: Error}) => {
);
};

export const ErrorBoundary = withWeaverse(ErrorBoundaryComponent);
export const ErrorBoundary = ErrorBoundaryComponent;

const LAYOUT_QUERY = `#graphql
query layout(
Expand Down
27 changes: 13 additions & 14 deletions app/routes/($locale).account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,40 @@ import {
useMatches,
useOutlet,
} from '@remix-run/react';
import {Suspense} from 'react';
import {flattenConnection} from '@shopify/hydrogen';
import {
json,
defer,
json,
redirect,
type LoaderFunctionArgs,
type AppLoadContext,
type LoaderFunctionArgs,
} from '@shopify/remix-oxygen';
import {flattenConnection} from '@shopify/hydrogen';
import {Suspense} from 'react';

import type {
CustomerDetailsFragment,
OrderCardFragment,
} from 'storefrontapi.generated';
import {
AccountAddressBook,
AccountDetails,
Button,
Modal,
OrderCard,
PageHeader,
Text,
AccountDetails,
AccountAddressBook,
Modal,
ProductSwimlane,
Text,
} from '~/components';
import {FeaturedCollections} from '~/components/FeaturedCollections';
import {usePrefixPathWithLocale} from '~/lib/utils';
import {CACHE_NONE, routeHeaders} from '~/data/cache';
import {ORDER_CARD_FRAGMENT} from '~/components/OrderCard';
import {CACHE_NONE, routeHeaders} from '~/data/cache';
import {usePrefixPathWithLocale} from '~/lib/utils';

import {doLogout} from './($locale).account.logout';
import {
getFeaturedData,
type FeaturedData,
} from './($locale).featured-products';
import {doLogout} from './($locale).account.logout';
import {Container} from '~/components/Container';

// Combining json + defer in a loader breaks the
// types returned by useLoaderData. This is a temporary fix.
Expand Down Expand Up @@ -133,7 +132,7 @@ function Account({customer, heading, featuredData}: AccountType) {
const addresses = flattenConnection(customer.addresses);

return (
<Container>
<div className="container mx-auto px-4 max-w-screen-xl">
<PageHeader heading={heading}>
<Form method="post" action={usePrefixPathWithLocale('/account/logout')}>
<button type="submit" className="text-body/50">
Expand Down Expand Up @@ -162,7 +161,7 @@ function Account({customer, heading, featuredData}: AccountType) {
</Await>
</Suspense>
)}
</Container>
</div>
);
}

Expand Down
8 changes: 4 additions & 4 deletions app/routes/($locale).blogs.$blogHandle.$articleHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import {routeHeaders} from '~/data/cache';
import {ARTICLE_QUERY} from '~/data/queries';
import {seoPayload} from '~/lib/seo.server';
import {WeaverseContent} from '~/weaverse';
import styles from '../styles/custom-font.css';
// import styles from '../styles/custom-font.css';

export const headers = routeHeaders;

export const links: LinksFunction = () => {
return [{rel: 'stylesheet', href: styles}];
};
// export const links: LinksFunction = () => {
// return [{rel: 'stylesheet', href: styles}];
// };

export async function loader(args: RouteLoaderArgs) {
let {request, params, context} = args;
Expand Down
77 changes: 49 additions & 28 deletions app/sections/collection-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import type {
HydrogenComponentProps,
HydrogenComponentSchema,
} from '@weaverse/hydrogen';
import { forwardRef } from 'react';
import { useLoaderData } from '@remix-run/react';
import { CollectionDetailsQuery } from 'storefrontapi.generated';
import { CSSProperties } from 'react';
import {forwardRef} from 'react';
import {useLoaderData} from '@remix-run/react';
import {CollectionDetailsQuery} from 'storefrontapi.generated';
import {CSSProperties} from 'react';
import clsx from 'clsx';

interface HeaderProps extends HydrogenComponentProps {
Expand All @@ -18,15 +18,23 @@ interface HeaderProps extends HydrogenComponentProps {
}

let CollectHeader = forwardRef<HTMLElement, HeaderProps>((props, ref) => {
let { sectionHeightDesktop, sectionHeightMobile, enableBackground, overlayOpacity, enableOverlay, contentPosition, ...rest } = props;
let { collection } = useLoaderData<
let {
sectionHeightDesktop,
sectionHeightMobile,
enableBackground,
overlayOpacity,
enableOverlay,
contentPosition,
...rest
} = props;
let {collection} = useLoaderData<
CollectionDetailsQuery & {
collections: Array<{ handle: string; title: string }>;
collections: Array<{handle: string; title: string}>;
}
>();
let backgroundStyle: CSSProperties = {
'--header-height-desktop': `${sectionHeightDesktop}px`,
'--header-height-mobile': `${sectionHeightMobile}px`
'--header-height-mobile': `${sectionHeightMobile}px`,
} as CSSProperties;

if (enableBackground) {
Expand All @@ -38,7 +46,7 @@ let CollectHeader = forwardRef<HTMLElement, HeaderProps>((props, ref) => {
'--overlay-opacity': `${overlayOpacity}`,
} as CSSProperties;
}
let positionClass: {[key: string]: string} = {
let positionClass: {[key: string]: string} = {
'top left': 'items-start justify-start',
'top right': 'items-start justify-end',
'top center': 'items-start justify-center',
Expand All @@ -50,20 +58,30 @@ let CollectHeader = forwardRef<HTMLElement, HeaderProps>((props, ref) => {
'bottom right': 'items-end justify-end',
};
return (
<section ref={ref} {...rest} style={backgroundStyle} className={clsx(
'flex relative overflow-hidden bg-center bg-no-repeat bg-cover h-[var(--header-height-mobile)] sm:h-[var(--header-height-desktop)]',
positionClass[contentPosition]
)}>
{enableOverlay && enableBackground && <div className="absolute inset-0 z-1 bg-black bg-opacity-[var(--overlay-opacity)]" style={overlayStyle}></div>}
<div className={clsx(
'text-center w-5/6 text-gray-700 z-2 relative',
enableBackground ? 'text-white' : 'text-gray-700',
)}>
<h1 className='text-4xl tracking-tight font-worksans font-normal leading-tight md:text-5xl'>
{collection?.title}
</h1>
<section
ref={ref}
{...rest}
style={backgroundStyle}
className={clsx(
'flex relative overflow-hidden bg-center bg-no-repeat bg-cover h-[var(--header-height-mobile)] sm:h-[var(--header-height-desktop)]',
positionClass[contentPosition],
)}
>
{enableOverlay && enableBackground && (
<div
className="absolute inset-0 z-1 bg-black bg-opacity-[var(--overlay-opacity)]"
style={overlayStyle}
></div>
)}
<div
className={clsx(
'text-center w-5/6 text-gray-700 z-2 relative',
enableBackground ? 'text-white' : 'text-gray-700',
)}
>
<h3 className="leading-tight font-medium">{collection?.title}</h3>
{collection?.description && (
<p className="mt-4 dark:text-gray-400 font-worksans text-base md:text-sm">
<p className="mt-4 dark:text-gray-400 text-base md:text-sm">
{collection.description}
</p>
)}
Expand All @@ -78,6 +96,9 @@ export let schema: HydrogenComponentSchema = {
type: 'collection-header',
title: 'Collection header',
toolbar: ['general-settings', ['duplicate', 'delete']],
enabledOn: {
pages: ['COLLECTION'],
},
inspector: [
{
group: 'Header',
Expand All @@ -96,7 +117,7 @@ export let schema: HydrogenComponentSchema = {
configs: {
min: 350,
max: 550,
step: 10
step: 10,
},
},
{
Expand All @@ -107,7 +128,7 @@ export let schema: HydrogenComponentSchema = {
configs: {
min: 350,
max: 550,
step: 10
step: 10,
},
},
{
Expand All @@ -124,16 +145,16 @@ export let schema: HydrogenComponentSchema = {
configs: {
min: 0.1,
max: 1,
step: 0.1
step: 0.1,
},
condition: `enableOverlay.eq.true`
condition: `enableOverlay.eq.true`,
},
{
type: 'position',
name: 'contentPosition',
label: 'Content position',
defaultValue: 'center center'
}
defaultValue: 'center center',
},
],
},
],
Expand Down
49 changes: 49 additions & 0 deletions app/sections/count-down/heading-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type {
HydrogenComponentProps,
HydrogenComponentSchema,
} from '@weaverse/hydrogen';
import { forwardRef, CSSProperties } from 'react';


interface CountDownHeadingProps extends HydrogenComponentProps {
heading: string;
textColor: string;
}

let CountDownHeading = forwardRef<HTMLDivElement, CountDownHeadingProps>((props, ref) => {
let { heading, textColor, ...rest } = props;
let headingStyle: CSSProperties = {
'--heading-text-color': textColor,
} as CSSProperties;
return (
<div ref={ref} {...rest} style={headingStyle}>
{heading && <h3 className='font-medium text-[var(--heading-text-color)]'>{heading}</h3>}
</div>
);
});

export default CountDownHeading;

export let schema: HydrogenComponentSchema = {
type: 'count-down--heading',
title: 'Heading',
inspector: [
{
group: 'Heading',
inputs: [
{
type: 'text',
name: 'heading',
label: 'Heading',
defaultValue: 'Countdown heading',
},
{
type: 'color',
name: 'textColor',
label: 'Color',
defaultValue: '#000000',
}
],
},
],
};
Loading