-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from adobe/new-features-plp
New features PLP
- Loading branch information
Showing
151 changed files
with
13,140 additions
and
6,442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module.exports = { | ||
plugins: [ | ||
require('postcss-import'), | ||
require('tailwindcss'), | ||
require('tailwindcss/nesting'), | ||
require('autoprefixer'), | ||
require('tailwindcss'), | ||
require('cssnano'), | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const graphqlEndpoint = `${window.origin}/graphql`; | ||
|
||
async function getGraphQL(query = '', variables = {}, store = '') { | ||
const response = await fetch(graphqlEndpoint, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json', Store: store }, | ||
body: JSON.stringify({ | ||
query, | ||
variables, | ||
}), | ||
}).then((res) => res.json()); | ||
|
||
return response; | ||
} | ||
|
||
export { getGraphQL }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const CREATE_EMPTY_CART = ` | ||
mutation createEmptyCart($input: createEmptyCartInput) { | ||
createEmptyCart(input: $input) | ||
} | ||
`; | ||
|
||
const ADD_TO_CART = ` | ||
mutation addProductsToCart( | ||
$cartId: String! | ||
$cartItems: [CartItemInput!]! | ||
) { | ||
addProductsToCart( | ||
cartId: $cartId | ||
cartItems: $cartItems | ||
) { | ||
cart { | ||
items { | ||
product { | ||
name | ||
sku | ||
} | ||
quantity | ||
} | ||
} | ||
user_errors { | ||
code | ||
message | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export { ADD_TO_CART, CREATE_EMPTY_CART }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/components/AddToCartButton/AddToCartButton.stories.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Canvas, Meta, Story, ArgsTable } from '@storybook/addon-docs'; | ||
import { action } from '@storybook/addon-actions'; | ||
import { AddToCartButton } from '../AddToCartButton'; | ||
|
||
<Meta | ||
title="PLP/AddToCartButton" | ||
component={AddToCartButton} | ||
parameters={{ | ||
layout: 'centered', | ||
}} | ||
/> | ||
|
||
export const Template = (args) => <AddToCartButton {...args} />; | ||
|
||
# AddToCartButton | ||
|
||
``` | ||
import { AddToCartButton } from '../AddToCartButton' | ||
``` | ||
|
||
<Canvas> | ||
<Story | ||
name="AddToCartButton" | ||
args={{ | ||
onClick: action('onClick'), | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
Copyright 2024 Adobe | ||
All Rights Reserved. | ||
NOTICE: Adobe permits you to use, modify, and distribute this file in | ||
accordance with the terms of the Adobe license agreement accompanying | ||
it. | ||
*/ | ||
|
||
import { render } from '@testing-library/preact'; | ||
|
||
import { AddToCartButton } from './AddToCartButton'; | ||
|
||
describe('WidgetSDK - UIKit/AddToCartButton', () => { | ||
test('renders', () => { | ||
const { container } = render( | ||
<AddToCartButton | ||
onClick={() => { | ||
return; | ||
}} | ||
/> | ||
); | ||
|
||
const elem = container.querySelector('.ds-sdk-add-to-cart-button'); | ||
|
||
expect(!!elem).toEqual(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
Copyright 2024 Adobe | ||
All Rights Reserved. | ||
NOTICE: Adobe permits you to use, modify, and distribute this file in | ||
accordance with the terms of the Adobe license agreement accompanying | ||
it. | ||
*/ | ||
|
||
import { FunctionComponent } from 'preact'; | ||
|
||
import CartIcon from '../../icons/cart.svg'; | ||
|
||
export interface AddToCartButtonProps { | ||
onClick: (e: any) => any; | ||
} | ||
export const AddToCartButton: FunctionComponent<AddToCartButtonProps> = ({ | ||
onClick, | ||
}: AddToCartButtonProps) => { | ||
return ( | ||
<div className="ds-sdk-add-to-cart-button"> | ||
<button | ||
className="flex items-center justify-center text-white text-sm rounded-full h-[32px] w-full p-sm" | ||
style={{ | ||
'background-color': `#464646`, | ||
}} | ||
onClick={onClick} | ||
> | ||
<CartIcon className="w-[24px] pr-4" /> | ||
Add To Cart | ||
</button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
Copyright 2024 Adobe | ||
All Rights Reserved. | ||
NOTICE: Adobe permits you to use, modify, and distribute this file in | ||
accordance with the terms of the Adobe license agreement accompanying | ||
it. | ||
*/ | ||
|
||
export * from './AddToCartButton'; | ||
export { AddToCartButton as default } from './AddToCartButton'; |
Oops, something went wrong.