Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract checkout items to their own scope #2

Merged
merged 3 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 82 additions & 2 deletions .bitmap
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,99 @@
"mainFile": "index.ts",
"rootDir": "ecommerce/blocks/page-header"
},
"checkout-action-item": {
"name": "checkout-action-item",
"scope": "",
"version": "",
"defaultScope": "bit-nimble.checkout",
"mainFile": "index.ts",
"rootDir": "checkout/checkout-action-item",
"config": {
"bit-nimble.design/envs/mui-env@0.0.1": {},
"teambit.envs/envs": {
"env": "bit-nimble.design/envs/mui-env"
},
"teambit.dependencies/dependency-resolver": {
"policy": {
"devDependencies": {
"@types/testing-library__jest-dom": "^5.14.9"
}
}
},
"teambit.component/dev-files": {},
"teambit.preview/preview": {},
"teambit.compositions/compositions": {},
"teambit.docs/docs": {},
"teambit.pipelines/builder": {},
"teambit.harmony/application": {},
"teambit.component/renaming": {
"renamedFrom": {
"scope": "bit-nimble.ecommerce",
"name": "checkout/checkout-action-item",
"version": "0.0.6"
}
}
}
},
"checkout-nav-menu-content": {
"name": "checkout-nav-menu-content",
"scope": "",
"version": "",
"defaultScope": "bit-nimble.checkout",
"mainFile": "index.ts",
"rootDir": "checkout/checkout-nav-menu-content",
"config": {
"bit-nimble.design/envs/mui-env@0.0.1": {},
"teambit.envs/envs": {
"env": "bit-nimble.design/envs/mui-env"
},
"teambit.dependencies/dependency-resolver": {},
"teambit.component/dev-files": {},
"teambit.preview/preview": {},
"teambit.compositions/compositions": {},
"teambit.docs/docs": {},
"teambit.pipelines/builder": {},
"teambit.harmony/application": {},
"teambit.component/renaming": {
"renamedFrom": {
"scope": "bit-nimble.ecommerce",
"name": "checkout/checkout-nav-menu-content",
"version": "0.0.1"
}
}
}
},
"checkout/checkout-action-item": {
"name": "checkout/checkout-action-item",
"scope": "bit-nimble.ecommerce",
"version": "0.0.6",
"mainFile": "index.ts",
"rootDir": "ecommerce/checkout/checkout-action-item"
"rootDir": "ecommerce/checkout/checkout-action-item",
"config": {
"teambit.component/deprecation": {
"deprecate": true,
"newId": {
"name": "checkout-action-item",
"scope": "bit-nimble.checkout"
}
}
}
},
"checkout/checkout-nav-menu-content": {
"name": "checkout/checkout-nav-menu-content",
"scope": "bit-nimble.ecommerce",
"version": "0.0.1",
"mainFile": "index.ts",
"rootDir": "ecommerce/checkout/checkout-nav-menu-content"
"rootDir": "ecommerce/checkout/checkout-nav-menu-content",
"config": {
"teambit.component/deprecation": {
"deprecate": true,
"newId": {
"name": "checkout-nav-menu-content",
"scope": "bit-nimble.checkout"
}
}
}
},
"envs/mui-env": {
"name": "envs/mui-env",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_USER_NAME: ${{ secrets.GIT_USER_NAME }}
GIT_USER_EMAIL: ${{ secrets.GIT_USER_EMAIL }}
BIT_CONFIG_USER_TOKEN: ${{ secrets.BIT_CONFIG_USER_TOKEN }}
BIT_CONFIG_USER_TOKEN: ${{ secrets.BIT_CLOUD_ACCESS_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize Bit
uses: bit-tasks/init@v1
uses: bit-tasks/init@v1
- name: Bit Pull Request
uses: bit-tasks/pull-request@v1
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions checkout/checkout-action-item/checkout-action-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { PageHeaderMenuItemObject } from '@bit-nimble/design.page-header-menu-item';
import { CheckoutNavMenuContent } from '@bit-nimble/checkout.checkout-nav-menu-content';

export const checkoutActionItem: PageHeaderMenuItemObject = {
id: 'checkout',
title: 'Checkout',
icon: '🛒',
menuContent: <CheckoutNavMenuContent />,
};
1 change: 1 addition & 0 deletions checkout/checkout-action-item/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { checkoutActionItem } from './checkout-action-item';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import { CheckoutNavMenuContent } from './checkout-nav-menu-content';

export const BasicCheckoutNavMenuContent = () => {
return <CheckoutNavMenuContent />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: A CheckoutNavMenuContent component.
---

import { CheckoutNavMenuContent } from './checkout-nav-menu-content';

### Component usage
```js
<CheckoutNavMenuContent>Hello world!</CheckoutNavMenuContent>
```

### Render hello world!

```js live
<CheckoutNavMenuContent>Hello world!</CheckoutNavMenuContent>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render } from '@testing-library/react';
import { BasicCheckoutNavMenuContent } from './checkout-nav-menu-content.composition';

it('renders with the correct text', () => {
const { getByText } = render(<BasicCheckoutNavMenuContent />);
const rendered = getByText('Add some products!');
expect(rendered).toBeTruthy();
});
36 changes: 36 additions & 0 deletions checkout/checkout-nav-menu-content/checkout-nav-menu-content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Box, Typography } from '@mui/material';

export type CheckoutNavMenuContentProps = {};

export function CheckoutNavMenuContent() {
const cartItems = []; // Simulate cart items

return (
<Box>
{cartItems.length === 0 ? (
<Box
sx={{
p: 2,
textAlign: 'center',
}}
>
<Typography variant="subtitle1" component="div">
Your cart is empty
</Typography>
<Typography
variant="body2"
component="div"
sx={{
pt: 2,
}}
>
<span role="img" aria-label="Cart">
🛒
</span>{' '}
Add some products!
</Typography>
</Box>
) : null}
</Box>
);
}
2 changes: 2 additions & 0 deletions checkout/checkout-nav-menu-content/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { CheckoutNavMenuContent } from './checkout-nav-menu-content';
export type { CheckoutNavMenuContentProps } from './checkout-nav-menu-content';
2 changes: 1 addition & 1 deletion ecommerce/shop-web/shop-web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Box, CssBaseline, GlobalStyles, MenuItem } from '@mui/material';
import { PageHeader } from '@bit-nimble/ecommerce.blocks.page-header';
import { NimbleProvider } from '@bit-nimble/design.themes.nimble';
import { supportActionItem } from '@bit-nimble/support.header-action-item';
import { checkoutActionItem } from '@bit-nimble/ecommerce.checkout.checkout-action-item';
import { checkoutActionItem } from '@bit-nimble/checkout.checkout-action-item';
import { createEmotionCache } from './emotion-cache.js';

export function SupportNavMenuContent() {
Expand Down
Loading