Skip to content

Commit

Permalink
Cleanup + placeholder pages
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Sep 23, 2024
1 parent f4b088f commit 7dd19fd
Show file tree
Hide file tree
Showing 17 changed files with 236 additions and 138 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gcr-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:

- name: gcloud auth
id: 'auth'
uses: 'google-github-actions/auth@v0'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'

# Setup gcloud CLI
- name: gcloud setup
uses: google-github-actions/setup-gcloud@v0
uses: google-github-actions/setup-gcloud@v2

- name: gcloud docker-auth
run: gcloud auth configure-docker
Expand Down
10 changes: 5 additions & 5 deletions .gitignore
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
34 changes: 33 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# To Do

- [ ] copy to clipboard for variations
- [ ] patterns into database
- [ ] search.html
- [ ] test button for variations
- [ ] comments via utteranc.es
- [ ] homepage: search
- [ ] homepage: featured
- [ ] homepage: latest
Expand All @@ -16,6 +16,38 @@
- [ ] post to places besides RXP
- [ ] 404 page


## Data Model

all:
- owner
- created
- updated

PatternBase (rpb)
- handle
- title
- details_md
- featured
- public
- tags (array)

PatternVariation (rpv)
- title
- engines (array)
- pattern
- flags
- replacement

PatternVariationTest (rpt)
- haystack
- results (JSONB, per POSIX)


## POSIX API

- [GNU](https://www.gnu.org/software/libc/manual/html_node/Regexp-Subexpressions.html)

## Fonts

- Roboto Slab for headings
Expand Down
55 changes: 40 additions & 15 deletions app/components/ColorSchemeToggle/ColorSchemeToggle.tsx
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>
13 changes: 10 additions & 3 deletions app/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ColorSchemeToggle } from "~/components/ColorSchemeToggle/ColorSchemeToggle";

const links = [
{ link: 'https://github.com/regexplanet/regex-zone/issues', label: 'Feedback' },
Expand All @@ -20,8 +21,14 @@ export function Footer() {
);

return (
<footer className="d-flex justify-content-center text-body-tertiary pt-3"><small>
{ initial }
</small></footer>
<>
<hr className="pt-3" />
<footer className="d-flex justify-content-center align-items-center text-body-tertiary"><small className="pe-3">
{ initial }
</small>

<ColorSchemeToggle />
</footer>
</>
)
}
45 changes: 17 additions & 28 deletions app/components/HeaderSearch/HeaderSearch.tsx
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>
</>
);
}
29 changes: 29 additions & 0 deletions app/components/NavbarLink.tsx
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>
);
}
1 change: 0 additions & 1 deletion app/components/Welcome/Welcome.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Anchor } from "react-bootstrap";

export function Welcome() {
return (
Expand Down
22 changes: 7 additions & 15 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useRouteError,
} from "@remix-run/react";
import { HeaderSearch } from "./components/HeaderSearch/HeaderSearch";
import { Container } from "react-bootstrap";
import { Footer } from "./components/Footer";

export function Layout({ children }: { children: React.ReactNode }) {
return (
Expand All @@ -33,7 +33,11 @@ export function Layout({ children }: { children: React.ReactNode }) {
</style>
</head>
<body>
<HeaderSearch />
<div className="container-lg">
{children}
</div>
<Footer />
<ScrollRestoration />
<Scripts />
</body>
Expand All @@ -48,16 +52,7 @@ export default function App() {
export function ErrorBoundary() {
const error = useRouteError();
return (
<html lang="en">
<head>
<title>Oops!</title>
<Meta />
<Links />

</head>
<body>
<HeaderSearch />
<Container>
<>
<h1 className="py-2">Error</h1>
<div>
{isRouteErrorResponse(error)
Expand All @@ -66,9 +61,6 @@ export function ErrorBoundary() {
? error.message
: "Unknown Error"}
</div>
</Container>
<Scripts />
</body>
</html>
</>
);
}
11 changes: 4 additions & 7 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { MetaFunction } from "@remix-run/node";
import { Container } from 'react-bootstrap';
import { isRouteErrorResponse, Link as RemixLink, Links, Meta, Scripts, useRouteError } from "@remix-run/react";

import { ColorSchemeToggle } from "~/components/ColorSchemeToggle/ColorSchemeToggle";
import { HeaderSearch } from "~/components/HeaderSearch/HeaderSearch";
import { Footer } from "~/components/Footer";

Expand All @@ -16,15 +14,10 @@ export const meta: MetaFunction = () => {
export default function Index() {
return (
<>
<HeaderSearch />
<Container>
<h1 className="py-2">
Welcome to the Regex Zone
</h1>
<div className="pb-3">Check out the collection of useful <RemixLink to="/patterns/">Regular Expression Patterns</RemixLink>!</div>
<ColorSchemeToggle />
</Container>
<Footer />
</>
);
}
Expand All @@ -39,6 +32,8 @@ export function ErrorBoundary() {
<Links />
</head>
<body>
<HeaderSearch />
<div className="container-lg">
<h1>xx
{isRouteErrorResponse(error)
? `${error.status} ${error.statusText}`
Expand All @@ -47,6 +42,8 @@ export function ErrorBoundary() {
: "Unknown Error"}
</h1>
<Scripts />
</div>
<Footer />
</body>
</html>
);
Expand Down
19 changes: 19 additions & 0 deletions app/routes/links._index.tsx
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>
</>
);
}
Loading

0 comments on commit 7dd19fd

Please sign in to comment.