mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-08 07:56:12 +02:00
refact: remove react-treeview dependency, rework resource sidebar
This commit is contained in:
Generated
-8
@@ -14117,14 +14117,6 @@
|
|||||||
"shallowequal": "^1.0.1"
|
"shallowequal": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"react-treeview": {
|
|
||||||
"version": "0.4.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/react-treeview/-/react-treeview-0.4.7.tgz",
|
|
||||||
"integrity": "sha1-9kfgT3BJbrEfsJEsNRh+gOtg1Fg=",
|
|
||||||
"requires": {
|
|
||||||
"prop-types": "^15.5.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"read": {
|
"read": {
|
||||||
"version": "1.0.7",
|
"version": "1.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz",
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
"react-dom": "^16.8.6",
|
"react-dom": "^16.8.6",
|
||||||
"react-helmet": "^5.2.1",
|
"react-helmet": "^5.2.1",
|
||||||
"react-perfect-scrollbar": "^1.5.3",
|
"react-perfect-scrollbar": "^1.5.3",
|
||||||
"react-treeview": "^0.4.7",
|
|
||||||
"styled-components": "^4.3.2"
|
"styled-components": "^4.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import React, { useState } from "react"
|
import React, { useState } from "react"
|
||||||
import Tree from "react-treeview"
|
|
||||||
import { useStaticQuery, graphql } from "gatsby"
|
import { useStaticQuery, graphql } from "gatsby"
|
||||||
import useBuildTree from "./useBuildTree"
|
import useBuildTree from "./useBuildTree"
|
||||||
import useSidebar from "./../../hooks/useSidebar"
|
import useSidebar from "./../../hooks/useSidebar"
|
||||||
import banner from "../../images/tph-banner.png"
|
import banner from "../../images/tph-banner.png"
|
||||||
|
import TriangleDown from "../../icons/triangle-down.svg"
|
||||||
import * as SC from "./styles"
|
import * as SC from "./styles"
|
||||||
|
|
||||||
export interface IFile {
|
export interface IFile {
|
||||||
@@ -82,13 +82,11 @@ function Folder({ item }: { item: IFolder }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SC.TreeWrapper>
|
<SC.TreeWrapper collapsed={collapsed}>
|
||||||
<Tree
|
<SC.Label onClick={toggleCollapse}>
|
||||||
collapsed={collapsed}
|
<TriangleDown /> {item.title}
|
||||||
nodeLabel={<SC.Label onClick={toggleCollapse}>{item.title}</SC.Label>}
|
</SC.Label>
|
||||||
>
|
<SC.Children>{item.children.map(node => plantTree(node))}</SC.Children>
|
||||||
{item.children.map(node => plantTree(node))}
|
|
||||||
</Tree>
|
|
||||||
</SC.TreeWrapper>
|
</SC.TreeWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -98,22 +96,15 @@ function FirstLevelFolder({ item, index }: { item: IFolder; index: number }) {
|
|||||||
const collapsed = current !== index
|
const collapsed = current !== index
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SC.TreeWrapper>
|
<SC.TreeWrapper className="firstLevel" collapsed={collapsed}>
|
||||||
<Tree
|
<SC.FirstLabel
|
||||||
className="firstLevel"
|
className={!collapsed ? "active" : undefined}
|
||||||
collapsed={collapsed}
|
onClick={() => setCurrent(index)}
|
||||||
nodeLabel={
|
|
||||||
<SC.FirstLabel
|
|
||||||
className={!collapsed ? "active" : undefined}
|
|
||||||
onClick={() => setCurrent(index)}
|
|
||||||
>
|
|
||||||
{item.title}
|
|
||||||
<SC.CollapseToggler />
|
|
||||||
</SC.FirstLabel>
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{item.children.map(node => plantTree(node))}
|
{item.title}
|
||||||
</Tree>
|
<SC.CollapseToggler />
|
||||||
|
</SC.FirstLabel>
|
||||||
|
<SC.Children>{item.children.map(node => plantTree(node))}</SC.Children>
|
||||||
</SC.TreeWrapper>
|
</SC.TreeWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import ChevronUp from "../../icons/chevron-up.svg"
|
|||||||
|
|
||||||
export const ResourcesSidebarWrapper = styled.div`
|
export const ResourcesSidebarWrapper = styled.div`
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
flex: 0 0 300px;
|
flex: 0 0 320px;
|
||||||
background: #f9f9f9;
|
background: #f9f9f9;
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -13,25 +13,41 @@ export const Banner = styled.img`
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
`
|
`
|
||||||
|
|
||||||
export const TreeWrapper = styled.div`
|
export const Children = styled.div`
|
||||||
width: 100%;
|
padding-left: 16px;
|
||||||
|
padding-bottom: 8px;
|
||||||
& + & {
|
display: flex;
|
||||||
border-top: 1px solid #dbdbdb;
|
flex-direction: column;
|
||||||
}
|
align-items: flex-start;
|
||||||
|
overflow: hidden;
|
||||||
`
|
`
|
||||||
|
|
||||||
export const Label = styled.div`
|
export const Label = styled.div`
|
||||||
padding: 4px 0;
|
user-select: none;
|
||||||
|
position: relative;
|
||||||
|
padding: 8px 0;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
position: absolute;
|
||||||
|
right: 100%;
|
||||||
|
margin-right: 4px;
|
||||||
|
width: 10px;
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
export const FirstLabel = styled.div`
|
export const FirstLabel = styled.div`
|
||||||
|
user-select: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
padding: 12px 15px 12px 0;
|
padding: 12px 15px 12px 0;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
color: #a9a9a9;
|
color: #a9a9a9;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
color: #000;
|
color: #000;
|
||||||
@@ -56,62 +72,44 @@ export const FirstLabel = styled.div`
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
export const TreeWrapper = styled.div<{ collapsed: boolean }>`
|
||||||
|
width: 100%;
|
||||||
|
font-size: 20px;
|
||||||
|
|
||||||
|
&.firstLevel {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
& + & {
|
||||||
|
border-top: 1px solid #dbdbdb;
|
||||||
|
}
|
||||||
|
|
||||||
|
${Children} {
|
||||||
|
display: ${props => (props.collapsed ? "none" : "block")};
|
||||||
|
/* height: ${props => (props.collapsed ? 0 : "auto")}; */
|
||||||
|
}
|
||||||
|
|
||||||
|
& > ${Label} svg {
|
||||||
|
transform: rotate(${props => (props.collapsed ? -90 : 0)}deg);
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
export const CollapseToggler = styled(ChevronUp)``
|
export const CollapseToggler = styled(ChevronUp)``
|
||||||
|
|
||||||
export const Inner = styled.div`
|
export const Inner = styled.div`
|
||||||
padding-top: 30px;
|
padding-top: 30px;
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
|
|
||||||
.tree-view {
|
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-view_item {
|
|
||||||
display: flex;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-view_children {
|
|
||||||
margin-left: 16px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-view_children-collapsed {
|
|
||||||
height: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-view_arrow {
|
|
||||||
cursor: pointer;
|
|
||||||
margin-right: 6px;
|
|
||||||
display: inline-block;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
user-select: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-view_arrow:after {
|
|
||||||
content: "▾";
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-view_arrow.firstLevel {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tree-view_arrow-collapsed {
|
|
||||||
-webkit-transform: rotate(-90deg);
|
|
||||||
-moz-transform: rotate(-90deg);
|
|
||||||
-ms-transform: rotate(-90deg);
|
|
||||||
transform: rotate(-90deg);
|
|
||||||
}
|
|
||||||
`
|
`
|
||||||
|
|
||||||
export const PageLink = styled(Link)`
|
export const PageLink = styled(Link)`
|
||||||
display: block;
|
display: block;
|
||||||
padding: 4px 0;
|
padding: 4px 0;
|
||||||
color: #1c61df;
|
color: #000;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
& + & {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 292.362 292.362">
|
||||||
|
<path d="M286.935 69.377c-3.614-3.617-7.898-5.424-12.848-5.424H18.274c-4.952 0-9.233 1.807-12.85 5.424C1.807 72.998 0 77.279 0 82.228c0 4.948 1.807 9.229 5.424 12.847l127.907 127.907c3.621 3.617 7.902 5.428 12.85 5.428s9.233-1.811 12.847-5.428L286.935 95.074c3.613-3.617 5.427-7.898 5.427-12.847 0-4.948-1.814-9.229-5.427-12.85z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 413 B |
Reference in New Issue
Block a user