update src/components/Accordion/AccordionDesign1/index.js and src/components/Code/index.js

master
mahdi 3 years ago
parent d693992591
commit 421ef0a9ea
  1. 261
      src/components/Accordion/AccordionDesign1/index.js
  2. 2
      src/components/Code/index.js

@ -18,135 +18,137 @@ const AccordionDesign1 = ({ courses, vod }) => {
} }
return ( return (
<DragDropContext onDragEnd={handleOnDragEnd}> <>
<Droppable droppableId="accordions"> <DragDropContext onDragEnd={handleOnDragEnd}>
{(provided) => ( <Droppable droppableId="accordions">
<section {(provided) => (
className="w-full flex flex-col bg-gray-200" <section
{...provided.droppableProps} className="w-full flex flex-col bg-gray-200"
ref={provided.innerRef} {...provided.droppableProps}
id="accordions" ref={provided.innerRef}
> id="accordions"
{courses.map((course, index) => ( >
<Draggable {courses.map((course, index) => (
key={course.id} <Draggable
draggableId={"e" + course.id} key={course.id}
index={index} draggableId={"e" + course.id}
> index={index}
{(provided) => ( >
<div {(provided) => (
className="flex flex-col"
key={index}
props={{
ref: provided.innerRef,
...provided.draggableProps,
...provided.dragHandleProps,
}}
style={provided.draggableProps.style}
>
{/* parent */}
<div <div
className={`flex flex-row items-center justify-between px-3 py-4 border-b-2 ${ className="flex flex-col"
activeAccordion === course key={index}
? "border-surfaceBorder " props={{
: "border-secondary" ref: provided.innerRef,
} cursor-pointer`} ...provided.draggableProps,
onClick={() => ...provided.dragHandleProps,
setActiveAccordion( }}
activeAccordion === course ? null : course style={provided.draggableProps.style}
)
}
> >
<CircleInCircle {/* parent */}
parentClassName={"bg-secondary w-4 h-4 "} <div
childClassName={false} className={`flex flex-row items-center justify-between px-3 py-4 border-b-2 ${
/>
<h2 className="flex-1 mr-5 text-sm">{course.title}</h2>
{vod && (
<div className="flex flex-row items-center ml-5 ">
<p className="text-xs">
دقیقه:
<span>{course.min}</span>
</p>
<div className="w-0.5 h-4 mx-2 bg-surfaceBorder"></div>
<p className="text-xs">
ویدیو:
<span>{course.video}</span>
</p>
</div>
)}
<img
src={
activeAccordion === course activeAccordion === course
? `images/accordion-.svg` ? "border-surfaceBorder "
: `images/accordion+.svg` : "border-secondary"
} cursor-pointer`}
onClick={() =>
setActiveAccordion(
activeAccordion === course ? null : course
)
} }
alt="" >
class="w-3 ml-2" <CircleInCircle
/> parentClassName={"bg-secondary w-4 h-4 "}
</div> childClassName={false}
{/* child */} />
{activeAccordion === course && <h2 className="flex-1 mr-5 text-sm">{course.title}</h2>
course.lessons.map((lesson, i) => ( {vod && (
<div className="flex flex-row items-center justify-between p-3 border-b-2 border-surfaceBorder cursor-pointer transition-all duration-500 ease-in-out"> <div className="flex flex-row items-center ml-5 ">
<div className="flex flex-row items-center"> <p className="text-xs">
{vod === !true && ( دقیقه:
<img <span>{course.min}</span>
src="images/accordionGroup2725.svg" </p>
className="w-3" <div className="w-0.5 h-4 mx-2 bg-surfaceBorder"></div>
alt="line" <p className="text-xs">
/> ویدیو:
)} <span>{course.video}</span>
<span </p>
className={`text-sm ${
vod === true ? "mr-0" : "mr-3"
}`}
>
{i + 1}
</span>
</div> </div>
<div className="w-0.5 h-5 mx-3 bg-surfaceBorder"></div> )}
<p className="text-sm flex-1">{lesson.name}</p> <img
<div className="flex flex-row items-center justify-end gap-x-3 flex-1"> src={
{vod ? ( activeAccordion === course
<> ? `images/accordion-.svg`
<div className="flex flex-row items-center ml-7"> : `images/accordion+.svg`
<p className="text-xs"> }
دقیقه: alt=""
<span>{course.min}</span> class="w-3 ml-2"
</p> />
<Button </div>
className="px-2 py-1 text-primary text-sm border border-surfaceBorder rounded mr-4" {/* child */}
text={"پخش"} {activeAccordion === course &&
/> course.lessons.map((lesson, i) => (
</div> <div className="flex flex-row items-center justify-between p-3 border-b-2 border-surfaceBorder cursor-pointer transition-all duration-500 ease-in-out">
</> <div className="flex flex-row items-center">
) : ( {vod === !true && (
<>
<img <img
src="images/accordionGroup2724.svg" src="images/accordionGroup2725.svg"
className="w-8 rounded" className="w-3"
alt="delete-button" alt="line"
/> />
<img )}
src="images/accordionGroup2723.svg" <span
className="w-8 rounded" className={`text-sm ${
alt="edit-button" vod === true ? "mr-0" : "mr-3"
/> }`}
</> >
)} {i + 1}
</span>
</div>
<div className="w-0.5 h-5 mx-3 bg-surfaceBorder"></div>
<p className="text-sm flex-1">{lesson.name}</p>
<div className="flex flex-row items-center justify-end gap-x-3 flex-1">
{vod ? (
<>
<div className="flex flex-row items-center ml-7">
<p className="text-xs">
دقیقه:
<span>{course.min}</span>
</p>
<Button
className="px-2 py-1 text-primary text-sm border border-surfaceBorder rounded mr-4"
text={"پخش"}
/>
</div>
</>
) : (
<>
<img
src="images/accordionGroup2724.svg"
className="w-8 rounded"
alt="delete-button"
/>
<img
src="images/accordionGroup2723.svg"
className="w-8 rounded"
alt="edit-button"
/>
</>
)}
</div>
</div> </div>
</div> ))}
))} {provided.placeholder}
{provided.placeholder} </div>
</div> )}
)} </Draggable>
</Draggable> ))}
))} </section>
</section> )}
)} </Droppable>
</Droppable> </DragDropContext>
</DragDropContext> </>
); );
}; };
@ -209,3 +211,20 @@ AccordionDesign1.defaultProps = {
}, },
], ],
}; };
{
/* monaco */
}
// import MonacoEditor from "react-monaco-editor";
// <MonacoEditor
// width="800"
// height="600"
// language="javascript"
// theme="vs-dark"
// value={code}
// options={options}
// onChange={::this.onChange}
// editorDidMount={::this.editorDidMount}
// />

@ -1,5 +1,6 @@
import { useState } from "react"; import { useState } from "react";
import copyIcon from "./copy.png"; import copyIcon from "./copy.png";
import MonacoEditor from "react-monaco-editor";
function Code({ code }) { function Code({ code }) {
const [copied, setCopied] = useState(false); const [copied, setCopied] = useState(false);
@ -13,6 +14,7 @@ function Code({ code }) {
/* Copy the text inside the text field */ /* Copy the text inside the text field */
navigator.clipboard.writeText(copyText); navigator.clipboard.writeText(copyText);
}; };
return ( return (
<div className="flex flex-col w-full my-10"> <div className="flex flex-col w-full my-10">
<div className="w-full flex flex-row items-center justify-between"> <div className="w-full flex flex-row items-center justify-between">

Loading…
Cancel
Save