Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ui:
 Added "textTransform: 'uppercase'" to Typography plugin for h1,2,3
cmmc:
 moved context to a dir at the top level
CommerceContextValue now has the Service, and a CommerceUI store
new useCommerceUI to access store
  • Loading branch information
artemis-prime committed Apr 20, 2024
1 parent fa83fc1 commit bdaa0f3
Show file tree
Hide file tree
Showing 21 changed files with 7,410 additions and 5,709 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"clean:all": "rm -rf node_modules && pnpm -r clean"
},
"packageManager": "pnpm@8.14.1",
"packageManager": "pnpm@9.0.4",
"dependencies": {
"husky": "^8.0.3"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hanzo/auth",
"version": "2.4.4",
"version": "2.4.5",
"description": "Library with Firebase authentication.",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down Expand Up @@ -31,7 +31,7 @@
"firebase-admin": "^12.0.0"
},
"peerDependencies": {
"@hanzo/ui": "^3.6.3",
"@hanzo/ui": "^3.6.4",
"@hookform/resolvers": "^3.3.4",
"firebase": "^10.8.0",
"lucide-react": "^0.344.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/components/buy/buy-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
CategoryNode,
} from '../../types'

import { useCommerce } from '../../service/context'
import { useCommerce } from '../../context'
import * as pathUtils from '../../service/path-utils'
import { getFacetValuesMutator, ObsStringMutator } from '../../util'

Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/components/buy/carousel-buy-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import type {
MultiFamilySelectorOptions,
} from '../../types'

import { useCommerce } from '../../service/context'
import { useCommerce } from '../../context'
import { getSelectionUISpecifier } from '../../util'

import { CarouselItemSelector, ButtonItemSelector } from '../item-selector'
Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/components/cart/cart-accordian.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@hanzo/ui/primitives'

import { formatCurrencyValue } from '../../util'
import { useCommerce } from '../../service/context'
import { useCommerce } from '../../context'

import CartPanel from './cart-panel'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Image } from '@hanzo/ui/primitives'
import type { LineItem } from '../../../types'
import { formatCurrencyValue } from '../../../util'
import AddToCartWidget from '../../buy/add-to-cart-widget'
import { useCommerce } from '../../../service/context'
import { useCommerce } from '../../../context'

const DEF_IMG_SIZE=40

Expand Down
2 changes: 1 addition & 1 deletion packages/commerce/components/cart/cart-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { observer } from 'mobx-react-lite'
import { Button, ScrollArea } from '@hanzo/ui/primitives'
import { cn } from '@hanzo/ui/util'

import { useCommerce } from '../../../service/context'
import { useCommerce } from '../../../context'
import { formatCurrencyValue } from '../../../util'
import { sendFBEvent, sendGAEvent } from '../../../util/analytics'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { observer } from 'mobx-react-lite'

import { Button, Form, FormControl, FormField, FormItem, Input } from '@hanzo/ui/primitives'

import { useCommerce } from '../../../service/context'
import { useCommerce } from '../../../context'
import type { Promo } from '../../../types'
import getPromoFromApi from '../../../util/promo-codes'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useForm } from 'react-hook-form'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@hanzo/ui/primitives'
import { useAuth } from '@hanzo/auth/service'

import { useCommerce } from '../../../service/context'
import { useCommerce } from '../../../context'
import { sendFBEvent, sendGAEvent } from '../../../util/analytics'
import type { CheckoutStepComponentProps, TransactionStatus } from '../../../types'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

import { cn } from '@hanzo/ui/util'

import { useCommerce } from '../../../../service/context'
import { useCommerce } from '../../../../context'
import { processSquareCardPayment } from '../../../../util'
import type { PaymentMethodComponentProps } from '../../../../types'
import { sendFBEvent, sendGAEvent } from '../../../../util/analytics'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from '@hanzo/ui/primitives'

import Eth from '../crypto-icons/eth'
import { useCommerce } from '../../../../service/context'
import { useCommerce } from '../../../../context'
import type { PaymentMethodComponentProps } from '../../../../types'
import { sendFBEvent, sendGAEvent } from '../../../../util/analytics'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SelectValue
} from '@hanzo/ui/primitives'

import { useCommerce } from '../../service/context'
import { useCommerce } from '../../context'

import countries from '../../util/countries'
import { sendGAEvent } from '../../util/analytics'
Expand Down
61 changes: 61 additions & 0 deletions packages/commerce/context/commerce-ui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {
action,
computed,
makeObservable,
observable,
} from 'mobx'

interface CommerceUI {
showBuyOptions: (skuPath: string) => void
hideBuyOptions: () => void

get buyOptionsShowing(): boolean

get skuPath(): string | undefined
clearSkuPath: () => void
}

