Skip to content

Commit

Permalink
feat:(theme) Add cva header and remove section
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasKn committed Dec 1, 2023
1 parent 8e51946 commit 0da1479
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 53 deletions.
67 changes: 41 additions & 26 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions templates/hydrogen-theme/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
// If not working, try adding this setting to User settings.json
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
Expand Down
5 changes: 2 additions & 3 deletions templates/hydrogen-theme/app/components/CmsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {FOOTERS_FRAGMENT} from '~/qroq/footers';
import {useIsDev} from '~/hooks/useIsDev';
import {sections} from '~/lib/sectionRelsolver';
import {useSettingsCssVars} from '~/hooks/useSettingsCssVars';
import {section} from './cva/section';
import {EncodeDataAttributeCallback} from '@sanity/react-loader';

type CmsSectionsProps =
Expand Down Expand Up @@ -56,7 +55,7 @@ function SectionWrapper(props: {
<footer
data-footer-type={isDev ? sectionType : null}
style={cssVars}
className={section({})}
className="color-scheme section-padding relative"
>
{children}
{data.settings?.customCss && (
Expand All @@ -68,7 +67,7 @@ function SectionWrapper(props: {
data-section-type={isDev ? sectionType : null}
id={`section-${data._key}`}
style={cssVars}
className={section({})}
className="color-scheme section-padding relative"
>
{children}
{data.settings?.customCss && (
Expand Down
4 changes: 3 additions & 1 deletion templates/hydrogen-theme/app/components/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function ProductCard(props: {
return (
<div className="overflow-hidden rounded-lg border">
<Link to={`/products/${product.handle}`}>
{firstVariant.image && <Image data={firstVariant.image} />}
{firstVariant.image && (
<Image aspectRatio="16/9" sizes="33vw" data={firstVariant.image} />
)}
<div className="p-3">
<div className="text-lg">{product.title}</div>
<div>
Expand Down
12 changes: 12 additions & 0 deletions templates/hydrogen-theme/app/components/cva/header.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type {VariantProps} from 'class-variance-authority';
import {cva} from 'class-variance-authority';

export type HeaderVariantsProps = VariantProps<typeof header>;

export const header = cva([''], {
variants: {
optional: {'separator-line': 'border-color-scheme-text/10 border-b'},
},
});

export const headerVariants = (props: HeaderVariantsProps) => header(props);
21 changes: 0 additions & 21 deletions templates/hydrogen-theme/app/components/cva/section.ts

This file was deleted.

10 changes: 8 additions & 2 deletions templates/hydrogen-theme/app/components/layout/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type {CSSProperties} from 'react';
import {Link} from '@remix-run/react';
import {cx} from 'class-variance-authority';

import {Logo} from './Logo';
import {Navigation} from '../navigation/Navigation';
import {useSanityRoot} from '~/hooks/useSanityRoot';
import {useSettingsCssVars} from '~/hooks/useSettingsCssVars';
import {section} from '../cva/section';
import {headerVariants} from '../cva/header';

export function Header() {
const {data} = useSanityRoot();
Expand All @@ -21,7 +22,12 @@ export function Header() {
return (
<header
style={cssVars}
className={section({optional: showSeparatorLine ? 'header' : null})}
className={cx([
'color-scheme section-padding relative',
headerVariants({
optional: showSeparatorLine ? 'separator-line' : null,
}),
])}
>
<div className="container">
<div className="flex items-center justify-between">
Expand Down
1 change: 1 addition & 0 deletions templates/hydrogen-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@shopify/hydrogen": "^2023.10.2",
"@shopify/remix-oxygen": "^2.0.1",
"class-variance-authority": "^0.7.0",
"cva": "1.0.0-beta.1",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6",
"groq": "^3.20.2",
Expand Down

0 comments on commit 0da1479

Please sign in to comment.