Skip to content

Commit

Permalink
Dynamic intra-page on Sistent
Browse files Browse the repository at this point in the history
Signed-off-by: lakshya <[email protected]>
  • Loading branch information
lakshz committed Mar 14, 2024
1 parent 8f50600 commit 3f368f7
Show file tree
Hide file tree
Showing 41 changed files with 2,577 additions and 1,931 deletions.
45 changes: 42 additions & 3 deletions src/components/SistentNavigation/content.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
export const content = [
{ id: 0, link: "/projects/sistent/about", text: "About Sistent" },
{ id: 1, link: "/projects/sistent/identity/color", text: "Colors" },
{ id: 2, link: "/projects/sistent/identity/spacing", text: "Spacing" },
{ id: 3, link: "/projects/sistent/identity/typography", text: "Typography" },
{ id: 4, link: "/projects/sistent/components", text: "Components" },
{ id: 2, link: "/projects/sistent/identity/color/guidance", text: "Colors" },
{ id: 3, link: "/projects/sistent/identity/color/code", text: "Colors" },
{ id: 4, link: "/projects/sistent/identity/spacing", text: "Spacing" },
{
id: 5,
link: "/projects/sistent/identity/spacing/guidance",
text: "Spacing",
},
{ id: 6, link: "/projects/sistent/identity/spacing/code", text: "Spacing" },
{ id: 7, link: "/projects/sistent/identity/typography", text: "Typography" },
{
id: 8,
link: "/projects/sistent/identity/typography/guidance",
text: "Typography",
},
{
id: 9,
link: "/projects/sistent/identity/typography/code",
text: "Typography",
},
{ id: 10, link: "/projects/sistent/components/button", text: "Button" },
{
id: 10,
link: "/projects/sistent/components/button/guidance",
text: "Button",
},
{ id: 11, link: "/projects/sistent/components/button/code", text: "Button" },
{
id: 12,
link: "/projects/sistent/components/text-input",
text: "Text Input",
},
{
id: 13,
link: "/projects/sistent/components/text-input/guidance",
text: "Text Input",
},
{
id: 14,
link: "/projects/sistent/components/text-input/code",
text: "Text Input",
},
];
24 changes: 21 additions & 3 deletions src/components/SistentNavigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ const TOC = () => {
<li>
<Link
to="/projects/sistent/identity/color"
className="toc-sub-heading toc-sub-inline identity-item"
className={`toc-sub-heading toc-sub-inline identity-item ${
location.pathname.includes(
"/projects/sistent/identity/color"
)
? "active"
: ""
}`}
activeClassName="active"
>
Color
Expand All @@ -76,7 +82,13 @@ const TOC = () => {
<li>
<Link
to="/projects/sistent/identity/spacing"
className="toc-sub-heading toc-sub-inline identity-item"
className={`toc-sub-heading toc-sub-inline identity-item ${
location.pathname.includes(
"/projects/sistent/identity/spacing"
)
? "active"
: ""
}`}
activeClassName="active"
>
Spacing
Expand All @@ -85,7 +97,13 @@ const TOC = () => {
<li>
<Link
to="/projects/sistent/identity/typography"
className="toc-sub-heading toc-sub-inline identity-item"
className={`toc-sub-heading toc-sub-inline identity-item ${
location.pathname.includes(
"/projects/sistent/identity/typography"
)
? "active"
: ""
}`}
activeClassName="active"
>
Typography
Expand Down
101 changes: 101 additions & 0 deletions src/components/SistentNavigation/intra-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React, { useEffect, useState } from "react";
import { Link } from "gatsby";
import styled from "styled-components";

const JoinCommunityWrapper = styled.div`
width: 18rem;
@media screen and (min-width: 751px) and (max-width: 1279px) {
display: none;
}
.intra-page {
position: sticky;
top: 10rem;
right: 0rem;
margin-right: 1rem;
padding-bottom: 5rem;
padding-right: 2rem;
align-items: left;
justify-content: space-around;
display: flex;
flex-direction: column;
overflow: hidden;
.list {
color: #000000;
}
.active {
font-weight: 5000;
color: #000000;
}
ul {
list-style: none;
top: 3rem;
li {
padding-bottom: 0.5rem;
padding-top: 0.5rem;
}
}
@media only screen and (min-width: 1280px) and (max-width: 1350px) {
padding-right: 0rem;
margin-right: 0rem;
}
@media only screen and (max-width: 950px) {
width: 0;
opacity: 0;
height: 0;
transition: none;
visibility: hidden;
}
}
.learn {
width: 10rem;
}
`;

function IntraPage() {
const [contents, setContents] = useState([]);

useEffect(() => {
const anchors = document.querySelectorAll(".main-content > a");
console.log(anchors);
if (anchors) {
setContents(
Array.from(anchors).map((a) => ({
id: a.id,
link: `#${a.id}`,
text: a.id,
}))
);
}
}, []);

const [intapath, setIntapath] = useState(null);
useEffect(() => {
const path = window.location.pathname;
setIntapath(path);
}, []);

return (
<JoinCommunityWrapper>
<div className="intra-page">
<ul>
{contents.map((x) => (
<li key={x.id} className="list">
<Link
to={`${intapath}${x.link}`}
key={x.id}
activeClassName="active"
>
{x.text}
</Link>
</li>
))}
</ul>
</div>
</JoinCommunityWrapper>
);
}

export default IntraPage;
12 changes: 7 additions & 5 deletions src/components/handbook-navigation/intra-page.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React, { useEffect, useState } from "react";
import { Link } from "gatsby";
import styled from "styled-components";
import { link } from "joi";

const JoinCommunityWrapper = styled.div`
@media screen and (min-width: 751px) and (max-width: 1279px) {
display:none;
display: none;
}
.intra-page {
position: sticky;
Expand Down Expand Up @@ -35,10 +36,10 @@ const JoinCommunityWrapper = styled.div`
padding-top: 0.5rem;
}
}
@media only screen and (min-width: 1280px) and (max-width: 1350px){
padding-right:0rem;
margin-right:0rem;
}
@media only screen and (min-width: 1280px) and (max-width: 1350px) {
padding-right: 0rem;
margin-right: 0rem;
}
@media only screen and (max-width: 950px) {
width: 0;
opacity: 0;
Expand All @@ -59,6 +60,7 @@ function IntraPage({ contents }) {
const path = window.location.pathname;
setIntapath(path);
}, []);

return (
<JoinCommunityWrapper>
<div className="intra-page">
Expand Down
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/components/button/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import { ButtonCode } from "../../../../../sections/Projects/Sistent/components/button/code";

const ButtonCodePage = () => {
return <ButtonCode />;
};

export default ButtonCodePage;
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/components/button/guidance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import { ButtonGuidance } from "../../../../../sections/Projects/Sistent/components/button/guidance";

const ButtonGuidancePage = () => {
return <ButtonGuidance />;
};

export default ButtonGuidancePage;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import SistentButton from "../../../../sections/Projects/Sistent/components/button";
import SistentButton from "../../../../../sections/Projects/Sistent/components/button";

const SistentButtonPage = () => {
return <SistentButton />;
Expand Down
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/components/text-input/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import { TextInputCode } from "../../../../../sections/Projects/Sistent/components/text-input/code";

const TextInputCodePage = () => {
return <TextInputCode />;
};

export default TextInputCodePage;
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/components/text-input/guidance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import { TextInputGuidance } from "../../../../../sections/Projects/Sistent/components/text-input/guidance";

const TextInputGuidancePage = () => {
return <TextInputGuidance />;
};

export default TextInputGuidancePage;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import SistentTextInput from "../../../../sections/Projects/Sistent/components/text-input";
import SistentTextInput from "../../../../../sections/Projects/Sistent/components/text-input";

const SistentTextInputPage = () => {
return <SistentTextInput />;
Expand Down
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/identity/color/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import ColorCode from "../../../../../sections/Projects/Sistent/identity/color/code";

const ColorCodePage = () => {
return <ColorCode />;
};

export default ColorCodePage;
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/identity/color/guidance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import ColorGuidance from "../../../../../sections/Projects/Sistent/identity/color/guidance";

const ColorGuidancePage = () => {
return <ColorGuidance />;
};

export default ColorGuidancePage;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import SistentIdentityColor from "../../../../sections/Projects/Sistent/identity/color";
import SistentIdentityColor from "../../../../../sections/Projects/Sistent/identity/color";

const SistentIdentityColorPage = () => {
return <SistentIdentityColor />;
Expand Down
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/identity/spacing/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import { SpacingCode } from "../../../../../sections/Projects/Sistent/identity/spacing/code";

const SpacingCodePage = () => {
return <SpacingCode />;
};

export default SpacingCodePage;
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/identity/spacing/guidance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import { SpacingGuidance } from "../../../../../sections/Projects/Sistent/identity/spacing/guidance";

const SpacingGuidancePage = () => {
return <SpacingGuidance />;
};

export default SpacingGuidancePage;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import SistentIdentitySpacing from "../../../../sections/Projects/Sistent/identity/spacing/index";
import SistentIdentitySpacing from "../../../../../sections/Projects/Sistent/identity/spacing/index";

const IdentitySpacingPage = () => {
return <SistentIdentitySpacing />;
Expand Down
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/identity/typography/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import TypographyCode from "../../../../../sections/Projects/Sistent/identity/typography/code";

const TypographyCodePage = () => {
return <TypographyCode />;
};

export default TypographyCodePage;
8 changes: 8 additions & 0 deletions src/pages/projects/sistent/identity/typography/guidance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from "react";
import TypographyGuidance from "../../../../../sections/Projects/Sistent/identity/typography/guidance";

const TypographyGuidancePage = () => {
return <TypographyGuidance />;
};

export default TypographyGuidancePage;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import SistentTypography from "../../../../sections/Projects/Sistent/identity/typography";
import SistentTypography from "../../../../../sections/Projects/Sistent/identity/typography";

const SistentTypographyPage = () => {
return <SistentTypography />;
Expand Down
Loading

0 comments on commit 3f368f7

Please sign in to comment.