class CommerceUIStore implements CommerceUI {

_skuPath: string | undefined = undefined
_optionsShowing: boolean = false

constructor() {
makeObservable(this, {
_skuPath: observable,
_optionsShowing: observable,
showBuyOptions: action,
hideBuyOptions: action,
buyOptionsShowing: computed,
skuPath: computed,
clearSkuPath: action
})
}

showBuyOptions = (skuPath: string): void => {
this._skuPath = skuPath
this._optionsShowing = true
}

hideBuyOptions = (): void => {
this._optionsShowing = false
}

get buyOptionsShowing(): boolean {
return this._optionsShowing
}

get skuPath(): string | undefined {
return this._skuPath
}

clearSkuPath = (): void => {
this._skuPath = undefined
this._optionsShowing = false
}
}

export {
CommerceUIStore,
type CommerceUI
}
63 changes: 63 additions & 0 deletions packages/commerce/context/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use client'
import React, {
createContext,
useContext,
useRef,
type PropsWithChildren
} from 'react'

// https://dev.to/ivandotv/mobx-server-side-rendering-with-next-js-4m18
import { enableStaticRendering } from 'mobx-react-lite'
enableStaticRendering(typeof window === "undefined")

import type { ServiceOptions } from '..'
import type CommerceService from '../types/commerce-service'
import getInstance from '../service/get-instance'
import type { Family, CategoryNode, SelectionUISpecifier } from '../types'
import { type CommerceUI, CommerceUIStore } from './commerce-ui'

type CommerceContextValue = {
service: CommerceService
ui: CommerceUI
}

const CommerceContext = createContext<CommerceContextValue | undefined>(undefined)

const useCommerce = (): CommerceService => {
return (useContext(CommerceContext) as CommerceContextValue)?.service
}

const useCommerceUI = (): CommerceUI => {
return (useContext(CommerceContext) as CommerceContextValue)?.ui
}

const CommerceProvider: React.FC<PropsWithChildren & {
families: Family[]
rootNode: CategoryNode
options?: ServiceOptions
uiSpecs?: Record<string, SelectionUISpecifier>
}> = ({
children,
families,
rootNode,
options,
uiSpecs
}) => {

// TODO: Inject Promo fixture here from siteDef
const serviceRef = useRef<CommerceContextValue>({
service: getInstance(families, rootNode, options, uiSpecs),
ui: new CommerceUIStore()
})
return (
<CommerceContext.Provider value={serviceRef.current}>
{children}
</CommerceContext.Provider>
)
}

export {
useCommerce,
useCommerceUI,
CommerceProvider
}
2 changes: 1 addition & 1 deletion packages/commerce/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './service/context'
export * from './context'
export * from './components'
export type { StandaloneServiceOptions as ServiceOptions } from './service/impls/standalone/standalone-service'
export {
Expand Down
6 changes: 3 additions & 3 deletions packages/commerce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hanzo/commerce",
"version": "6.4.4",
"version": "6.4.6",
"description": "e-commerce framework.",
"type": "module",
"publishConfig": {
Expand Down Expand Up @@ -40,8 +40,8 @@
"square": "^35.0.0"
},
"peerDependencies": {
"@hanzo/auth": "^2.4.4",
"@hanzo/ui": "^3.6.3",
"@hanzo/auth": "^2.4.5",
"@hanzo/ui": "^3.6.4",
"@hookform/resolvers": "^3.3.4",
"@radix-ui/react-radio-group": "^1.1.3",
"firebase": "^10.8.0",
Expand Down
44 changes: 0 additions & 44 deletions packages/commerce/service/context.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
parseAsBoolean,
} from 'next-usequerystate'

import { useCommerce } from '../service/context'
import { useCommerce } from '../context'
import type { SelectedPaths } from '../types'
import sep from '../service/sep'

Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hanzo/ui",
"version": "3.6.3",
"version": "3.6.4",
"description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
9 changes: 6 additions & 3 deletions packages/ui/tailwind/typo-plugin/get-plugin-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,20 @@ const defaultCSS = {
h1: {
color: 'var(--tw-typo-plugin-headings)',
fontWeight: '800',
textAlign: 'inherit'
textAlign: 'inherit',
textTransform: 'uppercase'
},
h2: {
color: 'var(--tw-typo-plugin-headings)',
fontWeight: '700',
textAlign: 'inherit'
textAlign: 'inherit',
textTransform: 'uppercase'
},
h3: {
color: 'var(--tw-typo-plugin-headings)',
fontWeight: '600',
textAlign: 'inherit'
textAlign: 'inherit',
textTransform: 'uppercase'
},
h4: {
color: 'var(--tw-typo-plugin-headings)',
Expand Down
Loading

0 comments on commit bdaa0f3

Please sign in to comment.