Skip to content

Commit

Permalink
First commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnrendra committed Nov 22, 2022
1 parent 8a1de03 commit 91934a3
Show file tree
Hide file tree
Showing 37 changed files with 2,143 additions and 450 deletions.
24 changes: 24 additions & 0 deletions components/AddItem/AddItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { memo } from 'react'
import { Button } from '@ui'
import store from '@store'

const AddItem = () => {
const addItem = store(({ addItem }: any) => addItem)
const setText = store(({ setText }: any) => setText)

const handleAddItem = () => {
console.log('add-------')
addItem()
setText('')
}

console.log('AddItem')
return (
<Button
text="Add Item"
onClick={handleAddItem}
/>
)
}

export default memo(AddItem)
3 changes: 3 additions & 0 deletions components/AddItem/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AddItem from './AddItem'

export default AddItem
25 changes: 25 additions & 0 deletions components/InputItem/InputItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { memo } from 'react'
import { Input } from '@ui'
import store from '@store'

const InputItem = () => {
const text = store(({ text }: any) => text)
const setText = store(({ setText }: any) => setText)

const handleTyped = (text: string) => {
console.log('typed-----', text)
setText(text)
}

console.log('InputItem', text)

return (
<Input
placeholder="New Item ..."
value={text}
onTyped={handleTyped}
/>
)
}

export default memo(InputItem)
3 changes: 3 additions & 0 deletions components/InputItem/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import InputItem from './InputItem'

export default InputItem
47 changes: 47 additions & 0 deletions components/Item/Item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { memo } from 'react'
import { XCircleIcon as CloseIcon } from '@heroicons/react/24/outline'
import { Card } from '@ui'
import { tw } from '@utils'
import store from '@store'

const Item = ({
name = ''
}) => {
const removeItem = store(({ removeItem }: any) => removeItem)

const handleRemoveItem = () => {
console.log('remove------', name)
removeItem(name)
}

console.log('Item', name)
return (
<Card
className={tw(
'flex',
'justify-between',
'my-4'
)}
>
<p
className={tw(
'w-fit'
)}
>
{name}
</p>
<CloseIcon
onClick={handleRemoveItem}
className={tw(
'w-6',
'h-6',
'text-rose-500',
'hover:text-rose-700',
'cursor-pointer'
)}
/>
</Card>
)
}

export default memo(Item)
3 changes: 3 additions & 0 deletions components/Item/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Item from './Item'

export default Item
28 changes: 28 additions & 0 deletions components/List/List.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { memo } from 'react'
import { Item } from '@components'
import { tw } from '@utils'
import store from '@store'

const List = () => {
const items = store(({ items }: any) => items)
console.log('List')
return (
<div>
{items.length
? items.map((item: any) => (
<Item
key={item.id}
name={item.name}
/>))
: (
<div className={tw('text-center')}>
<p className={tw('font-bold')}>There is no Item!</p>
<small>Please open <b className={tw('text-rose-500')}>Dev Tools</b> - <b className={tw('text-rose-500')}>Consol</b> and see the <b className={tw('text-rose-500')}>Rendering</b> log!</small>
</div>
)
}
</div>
)
}

export default memo(List)
3 changes: 3 additions & 0 deletions components/List/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import List from './List'

export default List
11 changes: 11 additions & 0 deletions components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import AddItem from './AddItem'
import InputItem from './InputItem'
import Item from './Item'
import List from './List'

export {
AddItem,
InputItem,
Item,
List
}
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
swcMinify: true
}

module.exports = nextConfig
Loading

1 comment on commit 91934a3

@vercel
Copy link

@vercel vercel bot commented on 91934a3 Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.