Skip to content

Commit

Permalink
Merge branch 'Weaverse:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-phan authored Aug 14, 2024
2 parents c0fbafa + 554a8b8 commit 7ccd7ef
Show file tree
Hide file tree
Showing 61 changed files with 667 additions and 922 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ WEAVERSE_PROJECT_ID=clptu3l4p001sxfsn1u9jzqnm
# Additional services
#PUBLIC_GOOGLE_GTM_ID=G-R1KFYYKE48
#JUDGEME_PRIVATE_API_TOKEN="your-judgeme-private-api-token"

#ALI_REVIEWS_API_KEY="your-ali-reviews-api-key"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @weaverse/pilot

## 2.7.8

### Patch Changes

- Updated dependencies
- @weaverse/hydrogen@3.4.0

## 2.6.8

### Patch Changes
Expand Down
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,32 @@ export async function loader(args: RouteLoaderArgs) {

`weaverse` is an `WeaverseClient` instance that has been injected into the app context by Weaverse. It provides a set of methods to interact with the Weaverse API.

```ts:server.ts
let handleRequest = createRequestHandler({
build: remixBuild,
mode: process.env.NODE_ENV,
getLoadContext: () => ({
// App context props
weaverse: createWeaverseClient({
storefront,
```ts:app/lib/context.ts
// app/lib/context.ts

const hydrogenContext = createHydrogenContext({
env,
request,
cache,
waitUntil,
session,
i18n: getLocaleFromRequest(request),
cart: {
queryFragment: CART_QUERY_FRAGMENT,
},
});

return {
...hydrogenContext,
// declare additional Remix loader context
weaverse: new WeaverseClient({
...hydrogenContext,
request,
env,
cache,
waitUntil,
themeSchema,
components,
}),
}),
});
};
```

### Rendering page content
Expand Down Expand Up @@ -252,11 +263,11 @@ Just export a `loader` function from your component:
```tsx:app/weaverse/sections/Video.tsx
import type {ComponentLoaderArgs} from '@weaverse/hydrogen';

