diff --git a/app/layout.tsx b/app/layout.tsx index e614d32..af93498 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,7 +1,7 @@ 'use client' -import { Background, Footer, Header, Sidebar } from 'chora/components' -import { MenuContextProvider, ThemeContextProvider } from 'chora/contexts' +import { Background, Footer, Header, Sidebar } from 'components' +import { MenuContextProvider, ThemeContextProvider } from 'contexts' import './globals.css' diff --git a/app/page.tsx b/app/page.tsx index 1fb3c49..6118fa3 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,4 +1,4 @@ -import { ArrowRight } from 'chora/components/icons' +import { ArrowRight } from 'components/icons' import { Metadata } from 'next' import Link from 'next/link' diff --git a/app/research/page.tsx b/app/research/page.tsx index 861d6b8..c88b76c 100644 --- a/app/research/page.tsx +++ b/app/research/page.tsx @@ -13,6 +13,7 @@ async function getResearchArtifacts() { return [ { group: 'about', items: getArtifacts('about') }, { group: 'concepts', items: getArtifacts('concepts') }, + { group: 'tutorials', items: getArtifacts('tutorials') }, ] } diff --git a/app/research/tutorials/[id]/page.module.css b/app/research/tutorials/[id]/page.module.css new file mode 100644 index 0000000..6f43de1 --- /dev/null +++ b/app/research/tutorials/[id]/page.module.css @@ -0,0 +1,33 @@ +.page { + composes: page from '../../../../styles/page.css'; +} + +.banner { + composes: banner-document from '../../../../styles/banner.css'; +} + +.content { + composes: content-full from '../../../../styles/content.css'; +} + +.content h2, +.content h3, +.content h4 { + margin: 1em 0; +} + +.content h4 { + font-weight: 400; +} + +.content p { + margin: 1em 0; + padding: 0 !important; +} + +.content pre { + background-color: rgba(150, 150, 150, 0.1); + border-radius: 1em; + margin: 1em 0; + padding: 1.5em; +} diff --git a/app/research/tutorials/[id]/page.tsx b/app/research/tutorials/[id]/page.tsx new file mode 100644 index 0000000..052a47c --- /dev/null +++ b/app/research/tutorials/[id]/page.tsx @@ -0,0 +1,35 @@ +import { Metadata } from 'next' + +import { getArtifact, getArtifacts } from '@utils' + +import styles from './page.module.css' + +export const metadata: Metadata = { + title: 'chora studio | research', +} + +export const generateStaticParams = () => { + return getArtifacts('tutorials') +} + +const ArtifactPage = async ({ params }: any) => { + const artifact = await getArtifact('tutorials', params.id) + return ( +
+
+
+

{`author: ${artifact.author}`}

+

{`title: ${artifact.title}`}

+

{`description: ${artifact.description}`}

+

{`created: ${artifact.created.toDateString()}`}

+

{`updated: ${artifact.updated.toDateString()}`}

+
+
+
+
+
+
+ ) +} + +export default ArtifactPage diff --git a/artifacts b/artifacts index 9e1988c..0c7e7cd 160000 --- a/artifacts +++ b/artifacts @@ -1 +1 @@ -Subproject commit 9e1988ceec80250b0e9ca6c940ebf9d37d276cb3 +Subproject commit 0c7e7cda9a3a94515da59cbd40c694dd6b9d9d9c diff --git a/bun.lockb b/bun.lockb old mode 100644 new mode 100755 index 2c73027..8013ac2 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/Background.module.css b/components/Background.module.css new file mode 100644 index 0000000..5c24869 --- /dev/null +++ b/components/Background.module.css @@ -0,0 +1,30 @@ +.background { + align-items: center; + display: flex; + height: 100vh; + justify-content: center; + position: fixed; + width: 100vw; + z-index: -1; +} + +.background { + background: var(--background-primary); +} + +.background img { + scale: 65%; +} + +@media (max-width: 850px) { + .background img { + scale: 35%; + } +} + +.background div { + background: var(--background-primary-transparent); + height: 100vh; + position: fixed; + width: 100vw; +} diff --git a/components/Background.tsx b/components/Background.tsx new file mode 100644 index 0000000..1c9c0d5 --- /dev/null +++ b/components/Background.tsx @@ -0,0 +1,24 @@ +'use client' + +import Image from 'next/image' +import * as React from 'react' +import { useContext } from 'react' + +import darkBackground from '../assets/images/chora_dark.png' +import lightBackground from '../assets/images/chora_light.png' +import { ThemeContext } from '../contexts' + +import styles from './Background.module.css' + +const Background = () => { + const { darkTheme } = useContext(ThemeContext) + + return ( +
+ chora +
+
+ ) +} + +export default Background diff --git a/components/Footer.module.css b/components/Footer.module.css new file mode 100644 index 0000000..a3075cc --- /dev/null +++ b/components/Footer.module.css @@ -0,0 +1,11 @@ +.footer { + composes: footer from '../styles/footer.css'; +} + +.title { + composes: footer-title from '../styles/footer.css'; +} + +.list { + composes: footer-list from '../styles/footer.css'; +} diff --git a/components/Footer.tsx b/components/Footer.tsx new file mode 100644 index 0000000..d945121 --- /dev/null +++ b/components/Footer.tsx @@ -0,0 +1,57 @@ +'use client' + +import Image from 'next/image' +import Link from 'next/link' +import * as React from 'react' +import { useContext } from 'react' + +import choraDarkSmall from '../assets//images/chora_dark_small.png' +import choraLightSmall from '../assets//images/chora_light_small.png' +import { ThemeContext } from '../contexts' +import { ArrowUpRight } from './icons' + +import styles from './Footer.module.css' + +const Footer = ({ about, sections }: any) => { + const { darkTheme } = useContext(ThemeContext) + + const currentYear = new Date().getFullYear() + + return ( +
+
{darkTheme?.toString()}
+
+
+ chora +

{`© ${currentYear} Chora Studio LLC`}

+
+ {about && ( +
+

{about.title}

+
{about.text}
+
+ )} + {sections.map((section: any) => ( +
+

{section.title}

+
    + {section.items.map((item: any) => ( +
  • + + {item.title} + {item.target && } + +
  • + ))} +
+
+ ))} +
+
+ ) +} + +export default Footer diff --git a/components/Header.module.css b/components/Header.module.css new file mode 100644 index 0000000..8e4d950 --- /dev/null +++ b/components/Header.module.css @@ -0,0 +1,22 @@ +.header { + composes: header from '../styles/header.css'; +} + +.menu { + composes: header-menu from '../styles/header.css'; +} + +.divider { + composes: header-divider from '../styles/header.css'; +} + +.button { + background: none; +} + +@media (min-width: 850px) { + .buttonMobile { + composes: button; + display: none !important; + } +} diff --git a/components/Header.tsx b/components/Header.tsx new file mode 100644 index 0000000..5637d05 --- /dev/null +++ b/components/Header.tsx @@ -0,0 +1,74 @@ +'use client' + +import Link from 'next/link' +import * as React from 'react' +import { useContext } from 'react' + +import { MenuContext, ThemeContext } from '../contexts' +import { HeaderTitle } from '.' +import { ArrowUpRight, MenuIcon, ThemeIcon } from './icons' + +import styles from './Header.module.css' + +const Header = ({ title, items, showMenuButton, showMobileTitle }: any) => { + const { showMenu, setShowMenu } = useContext(MenuContext) + const { darkTheme, setDarkTheme } = useContext(ThemeContext) + + const toggleMenu = () => { + if (showMenu) { + setShowMenu(false) + } else { + setShowMenu(true) + } + } + + const toggleTheme = () => { + if (darkTheme) { + setDarkTheme(false) + } else { + setDarkTheme(true) + } + } + + return ( +
+
{darkTheme?.toString()}
+
+ {showMenuButton && ( + + )} + +
+
    + {items && + items.map((item: any, i: number) => + item === 'divider' ? ( +
  • + {'|'} +
  • + ) : ( +
  • + + {item.title} + {item.target && } + +
  • + ), + )} +
+ +
+
+
+ ) +} + +export default Header diff --git a/components/HeaderTitle.module.css b/components/HeaderTitle.module.css new file mode 100644 index 0000000..1b474bd --- /dev/null +++ b/components/HeaderTitle.module.css @@ -0,0 +1,17 @@ +.title { + composes: header-title from '../styles/header.css'; +} + +@media (max-width: 850px) { + .title { + display: none !important; + } +} + +.mobileTitle { + composes: header-title from '../styles/header.css'; +} + +.headerTitleText { + composes: header-title-text from '../styles/header.css'; +} diff --git a/components/HeaderTitle.tsx b/components/HeaderTitle.tsx new file mode 100644 index 0000000..349998c --- /dev/null +++ b/components/HeaderTitle.tsx @@ -0,0 +1,26 @@ +'use client' + +import Image from 'next/image' +import Link from 'next/link' +import * as React from 'react' + +import choraLogoDark from '../assets/images/chora_dark_small.png' +import choraLogoLight from '../assets/images/chora_light_small.png' + +import styles from './HeaderTitle.module.css' + +const HeaderTitle = ({ darkTheme, title, showMobileTitle }: any) => ( +
+ + chora +
+ {'chora '} + {title && title.titleX && ( + {title.titleX} + )} +
+ +
+) + +export default HeaderTitle diff --git a/components/Sidebar.module.css b/components/Sidebar.module.css new file mode 100644 index 0000000..4543196 --- /dev/null +++ b/components/Sidebar.module.css @@ -0,0 +1,35 @@ +.sidebar { + composes: sidebar from '../styles/sidebar.css'; +} + +.mobileOnly { + composes: sidebar from '../styles/sidebar.css'; + min-height: calc(100vh - var(--header-height)); + width: 75vw; +} + +/* cancel sidebar styling */ +@media (max-width: 850px) { + .mobileOnly { + display: block !important; + } +} + +@media (min-width: 850px) { + .mobileOnly { + display: none !important; + } +} + +.active { + composes: sidebar-link-active from '../styles/sidebar.css'; +} + +.divider { + margin: 1em 0; +} + +.button { + background: none; + color: var(--color-theme); +} diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx new file mode 100644 index 0000000..5bd407e --- /dev/null +++ b/components/Sidebar.tsx @@ -0,0 +1,58 @@ +'use client' + +import Link from 'next/link' +import { usePathname } from 'next/navigation' +import * as React from 'react' +import { useContext, useEffect, useState } from 'react' + +import { MenuContext } from '../contexts' +import { ArrowUpRight } from './icons' + +import styles from './Sidebar.module.css' + +const Sidebar = ({ items, mobileOnly }: any) => { + const currentRoute = usePathname() + + const { showMenu, setShowMenu } = useContext(MenuContext) + + const [initRoute, setInitRoute] = useState('') + + useEffect(() => { + if (currentRoute && !initRoute) { + setInitRoute(currentRoute) + } + if (initRoute && initRoute !== currentRoute) { + setInitRoute(currentRoute) + setShowMenu(false) + } + }, [currentRoute, initRoute, setShowMenu]) + + return !mobileOnly || showMenu ? ( +
+
    + {items.map((item: any, i: number) => + item === 'divider' ? ( +
    + ) : ( +
  • + + {item.title} + {item.target === '_blank' && } + +
  • + ), + )} +
+
+ ) : ( + <> + ) +} + +export default Sidebar diff --git a/components/icons/ArrowLeft.tsx b/components/icons/ArrowLeft.tsx new file mode 100644 index 0000000..67b8823 --- /dev/null +++ b/components/icons/ArrowLeft.tsx @@ -0,0 +1,54 @@ +'use client' + +import * as React from 'react' +import { useContext } from 'react' + +import { ThemeContext } from '../../contexts' + +const defaultColor = '#00C3A5' + +const ArrowRight = ({ color, useTheme }: any) => { + const { darkTheme } = useContext(ThemeContext) + + const stroke = color || defaultColor + + return ( + + + + + + ) +} + +export default ArrowRight diff --git a/components/icons/ArrowRight.tsx b/components/icons/ArrowRight.tsx new file mode 100644 index 0000000..4ce313c --- /dev/null +++ b/components/icons/ArrowRight.tsx @@ -0,0 +1,54 @@ +'use client' + +import * as React from 'react' +import { useContext } from 'react' + +import { ThemeContext } from '../../contexts' + +const defaultColor = '#00C3A5' + +const ArrowRight = ({ color, useTheme }: any) => { + const { darkTheme } = useContext(ThemeContext) + + const stroke = color || defaultColor + + return ( + + + + + + ) +} + +export default ArrowRight diff --git a/components/icons/ArrowUpRight.tsx b/components/icons/ArrowUpRight.tsx new file mode 100644 index 0000000..ada3b9d --- /dev/null +++ b/components/icons/ArrowUpRight.tsx @@ -0,0 +1,54 @@ +'use client' + +import * as React from 'react' +import { useContext } from 'react' + +import { ThemeContext } from '../../contexts' + +const defaultColor = '#00C3A5' + +const ArrowUpRight = ({ color, useTheme }: any) => { + const { darkTheme } = useContext(ThemeContext) + + const stroke = color || defaultColor + + return ( + + + + + + ) +} + +export default ArrowUpRight diff --git a/components/icons/CheckIcon.tsx b/components/icons/CheckIcon.tsx new file mode 100644 index 0000000..d875e79 --- /dev/null +++ b/components/icons/CheckIcon.tsx @@ -0,0 +1,31 @@ +import * as React from 'react' + +const CheckIcon = ({ darkTheme }: any) => ( + + + + +) + +export default CheckIcon diff --git a/components/icons/MenuIcon.tsx b/components/icons/MenuIcon.tsx new file mode 100644 index 0000000..32544cf --- /dev/null +++ b/components/icons/MenuIcon.tsx @@ -0,0 +1,40 @@ +import * as React from 'react' + +const MenuIcon = ({ darkTheme }: any) => ( + + + + + +) + +export default MenuIcon diff --git a/components/icons/ThemeIcon.tsx b/components/icons/ThemeIcon.tsx new file mode 100644 index 0000000..badd089 --- /dev/null +++ b/components/icons/ThemeIcon.tsx @@ -0,0 +1,15 @@ +import * as React from 'react' + +const ThemeIcon = ({ darkTheme }: any) => ( + + + + +) + +export default ThemeIcon diff --git a/components/icons/UserIcon.tsx b/components/icons/UserIcon.tsx new file mode 100644 index 0000000..137222f --- /dev/null +++ b/components/icons/UserIcon.tsx @@ -0,0 +1,17 @@ +import * as React from 'react' + +const UserIcon = ({ darkTheme }: any) => ( + + + + + + +) + +export default UserIcon diff --git a/components/icons/index.ts b/components/icons/index.ts new file mode 100644 index 0000000..a4a94ce --- /dev/null +++ b/components/icons/index.ts @@ -0,0 +1,7 @@ +export { default as ArrowLeft } from './ArrowLeft' +export { default as ArrowRight } from './ArrowRight' +export { default as ArrowUpRight } from './ArrowUpRight' +export { default as CheckIcon } from './CheckIcon' +export { default as MenuIcon } from './MenuIcon' +export { default as ThemeIcon } from './ThemeIcon' +export { default as UserIcon } from './UserIcon' diff --git a/components/index.ts b/components/index.ts new file mode 100644 index 0000000..89f737f --- /dev/null +++ b/components/index.ts @@ -0,0 +1,5 @@ +export { default as Background } from './Background' +export { default as Footer } from './Footer' +export { default as Header } from './Header' +export { default as HeaderTitle } from './HeaderTitle' +export { default as Sidebar } from './Sidebar' diff --git a/contexts/MenuContext.tsx b/contexts/MenuContext.tsx new file mode 100644 index 0000000..3b74922 --- /dev/null +++ b/contexts/MenuContext.tsx @@ -0,0 +1,26 @@ +'use client' + +import * as React from 'react' +import { createContext, useState } from 'react' + +const MenuContext = createContext({}) + +const MenuContextProvider = (props: any) => { + const [showMenu, setShowMenu] = useState(false) + const [showUser, setShowUser] = useState(false) + + return ( + + {props.children} + + ) +} + +export { MenuContext, MenuContextProvider } diff --git a/contexts/ThemeContext.tsx b/contexts/ThemeContext.tsx new file mode 100644 index 0000000..2d888bc --- /dev/null +++ b/contexts/ThemeContext.tsx @@ -0,0 +1,56 @@ +'use client' + +import * as React from 'react' +import { createContext, useEffect, useState } from 'react' + +export const cachedDarkKey = 'chora-web-dark' + +const initDarkTheme = () => { + let initDarkTheme = false + + if ( + typeof localStorage !== 'undefined' && + localStorage.getItem(cachedDarkKey) + ) { + initDarkTheme = localStorage.getItem(cachedDarkKey) === 'true' + } else if (typeof window !== 'undefined') { + initDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches + } + + return initDarkTheme +} + +const ThemeContext = createContext({}) + +const ThemeContextProvider = (props: any) => { + const [darkTheme, setDarkTheme] = useState(initDarkTheme()) + + useEffect(() => { + if (typeof window !== 'undefined' && typeof localStorage !== 'undefined') { + const root = window.document.documentElement + + if (darkTheme) { + root.classList.add('dark-theme') + root.style.backgroundColor = '#161616' // --background-secondary (dark-theme) + } else { + root.classList.remove('dark-theme') + root.style.backgroundColor = '#FCFCFC' // --background-secondary (light-theme) + } + + localStorage.setItem(cachedDarkKey, darkTheme ? 'true' : 'false') + } + }, [darkTheme]) + + return ( + + {props.children} + + ) +} + +export { ThemeContext, ThemeContextProvider } diff --git a/contexts/index.ts b/contexts/index.ts new file mode 100644 index 0000000..33e6364 --- /dev/null +++ b/contexts/index.ts @@ -0,0 +1,4 @@ +'use client' + +export { MenuContext, MenuContextProvider } from './MenuContext' +export { ThemeContext, ThemeContextProvider } from './ThemeContext' diff --git a/styles/content.css b/styles/content.css index 8d71841..e32bc92 100644 --- a/styles/content.css +++ b/styles/content.css @@ -56,7 +56,6 @@ .content ul { list-style-position: inside; - margin: 0.5em 0 2em 0; } .content li { diff --git a/styles/footer.css b/styles/footer.css new file mode 100644 index 0000000..4e72733 --- /dev/null +++ b/styles/footer.css @@ -0,0 +1,68 @@ +/* footer */ + +.footer { + background: var(--background-primary); + box-shadow: var(--box-shadow); + height: var(--footer-height); + overflow: hidden; + width: 100%; +} + +.footer > div { + align-items: center; + display: flex; + height: inherit; + justify-content: center; + margin: 0 1em; +} + +/* footer-title */ + +.footer-title { + margin: 0 4em; +} + +.footer-title img { + display: block; + height: 120px; + margin: 0 auto 1em auto; + width: 120px; +} + +@media (max-width: 850px) { + .footer-title img { + display: none; + } +} + +.footer-title h4 { + display: block; +} + +/* footer-list */ + +.footer-list { + font-size: 0.95em; + height: 160px; + margin: 0 2em; + max-width: 220px; + min-width: 140px; +} + +@media (max-width: 850px) { + .footer-list { + display: none; + } +} + +.footer-list h3 { + margin-bottom: 1em; +} + +.footer-list ul { + margin: 0 0.5em; +} + +.footer-list li { + margin: 0.75em; +} diff --git a/styles/header.css b/styles/header.css new file mode 100644 index 0000000..52dfef0 --- /dev/null +++ b/styles/header.css @@ -0,0 +1,95 @@ +/* header */ + +.header { + background: var(--background-primary); + box-shadow: var(--box-shadow); + height: var(--header-height); + overflow: hidden; + position: fixed; + width: 100%; + z-index: 1; +} + +.header > div { + display: flex; + height: inherit; + justify-content: space-between; + margin: 0 2em; +} + +/* header-title */ + +.header-title { + align-items: center; + display: flex; + justify-content: center; +} + +.header-title a { + align-items: center; + display: flex; + justify-content: center; +} + +.header-title img { + height: 36px; + width: 36px; +} + +@media (max-width: 850px) { + .header-title img { + height: 27px; + width: 27px; + } +} + +.header-title-text { + color: var(--color-text); + font-size: 20px; + font-weight: 300; /* cancel link weight */ + margin-left: 8px; +} + +@media (max-width: 850px) { + .header-title-text { + font-size: 15px; + margin-left: 6px; + } +} + +/* header-menu */ + +.header-menu { + display: flex; + height: var(--header-height); +} + +@media (max-width: 850px) { + .header-menu > div { + display: none; + } +} + +.header-menu ul { + align-items: center; + display: flex; + justify-content: center; + list-style: none inside none; + margin: 0 1em; +} + +@media (max-width: 850px) { + .header-menu ul { + display: none; + } +} + +.header-menu li { + margin: 0.6em; +} + +/* header-divider */ + +.header-divider { + color: var(--color-theme); +} diff --git a/styles/sidebar.css b/styles/sidebar.css new file mode 100644 index 0000000..3aeb99c --- /dev/null +++ b/styles/sidebar.css @@ -0,0 +1,59 @@ +/* sidebar */ + +.sidebar { + background: var(--background-primary); + box-shadow: var(--box-shadow); + height: calc(100vh - var(--header-height)); + margin-top: var(--header-height); + overflow-y: scroll; + position: fixed; + scrollbar-width: none; /* hide scrollbar - Firefox */ + width: var(--sidebar-width); + z-index: 1; + -ms-overflow-style: none; /* hide scrollbar - Internet Explorer 10+ */ +} + +.sidebar::-webkit-scrollbar { + display: none; /* hide scrollbar - Safari and Chrome */ +} + +.sidebar ul { + list-style: none; +} + +.sidebar > ul { + padding: 1.5em; +} + +@media (max-width: 850px) { + .sidebar > ul { + padding: 1em; + } +} + +.sidebar > ul > li { + font-size: 1.2em; + padding: 0.75em 1.5em; +} + +.sidebar > ul > ul { + margin-left: 1.75em; +} + +.sidebar > ul > ul > li { + font-size: 1.1em; + padding: 0.65em 0.5em; +} + +/* sidebar-active */ + +.sidebar-active { + font-weight: 500; +} + +/* sidebar-breadcrumb */ + +.sidebar-breadcrumb a { + font-size: 0.85em; + margin-left: -0.5em; +} diff --git a/tsconfig.json b/tsconfig.json index a4667fd..75ca144 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,6 +20,8 @@ } ], "paths": { + "@components": ["components/index.ts"], + "@contexts": ["contexts/index.ts"], "@utils": ["utils/index.ts"] } },