forked from React-js-OTUS/react-start-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
homework3 Add types for base components
- Loading branch information
1 parent
739b609
commit 23a0b09
Showing
27 changed files
with
203 additions
and
172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Header } from './Header'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta: Meta<typeof Header> = { | ||
title: 'Otus/Common/Header', | ||
component: Header, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default: StoryObj<typeof Header> = {}; |
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,13 @@ | ||
import React from 'react'; | ||
import './header.css'; | ||
import { Logo } from '../logo/Logo'; | ||
|
||
export const Header = (): React.ReactElement => { | ||
return ( | ||
<header className="appheader"> | ||
<div className="appheader-content"> | ||
<Logo></Logo> | ||
</div> | ||
</header> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { Layout } from './Layout'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta: Meta<typeof Layout> = { | ||
title: 'Otus/Common/Layout', | ||
component: Layout, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default: StoryObj<typeof Layout> = { | ||
args: { | ||
children: [<div key={1} style={{ margin: 0, height: '500px' }} />], | ||
}, | ||
}; |
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 @@ | ||
import React from 'react'; | ||
import './layout.css'; | ||
import { Header } from '../header/Header'; | ||
|
||
interface LayoutContent { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Layout = ({ children }: LayoutContent): React.ReactElement => { | ||
return ( | ||
<div className="layout"> | ||
<Header></Header> | ||
{children} | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Logo } from './Logo'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
const meta: Meta<typeof Logo> = { | ||
title: 'Otus/Common/Logo', | ||
component: Logo, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default: StoryObj<typeof Logo> = {}; |
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,6 @@ | ||
import React from 'react'; | ||
import './logo.css'; | ||
|
||
export const Logo = (): React.ReactElement => { | ||
return <div className="logo" />; | ||
}; |
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import './modal.css'; | ||
|
||
interface ModalProps { | ||
visible: boolean; | ||
children: React.ReactNode; | ||
} | ||
|
||
export const Modal = ({ visible, children }: ModalProps): React.ReactElement => { | ||
if (!visible) return null; | ||
return ( | ||
<div className="modal-background"> | ||
<div className="modal-dialog"> | ||
<span className="modal-close">×</span> | ||
<div className="modal-body">{children}</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { Trash2 } from 'lucide-react'; | ||
import './cartitem.css'; | ||
|
||
interface CartItemProps { | ||
title: string; | ||
} | ||
|
||
export const CartItem = ({ title }: CartItemProps): React.ReactElement => { | ||
return ( | ||
<div className="cart-item"> | ||
<p className="cart-item__title">{title}</p> | ||
<div className="cart-item__remove-button"> | ||
<Trash2 color="red" /> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react'; | ||
import { PurchaseButton } from '../purchasebutton/PurchaseButton'; | ||
import './itemcard.css'; | ||
|
||
interface ItemCardProps { | ||
price: number; | ||
title: string; | ||
desc: string; | ||
} | ||
|
||
export const ItemCard = ({ price, title, desc }: ItemCardProps): React.ReactElement => { | ||
return ( | ||
<div className="card"> | ||
<img className="card__image" src="https://prd.place/200/200" /> | ||
<p className="card__text card__title">{title}</p> | ||
<p className="card__text card__description">{desc}</p> | ||
<div className="card__price-group"> | ||
<p className="card__price">{price}</p> | ||
<PurchaseButton additionalClass="card__button" /> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
5 changes: 3 additions & 2 deletions
5
...red/shopping/itempage/ItemPage.stories.js → ...red/shopping/itempage/ItemPage.stories.ts
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,28 @@ | ||
import React from 'react'; | ||
import { PurchaseButton } from '../purchasebutton/PurchaseButton'; | ||
import './itempage.css'; | ||
|
||
interface ItemPageProps { | ||
price: number; | ||
images: Array<number>; | ||
category: string; | ||
title: string; | ||
desc: string; | ||
} | ||
|
||
export const ItemPage = ({ price, images, category, title, desc }: ItemPageProps) => { | ||
return ( | ||
<div> | ||
<div className="page__images"> | ||
{images.map((imageId) => { | ||
return <img key={imageId} src={`https://prd.place/200/200?id=${imageId}`}></img>; | ||
})} | ||
</div> | ||
<p>Item: {title}</p> | ||
<p>Description: {desc}</p> | ||
<p>Category: {category}</p> | ||
<p>Price: {price}</p> | ||
<PurchaseButton /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.