@shopify/shop-minis-react 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-react",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.0.28",
4
+ "version": "0.0.29",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "engines": {
@@ -223,10 +223,15 @@ function ProductLinkActions({
223
223
  export interface ProductLinkProps {
224
224
  product: Product
225
225
  hideFavoriteAction?: boolean
226
+ onClick?: (product: Product) => void
226
227
  }
227
228
 
228
229
  // Composed ProductLink component
229
- function ProductLink({product, hideFavoriteAction = false}: ProductLinkProps) {
230
+ function ProductLink({
231
+ product,
232
+ hideFavoriteAction = false,
233
+ onClick,
234
+ }: ProductLinkProps) {
230
235
  const {navigateToProduct} = useShopNavigation()
231
236
  const {saveProduct, unsaveProduct} = useSavedProductsActions()
232
237
 
@@ -262,7 +267,8 @@ function ProductLink({product, hideFavoriteAction = false}: ProductLinkProps) {
262
267
  navigateToProduct({
263
268
  productId: id,
264
269
  })
265
- }, [navigateToProduct, id])
270
+ onClick?.(product)
271
+ }, [navigateToProduct, id, onClick, product])
266
272
 
267
273
  const handleActionPress = React.useCallback(async () => {
268
274
  const previousState = isFavoritedLocal
@@ -321,7 +327,7 @@ function ProductLink({product, hideFavoriteAction = false}: ProductLinkProps) {
321
327
  <ProductLinkInfo layout="horizontal">
322
328
  <ProductLinkTitle>{title}</ProductLinkTitle>
323
329
 
324
- {reviewCount && averageRating && (
330
+ {reviewCount && averageRating ? (
325
331
  <ProductLinkRating>
326
332
  <div className="flex items-center gap-1">
327
333
  {Array.from({length: 5}, (_, i) => (
@@ -343,7 +349,7 @@ function ProductLink({product, hideFavoriteAction = false}: ProductLinkProps) {
343
349
  </span>
344
350
  </div>
345
351
  </ProductLinkRating>
346
- )}
352
+ ) : null}
347
353
 
348
354
  <ProductLinkPrice>
349
355
  {hasDiscount ? (
@@ -220,6 +220,7 @@ export interface SearchResultsProps
220
220
  SearchInputProps,
221
221
  SearchResultsListProps {
222
222
  showSearchInput?: boolean
223
+ onProductClick?: (product: Product) => void
223
224
  }
224
225
 
225
226
  function Search({
@@ -230,6 +231,7 @@ function Search({
230
231
  className,
231
232
  renderItem,
232
233
  itemHeight,
234
+ onProductClick,
233
235
  }: SearchResultsProps) {
234
236
  const _renderItem = (product: Product, index: number) => {
235
237
  if (renderItem) {
@@ -238,7 +240,12 @@ function Search({
238
240
 
239
241
  return (
240
242
  <div className="p-2">
241
- <ProductLink key={product.id} product={product} hideFavoriteAction />
243
+ <ProductLink
244
+ key={product.id}
245
+ product={product}
246
+ hideFavoriteAction
247
+ onClick={onProductClick}
248
+ />
242
249
  </div>
243
250
  )
244
251
  }
@@ -10,7 +10,7 @@ export * from './commerce/search'
10
10
 
11
11
  export * from './content/image-content-wrapper'
12
12
 
13
- export * from './navigation/transition-container'
13
+ export * from './navigation/minis-router'
14
14
  export * from './navigation/transition-link'
15
15
 
16
16
  export * from './atoms/button'
@@ -0,0 +1,23 @@
1
+ import {BrowserRouter, BrowserRouterProps} from 'react-router'
2
+
3
+ import {TransitionContainer} from './transition-container'
4
+
5
+ type ShopMinisRouterProps = BrowserRouterProps & {
6
+ viewTransitions?: boolean
7
+ }
8
+
9
+ export function MinisRouter({
10
+ children,
11
+ viewTransitions = false,
12
+ ...props
13
+ }: ShopMinisRouterProps) {
14
+ if (viewTransitions) {
15
+ return (
16
+ <BrowserRouter {...props}>
17
+ <TransitionContainer>{children}</TransitionContainer>
18
+ </BrowserRouter>
19
+ )
20
+ }
21
+
22
+ return <BrowserRouter {...props}>{children}</BrowserRouter>
23
+ }
package/src/index.css CHANGED
@@ -1,6 +1,7 @@
1
1
  @import 'tailwindcss';
2
2
  @import 'tw-animate-css';
3
3
 
4
+ @import './styles/fonts.css';
4
5
  @import './styles/theme.css';
5
6
  @import './styles/globals.css';
6
7
  @import './styles/animations.css';
@@ -0,0 +1,37 @@
1
+ import {fn} from 'storybook/test'
2
+
3
+ import {
4
+ Search,
5
+ SearchInput,
6
+ SearchProvider,
7
+ SearchResultsList,
8
+ } from '../components'
9
+
10
+ import type {Meta, StoryObj} from '@storybook/react-vite'
11
+
12
+ const meta = {
13
+ title: 'Commerce/Search',
14
+ component: Search,
15
+ parameters: {
16
+ layout: 'padded',
17
+ },
18
+ tags: ['autodocs'],
19
+ } satisfies Meta<typeof Search>
20
+
21
+ export default meta
22
+ type Story = StoryObj<typeof meta>
23
+
24
+ export const Default: Story = {
25
+ args: {
26
+ onProductClick: fn(),
27
+ },
28
+ }
29
+
30
+ export const Composite: Story = {
31
+ render: args => (
32
+ <SearchProvider {...args}>
33
+ <SearchInput placeholder="Search..." />
34
+ <SearchResultsList />
35
+ </SearchProvider>
36
+ ),
37
+ }
@@ -0,0 +1,26 @@
1
+ @font-face {
2
+ font-family: 'Suisse Intl';
3
+ font-style: normal;
4
+ font-weight: 400;
5
+ font-display: swap;
6
+ src: url('https://cdn.shopify.com/shop-assets/static_uploads/shoplift/SuisseIntl-Book.woff2')
7
+ format('woff2');
8
+ }
9
+
10
+ @font-face {
11
+ font-family: 'Suisse Intl';
12
+ font-style: normal;
13
+ font-weight: 500;
14
+ font-display: swap;
15
+ src: url('https://cdn.shopify.com/shop-assets/static_uploads/shoplift/SuisseIntl-Medium.woff2')
16
+ format('woff2');
17
+ }
18
+
19
+ @font-face {
20
+ font-family: 'Suisse Intl';
21
+ font-style: normal;
22
+ font-weight: 600 700;
23
+ font-display: swap;
24
+ src: url('https://cdn.shopify.com/shop-assets/static_uploads/shoplift/SuisseIntl-SemiBold.woff2')
25
+ format('woff2');
26
+ }
@@ -94,6 +94,32 @@
94
94
 
95
95
  /* Button theme colors */
96
96
  --color-button-overlay: var(--grayscale-d70);
97
+
98
+ /* Default fonts */
99
+ --font-sans: 'Suisse Intl', ui-sans-serif, system-ui, sans-serif,
100
+ 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
101
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
102
+ 'Liberation Mono', 'Courier New', monospace;
103
+
104
+ /* Default Tailwind spacing scale (0.25rem = 4px base) */
105
+ --spacing: 0.25rem;
106
+
107
+ /* Semantic spacing aliases */
108
+ --spacing-shop-screen-margin: 20px;
109
+ --spacing--shop-screen-margin: -20px;
110
+ --spacing-shop-section-gap: 36px;
111
+ --spacing--shop-section-gap: -36px;
112
+ --spacing-shop-card-row-gutter: 8px;
113
+ --spacing--shop-card-row-gutter: -8px;
114
+ --spacing-shop-card-padding: 16px;
115
+ --spacing--shop-card-padding: -16px;
116
+
117
+ /* Shop shadow values */
118
+ --shadow-shop-xs: 0px 2px 4px 0px rgba(0, 0, 0, 0.06);
119
+ --shadow-shop-xs-surface: 0px -1px 4px 0px rgba(0, 0, 0, 0.06);
120
+ --shadow-shop-s: 0px 4px 8px 0px rgba(0, 0, 0, 0.1);
121
+ --shadow-shop-m: 0px 4px 12px 0px rgba(0, 0, 0, 0.16);
122
+ --shadow-shop-l: 0px 8px 24px 0px rgba(0, 0, 0, 0.24);
97
123
  }
98
124
 
99
125
  /* Dark mode overrides - only the palette colors that change */