-
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.
- Loading branch information
1 parent
0a9f567
commit c2e1b8f
Showing
11 changed files
with
291 additions
and
10 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,56 @@ | ||
.element { | ||
// | ||
display: flex; | ||
align-items: center; | ||
gap: var(--row-gap); | ||
|
||
.title { | ||
position: relative; | ||
.toggle { | ||
cursor: pointer; | ||
position: absolute; | ||
|
||
top: 0; | ||
height: 100%; | ||
opacity: 0; | ||
box-sizing: border-box; | ||
transition: 0.3s; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
&:hover, | ||
&.closed { | ||
.toggle { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
.list { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--col-gap); | ||
} | ||
|
||
&.left { | ||
flex-direction: row-reverse; | ||
.title { | ||
.toggle { | ||
right: 100%; | ||
} | ||
} | ||
.list { | ||
align-items: flex-end; | ||
} | ||
} | ||
&.right { | ||
flex-direction: row; | ||
.title { | ||
.toggle { | ||
left: 100%; | ||
} | ||
} | ||
.list { | ||
align-items: flex-start; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,10 +1,53 @@ | ||
import React, { FC } from 'react'; | ||
import React, { FC, useState } from 'react'; | ||
import classnames from 'classnames'; | ||
import style from './index.module.scss'; | ||
import { ElementProps } from './interface'; | ||
import { LinkIcon, ToggleIcon } from '../icons'; | ||
|
||
const Element: FC<ElementProps> = () => { | ||
return <div className={classnames(style.element)}>element</div>; | ||
const Element: FC<ElementProps> = ({ data, position, className }) => { | ||
const [closed, setClosed] = useState<boolean>(false); | ||
return ( | ||
<div className={classnames(style.element, style[position])}> | ||
<div | ||
className={classnames( | ||
style.title, | ||
className, | ||
closed && style.closed | ||
)} | ||
style={{ | ||
cursor: data.url ? 'pointer' : 'default', | ||
}} | ||
onClick={() => data.url && window.open(data.url, '_blank')} | ||
> | ||
{data.url && position === 'left' && LinkIcon} | ||
{data.title} | ||
{!!data.children?.length && ( | ||
<div | ||
className={style.toggle} | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
setClosed(!closed); | ||
}} | ||
> | ||
{ToggleIcon(closed)} | ||
</div> | ||
)} | ||
{data.url && position === 'right' && LinkIcon} | ||
</div> | ||
{!!data.children?.length && !closed && ( | ||
<div className={classnames(style.list)}> | ||
{data.children.map((ele, idx) => ( | ||
<Element | ||
key={idx} | ||
data={ele} | ||
className={className} | ||
position={position} | ||
/> | ||
))} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Element; |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import React from 'react'; | ||
import { SimpleMindProps } from '../SimpleMind/interface'; | ||
|
||
export interface ElementProps { | ||
className?: string; | ||
children?: React.ReactNode; | ||
data: SimpleMindProps['data']; | ||
position: 'left' | 'right'; | ||
} |
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 |
---|---|---|
@@ -1,4 +1,29 @@ | ||
.simpleMind { | ||
position: relative; | ||
} | ||
|
||
.elementLayer { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: var(--row-gap); | ||
.listContainer { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--col-gap); | ||
&.left { | ||
align-items: flex-end; | ||
} | ||
&.right { | ||
align-items: flex-start; | ||
} | ||
} | ||
} | ||
|
||
.lineLayer { | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
} |
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
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,32 @@ | ||
import React from 'react'; | ||
|
||
export const LinkIcon = ( | ||
<svg | ||
style={{ verticalAlign: 'bottom' }} | ||
viewBox="0 0 1024 1024" | ||
width="18" | ||
height="18" | ||
> | ||
<path d="M314.2144 401.9712a32 32 0 0 1 0 45.2608l-22.8608 22.912a181.504 181.504 0 0 0-4.736 251.776l4.736 4.8896a181.504 181.504 0 0 0 251.776 4.736l4.8896-4.736 22.8864-22.8864a32 32 0 0 1 45.2608 45.2608l-22.8864 22.8864c-94.1056 94.1056-245.5808 95.8464-341.8112 5.2224l-5.376-5.2224c-94.1056-94.1056-95.8464-245.5808-5.2224-341.8112l5.2224-5.376 22.8608-22.8864a32 32 0 0 1 45.2608 0z m120.5504-165.76a245.504 245.504 0 0 1 347.1872 0c94.1056 94.1056 95.8464 245.5808 5.2224 341.8112l-5.2224 5.376-22.8864 22.8864a32 32 0 0 1-45.2608-45.2608l22.8864-22.8864a181.504 181.504 0 0 0 4.736-251.776l-4.736-4.8896a181.504 181.504 0 0 0-251.776-4.736l-4.8896 4.736-22.912 22.8608a32 32 0 0 1-45.2608-45.2352l22.912-22.8864z" /> | ||
<path d="M604.5696 413.5936a32 32 0 0 1 2.2016 42.8032l-2.2016 2.432-135.8592 135.8848a32 32 0 0 1-47.4368-42.8288l2.2016-2.432 135.8592-135.8592a32 32 0 0 1 45.2352 0z" /> | ||
</svg> | ||
); | ||
|
||
export const ToggleIcon = (closed: boolean) => { | ||
return ( | ||
<svg width="16" height="16"> | ||
<path d="M3 8 L13 8" stroke="currentColor" strokeWidth="1" /> | ||
{closed && ( | ||
<path d="M8 3 L8 13" stroke="currentColor" strokeWidth="1" /> | ||
)} | ||
<circle | ||
cx="8" | ||
cy="8" | ||
r="7" | ||
stroke="currentColor" | ||
fill="transparent" | ||
strokeWidth="1" | ||
/> | ||
</svg> | ||
); | ||
}; |
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,9 @@ | ||
.demo2 { | ||
margin-top: 200px; | ||
} | ||
|
||
.element { | ||
border: 1px solid gainsboro; | ||
border-radius: 8px; | ||
padding: 8px; | ||
} |
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