mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-16 09:41:31 +10:00
implement functionality to hide/show individual items
This commit is contained in:
@ -1,16 +1,20 @@
|
||||
import React from 'react';
|
||||
|
||||
const Checkbox = ({ checked, onChange }) => {
|
||||
const Checkbox = ({ checked, onChange, icon = 'check', size = '2rem' }) => {
|
||||
return (
|
||||
<div className="bg-white border-2 rounded border-gray-400 hover:border-gray-500 w-8 h-8 flex flex-shrink-0 justify-center items-center mr-2 focus-within:border-blue-500 cursor-pointer">
|
||||
<div
|
||||
className="bg-white border-2 rounded border-gray-400 hover:border-gray-500 flex flex-shrink-0 justify-center items-center mr-2 focus-within:border-blue-500 cursor-pointer"
|
||||
style={{ width: size, height: size }}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
className="w-8 h-8 opacity-0 absolute cursor-pointer"
|
||||
style={{ width: size, height: size }}
|
||||
className="opacity-0 absolute cursor-pointer"
|
||||
checked={checked}
|
||||
onChange={e => onChange(e.target.checked)}
|
||||
/>
|
||||
<i className="material-icons fill-current hidden text-lg font-bold text-gray-800 cursor-pointer">
|
||||
check
|
||||
<i className="material-icons fill-current hidden text-sm font-bold text-gray-800 cursor-pointer">
|
||||
{icon}
|
||||
</i>
|
||||
</div>
|
||||
);
|
||||
|
||||
68
src/shared/ItemActions.js
Normal file
68
src/shared/ItemActions.js
Normal file
@ -0,0 +1,68 @@
|
||||
import React from 'react';
|
||||
import Checkbox from './Checkbox';
|
||||
|
||||
const ItemActions = ({
|
||||
item,
|
||||
onChange,
|
||||
type,
|
||||
identifier,
|
||||
dispatch,
|
||||
deleteItem,
|
||||
first,
|
||||
moveItemUp,
|
||||
last,
|
||||
moveItemDown,
|
||||
}) => {
|
||||
return (
|
||||
<div className="flex justify-between">
|
||||
<div className="flex items-center">
|
||||
<Checkbox
|
||||
size="2.25rem"
|
||||
checked={item.enable}
|
||||
onChange={v => {
|
||||
onChange(`${identifier}.enable`, v);
|
||||
}}
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => deleteItem(dispatch, type, item)}
|
||||
className="ml-2 bg-red-600 hover:bg-red-700 text-white text-sm font-medium py-2 px-5 rounded"
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<i className="material-icons mr-2 font-bold text-base">delete</i>
|
||||
<span className="text-sm">Delete</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex">
|
||||
{!first && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => moveItemUp(dispatch, type, item)}
|
||||
className="bg-gray-600 hover:bg-gray-700 text-white text-sm font-medium py-2 px-4 rounded mr-2"
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<i className="material-icons font-bold text-base">arrow_upward</i>
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
|
||||
{!last && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => moveItemDown(dispatch, type, item)}
|
||||
className="bg-gray-600 hover:bg-gray-700 text-white text-sm font-medium py-2 px-4 rounded"
|
||||
>
|
||||
<div className="flex items-center">
|
||||
<i className="material-icons font-bold text-base">arrow_downward</i>
|
||||
</div>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ItemActions;
|
||||
Reference in New Issue
Block a user