-
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
f4b088f
commit 7dd19fd
Showing
17 changed files
with
236 additions
and
138 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
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,7 +1,7 @@ | ||
node_modules | ||
|
||
/.cache | ||
/build | ||
/.cache | ||
.DS_Store | ||
.env | ||
.yarn/install-state.gz | ||
.DS_Store | ||
node_modules | ||
tmp* | ||
*.tmp |
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,25 +1,50 @@ | ||
'use client'; | ||
|
||
import { Button, ButtonGroup } from 'react-bootstrap'; | ||
|
||
function setColorScheme(scheme: 'light' | 'dark' | 'auto') { | ||
if (scheme == 'auto') { | ||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | ||
scheme = 'dark'; | ||
} else { | ||
scheme = 'light'; | ||
} | ||
import React from "react"; | ||
|
||
|
||
|
||
|
||
function getColorScheme() { | ||
|
||
if (typeof window === 'undefined') { | ||
return 'light'; | ||
} | ||
|
||
if (document.documentElement.hasAttribute('data-bs-theme')) { | ||
return document.documentElement.getAttribute('data-bs-theme'); | ||
} | ||
document.documentElement.setAttribute('data-bs-theme', scheme); | ||
|
||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | ||
return 'dark'; | ||
} else { | ||
return 'light'; | ||
} | ||
|
||
} | ||
|
||
export function ColorSchemeToggle() { | ||
const [ currentScheme, setColorScheme ] = React.useState(getColorScheme()); | ||
|
||
|
||
const onClick = (scheme: 'light' | 'dark' | 'auto') => { | ||
if (scheme == 'auto') { | ||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { | ||
scheme = 'dark'; | ||
} else { | ||
scheme = 'light'; | ||
} | ||
} | ||
document.documentElement.setAttribute('data-bs-theme', scheme); | ||
setColorScheme(scheme); | ||
} | ||
|
||
return ( | ||
<ButtonGroup> | ||
<Button onClick={() => setColorScheme('light')}>Light</Button> | ||
<Button onClick={() => setColorScheme('dark')}>Dark</Button> | ||
<Button onClick={() => setColorScheme('auto')}>Auto</Button> | ||
</ButtonGroup> | ||
<div className="btn-group" role="group" aria-label="Color scheme selector"> | ||
<button className={`btn btn-sm ${ currentScheme == 'light' ? 'btn-primary' : 'btn-outline-primary'}`} onClick={() => onClick('light')}>Light</button> | ||
<button className={`btn btn-sm ${ currentScheme == 'dark' ? 'btn-primary' : 'btn-outline-primary'}`} onClick={() => onClick('dark')}>Dark</button> | ||
</div> | ||
); | ||
} | ||
|
||
// <button onClick={() => setColorScheme('auto')}>Auto</button> |
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,45 +1,34 @@ | ||
import { PiMagnifyingGlass } from 'react-icons/pi'; | ||
import { Link as RemixLink, useLocation } from "@remix-run/react"; | ||
import { Container, Navbar } from 'react-bootstrap'; | ||
import { PiBlueprint, PiBlueprintBold, PiLink, PiMagnifyingGlass, PiMagnifyingGlassBold, PiPlay, PiPlayBold, PiUsersThree, PiUsersThreeBold } from 'react-icons/pi'; | ||
import { Link as RemixLink } from "@remix-run/react"; | ||
|
||
import RegexZoneSvg from '../Logos/RegexZoneSvg'; | ||
import { NavbarLink, NavbarLinkItem } from '~/components/NavbarLink'; | ||
|
||
const links = [ | ||
{ link: '/patterns/', label: 'Patterns' }, | ||
//{ link: '/docs/', label: 'Docs' }, | ||
{ link: 'https://www.regexplanet.com/', label: 'Testing' }, | ||
//{ link: 'https://github.com/regexplanet/regex-zone/discussions', label: 'Community' }, | ||
{ link: '/search.html', label: 'Search' }, | ||
{ link: '/404', label: '404' }, | ||
const links:NavbarLinkItem[] = [ | ||
{ link: '/patterns/', label: 'Patterns', icon: <PiBlueprint />, icon_bold: <PiBlueprintBold /> }, | ||
{ link: '/links/', label: 'Links', icon: <PiLink />, icon_bold: <PiLink /> }, | ||
{ link: '/testing/', label: 'Testing', icon: <PiPlay />, icon_bold: <PiPlayBold /> }, | ||
{ link: '/sharing/', label: 'Sharing', icon: <PiUsersThree />, icon_bold: <PiUsersThreeBold /> }, | ||
{ link: '/search.html', label: 'Search', icon: <PiMagnifyingGlass />, icon_bold: <PiMagnifyingGlassBold /> }, | ||
]; | ||
|
||
export function HeaderSearch() { | ||
const { pathname } = useLocation(); | ||
|
||
const items = links.map((link) => ( | ||
<li className="nav-item" key = {link.label} > | ||
<RemixLink | ||
className={pathname.startsWith(link.link) ? 'nav-link active fw-bold' : 'nav-link'} | ||
to={link.link} | ||
> | ||
{link.label} | ||
</RemixLink> | ||
</li> | ||
)); | ||
const items = links.map((link, index) => (<NavbarLink key={`key${index}`} link={link} />)); | ||
|
||
return ( | ||
<> | ||
<Navbar className="bg-body-tertiary border-bottom"> | ||
<Container> | ||
<Navbar.Brand as={RemixLink} className="fw-bold" to="/"> | ||
<RegexZoneSvg height={'2rem'} className="pe-2" /> | ||
<nav className="navbar navbar-expand bg-body-tertiary border-bottom"> | ||
<div className="container-lg"> | ||
<RemixLink className="navbar-brand fs-4 fw-bold" to="/"> | ||
<RegexZoneSvg height={'2rem'} className="pe-2 d-none d-md-inline" /> | ||
Regex Zone | ||
</Navbar.Brand> | ||
</RemixLink> | ||
<ul className="navbar-nav"> | ||
{items} | ||
</ul> | ||
</Container> | ||
</Navbar> | ||
</div> | ||
</nav> | ||
</> | ||
); | ||
} |
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,29 @@ | ||
import { Link as RemixLink, useLocation } from "@remix-run/react"; | ||
|
||
export type NavbarLinkProps = { | ||
link: NavbarLinkItem; | ||
}; | ||
|
||
export type NavbarLinkItem = { | ||
link: string; | ||
label: string; | ||
icon: JSX.Element; | ||
icon_bold: JSX.Element; | ||
}; | ||
|
||
export function NavbarLink({ link }: NavbarLinkProps) { | ||
const { pathname } = useLocation(); | ||
const isActive = pathname.startsWith(link.link) | ||
|
||
return ( | ||
<li className="nav-item" key={link.label} > | ||
<RemixLink | ||
className={`nav-link px-3 py-0 py-lg-2 ${isActive ? ' active fw-bold' : ''}`} | ||
to={link.link} | ||
> | ||
<span className="d-lg-none" style={{"fontSize": "1.5rem"}}>{isActive ? link.icon_bold : link.icon}</span> | ||
<span className="d-none d-lg-inline">{link.label}</span> | ||
</RemixLink> | ||
</li> | ||
); | ||
} |
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,3 @@ | ||
import { Anchor } from "react-bootstrap"; | ||
|
||
export function Welcome() { | ||
return ( | ||
|
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,19 @@ | ||
import type { MetaFunction } from "@remix-run/node"; | ||
|
||
export const meta: MetaFunction = () => { | ||
return [ | ||
{ title: "Links - Regex Zone" }, | ||
{ name: "description", content: "Random interesting links vaguely related to regular expressions" }, | ||
]; | ||
}; | ||
|
||
export default function Index() { | ||
return ( | ||
<> | ||
<h1 className="py-2">Links</h1> | ||
<div className="alert alert-info"> | ||
Coming soon... | ||
</div> | ||
</> | ||
); | ||
} |
Oops, something went wrong.