export let loader = async ({context, itemData}: ComponentLoaderArgs) => {
let {data} = await context.storefront.query<SeoCollectionContentQuery>(
export let loader = async ({weaverse, data}: ComponentLoaderArgs) => {
let {data} = await weaverse.storefront.query<SeoCollectionContentQuery>(
HOMEPAGE_SEO_QUERY,
{
variables: {handle: itemData.data.collectionHandle || 'frontpage'},
variables: {handle: data.collection.handle || 'frontpage'},
},
);
return data;
Expand Down
84 changes: 38 additions & 46 deletions app/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,44 @@ let variants = cva(
variant: {
primary: [
"border px-4 py-3",
"text-[var(--color-button-text,var(--button-primary-color))]",
"bg-[var(--color-button-bg,var(--button-primary-bg))]",
"border-[var(--color-button-border,var(--button-primary-border))]",
"hover:bg-[var(--color-button-bg-hover,var(--button-primary-bg-hover))]",
"hover:text-[var(--color-button-text-hover,var(--button-primary-color-hover))]",
"hover:border-[var(--color-button-border-hover,var(--button-primary-border-hover))]",
"text-[var(--color-button-primary-text)]",
"bg-[var(--color-button-primary-bg)]",
"border-[var(--color-button-primary-bg)]",
"hover:bg-[var(--color-button-primary-text)]",
"hover:text-[var(--color-button-primary-bg)]",
"hover:border-[var(--color-button-primary-text)]",
],
secondary: [
"border px-4 py-3",
"text-[var(--color-button-text,var(--button-secondary-color))]",
"bg-[var(--color-button-bg,var(--button-secondary-bg))]",
"border-[var(--color-button-border,var(--button-secondary-border))]",
"hover:bg-[var(--color-button-bg-hover,var(--button-secondary-bg-hover))]",
"hover:text-[var(--color-button-text-hover,var(--button-secondary-color-hover))]",
"hover:border-[var(--color-button-border-hover,var(--button-secondary-border-hover))]",
"text-[var(--color-button-secondary-text)]",
"bg-[var(--color-button-secondary-bg)]",
"border-[var(--color-button-secondary-bg)]",
"hover:bg-[var(--color-button-secondary-text)]",
"hover:text-[var(--color-button-secondary-bg)]",
"hover:border-[var(--color-button-secondary-text)]",
],
outline: [
"border px-4 py-3",
"text-[var(--color-button-text,var(--button-outline-color))]",
"bg-[var(--color-button-bg,var(--button-outline-bg))]",
"border-[var(--color-button-border,var(--button-outline-border))]",
"hover:bg-[var(--color-button-bg-hover,var(--button-outline-bg-hover))]",
"hover:text-[var(--color-button-text-hover,var(--button-outline-color-hover))]",
"hover:border-[var(--color-button-border-hover,var(--button-outline-border-hover))]",
"text-[var(--color-button-outline-text-and-border)]",
"bg-transparent",
"border-[var(--color-button-outline-text-and-border)]",
"hover:bg-[var(--color-button-outline-text-and-border)]",
"hover:text-[var(--color-text)]",
"hover:border-[var(--color-button-outline-text-and-border)]",
],
custom: [
"border px-4 py-3",
"text-[var(--color-button-text)]",
"bg-[var(--color-button-bg)]",
"border-[var(--color-button-border)]",
"hover:bg-[var(--color-button-bg-hover)]",
"hover:text-[var(--color-button-text-hover)]",
"hover:border-[var(--color-button-border-hover)]",
],
link: [
"bg-transparent py-2 border-b",
"text-[var(--color-button-text,var(--button-link-color))]",
"border-b-[var(--color-button-border,var(--button-link-color))]",
"hover:text-[var(--color-button-text-hover,var(--button-link-color-hover))]",
"hover:border-[var(--color-button-border-hover,var(--button-link-color-hover))]",
"text-[var(--color-text)]",
"border-b-[var(--color-text)]",
],
},
},
Expand All @@ -64,7 +71,6 @@ let variants = cva(
);

export interface ButtonStyleProps {
buttonStyle: "inherit" | "custom";
backgroundColor: string;
textColor: string;
borderColor: string;
Expand Down Expand Up @@ -97,7 +103,6 @@ let Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
loading,
openInNewTab,
className,
buttonStyle,
backgroundColor,
textColor,
borderColor,
Expand All @@ -108,7 +113,7 @@ let Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
children,
...rest
} = props;
if (buttonStyle === "custom") {
if (variant === "custom") {
style = {
...style,
"--color-button-bg": backgroundColor,
Expand Down Expand Up @@ -209,75 +214,62 @@ export let buttonContentInputs: InspectorGroup["inputs"] = [
{ label: "Secondary", value: "secondary" },
{ label: "Outline", value: "outline" },
{ label: "Link", value: "link" },
{ label: "Custom styles", value: "custom" },
],
},
defaultValue: "primary",
},
];
export let buttonStylesInputs: InspectorGroup["inputs"] = [
{
type: "select",
name: "buttonStyle",
label: "Button style",
configs: {
options: [
{ label: "Inherit", value: "inherit" },
{ label: "Custom", value: "custom" },
],
},
defaultValue: "inherit",
helpText:
"Use 'Inherit' for theme-based styles, or 'Custom' to modify button appearance.",
},
{
type: "color",
label: "Background color",
name: "backgroundColor",
defaultValue: "#000",
condition: "buttonStyle.eq.custom",
condition: "variant.eq.custom",
},
{
type: "color",
label: "Text color",
name: "textColor",
defaultValue: "#fff",
condition: "buttonStyle.eq.custom",
condition: "variant.eq.custom",
},
{
type: "color",
label: "Border color",
name: "borderColor",
defaultValue: "#00000000",
condition: "buttonStyle.eq.custom",
condition: "variant.eq.custom",
},
{
type: "color",
label: "Background color (hover)",
name: "backgroundColorHover",
defaultValue: "#00000000",
condition: "buttonStyle.eq.custom",
condition: "variant.eq.custom",
},
{
type: "color",
label: "Text color (hover)",
name: "textColorHover",
defaultValue: "#000",
condition: "buttonStyle.eq.custom",
condition: "variant.eq.custom",
},
{
type: "color",
label: "Border color (hover)",
name: "borderColorHover",
defaultValue: "#000",
condition: "buttonStyle.eq.custom",
condition: "variant.eq.custom",
},
];

export let buttonInputs: InspectorGroup["inputs"] = [
...buttonContentInputs,
{
type: "heading",
label: "Button styles",
label: "Button custom styles",
},
...buttonStylesInputs,
];
Expand Down
2 changes: 1 addition & 1 deletion app/components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer w-5 h-5 shrink-0 border ring-offset-background focus-visible:outline-none focus-visible:ring focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
"peer w-5 h-5 shrink-0 border ring-offset-background focus-visible:outline-none focus-visible:ring focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-background data-[state=checked]:text-body",
)}
{...props}
>
Expand Down
10 changes: 8 additions & 2 deletions app/components/Marquee.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { CSSProperties, useCallback, useEffect, useRef, useState } from "react";
import {
type CSSProperties,
useCallback,
useEffect,
useRef,
useState,
} from "react";

interface MarqueeProps {
children: React.ReactNode;
Expand Down Expand Up @@ -27,7 +33,7 @@ export function Marquee({
style={
{
"--animation-speed": `${animationTime}s`,
"--gap": `${gap}s`,
"--gap": `${gap}px`,
} as CSSProperties
}
>
Expand Down
2 changes: 1 addition & 1 deletion app/components/predictive-search/PredictiveSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PredictiveSearchForm } from "./SearchForm";
export function PredictiveSearch(props: { isOpen?: boolean }) {
let { isOpen } = props;
return (
<div className="relative border-t border-bar-subtle">
<div className="relative border-t border-line">
<PredictiveSearchForm>
{({ fetchResults, inputRef }) => (
<div className="mx-auto w-full max-w-[560px] p-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function PredictiveSearchResult({

return (
<div
className="predictive-search-result flex flex-col gap-4 divide-y divide-bar-subtle"
className="predictive-search-result flex flex-col gap-4 divide-y divide-line"
key={type}
>
<Link
Expand Down
4 changes: 2 additions & 2 deletions app/components/predictive-search/PredictiveSearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function PredictiveSearchResults() {
<div className="absolute left-1/2 top-20 z-10 flex w-fit -translate-x-1/2 items-center justify-center">
<div className="grid w-screen min-w-[430px] max-w-[720px] grid-cols-1 gap-6 border bg-white p-6 lg:grid-cols-[1fr_2fr] max-h-[80vh] overflow-y-auto">
<div className="space-y-8">
<div className="flex flex-col gap-4 divide-y divide-bar-subtle">
<div className="flex flex-col gap-4 divide-y divide-line">
<PredictiveSearchResult
goToSearchResult={goToSearchResult}
items={queries?.items}
Expand Down Expand Up @@ -82,7 +82,7 @@ function NoPredictiveSearchResults({
return null;
}
return (
<p className="w-[640px] border bg-primary p-6">
<p className="w-[640px] border bg-background p-6">
No results found for <q>{searchTerm.current}</q>
</p>
);
Expand Down
4 changes: 2 additions & 2 deletions app/components/predictive-search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type UseSearchReturn = NormalizedPredictiveSearch & {
searchTerm: React.MutableRefObject<string>;
};

type PredicticeSearchResultItemImage =
type PredictiveSearchResultItemImage =
| PredictiveCollectionFragment["image"]
| PredictiveArticleFragment["image"]
| PredictiveProductFragment["featuredImage"];
Expand All @@ -35,7 +35,7 @@ export type NormalizedPredictiveSearchResultItem = {
__typename: string | undefined;
handle: string;
id: string;
image?: PredicticeSearchResultItemImage;
image?: PredictiveSearchResultItemImage;
price?: PredictiveSearchResultItemPrice;
compareAtPrice?: PredictiveSearchResultItemPrice;
styledTitle?: string;
Expand Down
18 changes: 10 additions & 8 deletions app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { RemixBrowser } from "@remix-run/react";
import { StrictMode, startTransition } from "react";
import { hydrateRoot } from "react-dom/client";

startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>,
);
});
if (!window.location.origin.includes("webcache.googleusercontent.com")) {
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>,
);
});
}
2 changes: 1 addition & 1 deletion app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { AppLoadContext, EntryContext } from "@shopify/remix-oxygen";
import { isbot } from "isbot";
import { renderToReadableStream } from "react-dom/server";

import { getWeaverseCsp } from "~/weaverse/create-weaverse.server";
import { getWeaverseCsp } from "~/weaverse/csp";

export default async function handleRequest(
request: Request,
Expand Down
Loading

0 comments on commit 7ccd7ef

Please sign in to comment.